feat: SongCreator 씬 완성 — Beat Sage URL 지원, info.dat 메타데이터 자동 추출
- BeatSageUploader: audio_url 지원(UploadFromUrl), PollAndDownload 공통화, ZIP 500 오류 3회 재시도 - BeatSageConverter: info.dat 파싱(SongMetadata), BPM 자동 감지 → 노트 타이밍 변환에 적용 - SongCreatorManager: title/BPM 필수 입력 제거, 난이도 4개 자동 선택, GenerateFlowFromUrl 버그 수정 - NasPublisher: audioPath null 허용(URL 흐름에서 로컬 파일 없는 경우 스킵) - .gitignore/.gitattributes 초기 설정 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace VRSDK.EditorCode
|
||||
{
|
||||
[CustomEditor(typeof(AnimatorHelper))]
|
||||
public class I_AnimatorHelperInspector : Editor
|
||||
{
|
||||
private void Awake()
|
||||
{
|
||||
( target as AnimatorHelper ).ConstructAnimatorControllerInfo();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59b3f90f5357c9448901878af57a2c30
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Editor/I_AnimatorHelperInspector.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,13 @@
|
||||
using UnityEditor;
|
||||
using VRSDK.Climbing;
|
||||
|
||||
namespace VRSDK.EditorCode
|
||||
{
|
||||
[CustomEditor(typeof(ClimbPoint))]
|
||||
public class I_VR_ClimbPointInspector : I_VR_GrabbableInspector
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fcc59dacb29a235469e8fb0f08d7dee7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Editor/I_VR_ClimbPointInspector.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,65 @@
|
||||
using Platinio.SDK.EditorTools;
|
||||
using UnityEditor;
|
||||
|
||||
|
||||
namespace VRSDK.EditorCode
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(VR_DistanceGrab))]
|
||||
public class I_VR_DistanceGrabInspector : Editor
|
||||
{
|
||||
|
||||
private SerializedProperty pointerTransform = null;
|
||||
private SerializedProperty grabDistance = null;
|
||||
private SerializedProperty grabRadius = null;
|
||||
private SerializedProperty checkForObstruction = null;
|
||||
private SerializedProperty guideLineAlwaysVisible = null;
|
||||
private SerializedProperty canTriggerLineRender = null;
|
||||
private SerializedProperty lineTriggerInput = null;
|
||||
private SerializedProperty lineRender = null;
|
||||
private SerializedProperty layerMask = null;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
pointerTransform = serializedObject.FindProperty( "pointerTransform" );
|
||||
grabDistance = serializedObject.FindProperty( "grabDistance" );
|
||||
grabRadius = serializedObject.FindProperty( "grabRadius" );
|
||||
checkForObstruction = serializedObject.FindProperty( "checkForObstruction" );
|
||||
guideLineAlwaysVisible = serializedObject.FindProperty( "guideLineAlwaysVisible" );
|
||||
canTriggerLineRender = serializedObject.FindProperty( "canTriggerLineRender" );
|
||||
lineTriggerInput = serializedObject.FindProperty( "lineTriggerInput" );
|
||||
lineRender = serializedObject.FindProperty( "lineRender" );
|
||||
layerMask = serializedObject.FindProperty( "layerMask" );
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
PlatinioEditorGUILayout.PropertyField(pointerTransform);
|
||||
PlatinioEditorGUILayout.PropertyField(grabDistance);
|
||||
PlatinioEditorGUILayout.PropertyField(grabRadius);
|
||||
PlatinioEditorGUILayout.PropertyField(checkForObstruction);
|
||||
PlatinioEditorGUILayout.PropertyField(guideLineAlwaysVisible);
|
||||
|
||||
if (!guideLineAlwaysVisible.boolValue)
|
||||
{
|
||||
PlatinioEditorGUILayout.PropertyField( canTriggerLineRender );
|
||||
|
||||
if (canTriggerLineRender.boolValue)
|
||||
PlatinioEditorGUILayout.PropertyField( lineTriggerInput );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
canTriggerLineRender.boolValue = false;
|
||||
}
|
||||
|
||||
PlatinioEditorGUILayout.PropertyField(lineRender);
|
||||
PlatinioEditorGUILayout.PropertyField(layerMask);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d02b46e6b5ee3849ba0e2f03d444026
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Editor/I_VR_DistanceGrabInspector.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,120 @@
|
||||
using Platinio.SDK.EditorTools;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
namespace VRSDK.EditorCode
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor( typeof( VR_DropZone ) )]
|
||||
public class I_VR_DropZoneInspector : Editor
|
||||
{
|
||||
private VR_DropZone targetScript = null;
|
||||
|
||||
private SerializedProperty dropZoneMode = null;
|
||||
private SerializedProperty dropPoint = null;
|
||||
private SerializedProperty dropZoneColliderArray = null;
|
||||
private SerializedProperty startingDrop = null;
|
||||
private SerializedProperty shouldFly = null;
|
||||
private SerializedProperty flyTime = null;
|
||||
private SerializedProperty syncronizePosition = null;
|
||||
private SerializedProperty syncronizeRot = null;
|
||||
private SerializedProperty dropRadius = null;
|
||||
private SerializedProperty usePreview = null;
|
||||
private SerializedProperty onDropStateChange = null;
|
||||
private SerializedProperty disableCollidersOnDrop = null;
|
||||
private SerializedProperty canStack = null;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
targetScript = (VR_DropZone) target;
|
||||
|
||||
dropZoneMode = serializedObject.FindProperty( "dropZoneMode" );
|
||||
dropPoint = serializedObject.FindProperty( "dropPoint" );
|
||||
dropZoneColliderArray = serializedObject.FindProperty( "dropZoneColliderArray" );
|
||||
startingDrop = serializedObject.FindProperty( "startingDrop" );
|
||||
shouldFly = serializedObject.FindProperty( "shouldFly" );
|
||||
flyTime = serializedObject.FindProperty( "flyTime" );
|
||||
syncronizePosition = serializedObject.FindProperty( "syncronizePosition" );
|
||||
syncronizeRot = serializedObject.FindProperty( "syncronizeRot" );
|
||||
dropRadius = serializedObject.FindProperty( "dropRadius" );
|
||||
usePreview = serializedObject.FindProperty( "usePreview" );
|
||||
onDropStateChange = serializedObject.FindProperty( "onDrop" );
|
||||
disableCollidersOnDrop = serializedObject.FindProperty( "disableCollidersOnDrop" );
|
||||
canStack = serializedObject.FindProperty( "canStack" );
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
PlatinioEditorGUILayout.PropertyField( dropZoneMode );
|
||||
PlatinioEditorGUILayout.PropertyField( dropPoint );
|
||||
PlatinioEditorGUILayout.PropertyField( startingDrop );
|
||||
|
||||
if ((DropZoneMode) dropZoneMode.enumValueIndex == DropZoneMode.Collider)
|
||||
{
|
||||
PlatinioEditorGUILayout.PropertyField( dropZoneColliderArray, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
PlatinioEditorGUILayout.PropertyField( dropRadius );
|
||||
}
|
||||
|
||||
PlatinioEditorGUILayout.PropertyField( shouldFly );
|
||||
|
||||
if (shouldFly.boolValue)
|
||||
{
|
||||
PlatinioEditorGUILayout.PropertyField( flyTime );
|
||||
}
|
||||
|
||||
PlatinioEditorGUILayout.PropertyField( syncronizePosition );
|
||||
PlatinioEditorGUILayout.PropertyField( syncronizeRot );
|
||||
PlatinioEditorGUILayout.PropertyField( usePreview );
|
||||
PlatinioEditorGUILayout.PropertyField(canStack);
|
||||
PlatinioEditorGUILayout.PropertyField(disableCollidersOnDrop);
|
||||
PlatinioEditorGUILayout.PropertyField( onDropStateChange );
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
public void OnSceneGUI()
|
||||
{
|
||||
if (targetScript == null)
|
||||
OnEnable();
|
||||
|
||||
if (targetScript.DropPoint == null)
|
||||
return;
|
||||
|
||||
|
||||
if (targetScript.DropPoint == null || (DropZoneMode) dropZoneMode.enumValueIndex == DropZoneMode.Collider)
|
||||
return;
|
||||
|
||||
//handler for dropzone range
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
Handles.color = Color.blue;
|
||||
float r = Handles.RadiusHandle( Quaternion.identity, targetScript.DropPoint.position, dropRadius.floatValue );
|
||||
|
||||
|
||||
|
||||
if (GUI.changed)
|
||||
{
|
||||
targetScript.SetDropRadiusViaInspector( r );
|
||||
EditorUtility.SetDirty( targetScript );
|
||||
EditorSceneManager.MarkAllScenesDirty();
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject( target, "Changed Drop Distance" );
|
||||
targetScript.SetDropRadiusViaInspector(r);
|
||||
EditorUtility.SetDirty(targetScript);
|
||||
EditorSceneManager.MarkAllScenesDirty();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5869d5d67f00664c83d4a9c0b2d1095
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Editor/I_VR_DropZoneInspector.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,586 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Platinio.SDK.EditorTools;
|
||||
using UnityEditor.EditorTools;
|
||||
|
||||
namespace VRSDK.EditorCode
|
||||
{
|
||||
|
||||
|
||||
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(VR_Grabbable))]
|
||||
public class I_VR_GrabbableInspector : Editor
|
||||
{
|
||||
|
||||
private SerializedProperty onGrabStateChange = null;
|
||||
private SerializedProperty perfectGrab = null;
|
||||
private SerializedProperty grabDistance = null;
|
||||
private SerializedProperty grabFlyTime = null;
|
||||
private SerializedProperty shouldFly = null;
|
||||
private SerializedProperty startOnRightController = null;
|
||||
private SerializedProperty startOnLeftController = null;
|
||||
private SerializedProperty autoGrab = null;
|
||||
private SerializedProperty grabButton = null;
|
||||
private SerializedProperty grabLayer = null;
|
||||
private SerializedProperty unGrabLayer = null;
|
||||
private SerializedProperty enableColliderOnGrab = null;
|
||||
private SerializedProperty shareHandInteractSettings = null;
|
||||
private SerializedProperty shareHandAnimationSettings = null;
|
||||
private SerializedProperty leftHandSettings = null;
|
||||
private SerializedProperty handSettings = null;
|
||||
private SerializedProperty rightHandSettings = null;
|
||||
private SerializedProperty preserveKinematicState = null;
|
||||
private SerializedProperty useDistanceGrab = null;
|
||||
private SerializedProperty ignoreColliderList = null;
|
||||
private SerializedProperty toggleGrab = null;
|
||||
private SerializedProperty grabbableCollider = null;
|
||||
private SerializedProperty interactableType = null;
|
||||
|
||||
private Texture handIcon = null;
|
||||
private Texture playIcon = null;
|
||||
private Texture eventIcon = null;
|
||||
private Texture settingsIcon = null;
|
||||
|
||||
protected VR_Grabbable grabbable = null;
|
||||
protected VR_GrabbableEditorPart editorPart = null;
|
||||
|
||||
protected List<ConsoleMessage> consoleList = null;
|
||||
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
GetSerializeProperties();
|
||||
LoadIcons();
|
||||
|
||||
grabbable = (VR_Grabbable) target;
|
||||
editorPart = grabbable.EditorPart;
|
||||
}
|
||||
|
||||
private void GetSerializeProperties()
|
||||
{
|
||||
onGrabStateChange = serializedObject.FindProperty("onGrabStateChange");
|
||||
perfectGrab = serializedObject.FindProperty("perfectGrab");
|
||||
grabDistance = serializedObject.FindProperty("interactDistance");
|
||||
grabFlyTime = serializedObject.FindProperty("grabFlyTime");
|
||||
shouldFly = serializedObject.FindProperty("shouldFly");
|
||||
startOnRightController = serializedObject.FindProperty("startOnRightController");
|
||||
startOnLeftController = serializedObject.FindProperty("startOnLeftController");
|
||||
autoGrab = serializedObject.FindProperty("autoGrab");
|
||||
grabButton = serializedObject.FindProperty("interactButton");
|
||||
grabLayer = serializedObject.FindProperty("grabLayer");
|
||||
unGrabLayer = serializedObject.FindProperty("unGrabLayer");
|
||||
enableColliderOnGrab = serializedObject.FindProperty("enableColliderOnGrab");
|
||||
shareHandInteractSettings = serializedObject.FindProperty("shareHandInteractionSettings");
|
||||
shareHandAnimationSettings = serializedObject.FindProperty("shareHandAnimationSettings");
|
||||
rightHandSettings = serializedObject.FindProperty("rightHandSettings");
|
||||
leftHandSettings = serializedObject.FindProperty("leftHandSettings");
|
||||
handSettings = serializedObject.FindProperty("handSettings");
|
||||
preserveKinematicState = serializedObject.FindProperty("preserveKinematicState");
|
||||
useDistanceGrab = serializedObject.FindProperty("useDistanceGrab");
|
||||
ignoreColliderList = serializedObject.FindProperty("ignoreColliderList");
|
||||
toggleGrab = serializedObject.FindProperty("toggleGrab");
|
||||
interactableType = serializedObject.FindProperty("interactableType");
|
||||
grabbableCollider = serializedObject.FindProperty("grabCollider");
|
||||
|
||||
}
|
||||
|
||||
private void LoadIcons()
|
||||
{
|
||||
handIcon = PlatinioEditorGUILayout.LoadIcon("hand");
|
||||
playIcon = PlatinioEditorGUILayout.LoadIcon("play");
|
||||
eventIcon = PlatinioEditorGUILayout.LoadIcon("calendar");
|
||||
settingsIcon = PlatinioEditorGUILayout.LoadIcon("settings");
|
||||
}
|
||||
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
consoleList = new List<ConsoleMessage>();
|
||||
|
||||
|
||||
editorPart.selectedMenu = (GrabSelectionMenu) PlatinioEditorGUILayout.DrawGridButtons( (int) editorPart.selectedMenu, 2 ,
|
||||
new GUIContent(" Animation" , playIcon),
|
||||
new GUIContent(" Grab Settings", handIcon),
|
||||
new GUIContent(" Other", settingsIcon),
|
||||
new GUIContent(" Events", eventIcon)
|
||||
);
|
||||
|
||||
EditorGUILayout.Space(30);
|
||||
|
||||
|
||||
if (editorPart.selectedMenu == GrabSelectionMenu.Animation)
|
||||
{
|
||||
DrawGrabbableAnimationSettings();
|
||||
}
|
||||
else if (editorPart.selectedMenu == GrabSelectionMenu.GrabSettings)
|
||||
{
|
||||
DrawGrabSettings();
|
||||
}
|
||||
else if (editorPart.selectedMenu == GrabSelectionMenu.Other)
|
||||
{
|
||||
DrawOtherSettings();
|
||||
}
|
||||
else if (editorPart.selectedMenu == GrabSelectionMenu.Events)
|
||||
{
|
||||
DrawEventSettings();
|
||||
}
|
||||
|
||||
ConsoleUpdate();
|
||||
|
||||
EditorGUILayout.Space(20);
|
||||
|
||||
GUIContent content = new GUIContent("Console (" + consoleList.Count + ")", "");
|
||||
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutConsole , delegate { DrawConsole(); });
|
||||
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
}
|
||||
|
||||
private void DrawConsole()
|
||||
{
|
||||
PlatinioEditorGUILayout.DrawConsole(consoleList);
|
||||
}
|
||||
|
||||
private void ConsoleUpdate()
|
||||
{
|
||||
AnimationSettingsConsoleUpdate();
|
||||
GrabSettingsConsoleUpdate();
|
||||
}
|
||||
|
||||
private void DrawGrabbableAnimationSettings()
|
||||
{
|
||||
DrawGrabbableAnimationSettingsHeader();
|
||||
EditorGUILayout.Space(20);
|
||||
DrawGrabbableAnimationSettingsBody();
|
||||
}
|
||||
|
||||
protected virtual void DrawGrabbableAnimationSettingsHeader()
|
||||
{
|
||||
PlatinioEditorGUILayout.DrawTooltipBox(playIcon, "Animation Settings",
|
||||
"You can define diferent grab animations for each hand, and you can leave it empty if you don't wanna play any animation," +
|
||||
" some people prefer to hide the hand while grabbing something too.");
|
||||
}
|
||||
|
||||
protected virtual void DrawGrabbableAnimationSettingsBody()
|
||||
{
|
||||
SerializedProperty rightHand = serializedObject.FindProperty("rightHandAnimationSettings");
|
||||
SerializedProperty leftHand = serializedObject.FindProperty("leftHandAnimationSettings");
|
||||
SerializedProperty share = serializedObject.FindProperty("handAnimationSettings");
|
||||
|
||||
|
||||
GUIContent content = new GUIContent("Share Settings?", "Use the same settings for the left and right hand?");
|
||||
shareHandAnimationSettings.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content, shareHandAnimationSettings.boolValue);
|
||||
|
||||
if (shareHandAnimationSettings.boolValue)
|
||||
{
|
||||
content = new GUIContent("Both Hands", "Share settings for both hands");
|
||||
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutShareHandAnimationSettings, delegate { DrawHandAnimationSettings(share); });
|
||||
}
|
||||
else
|
||||
{
|
||||
content = new GUIContent("Left Hand", "Left hand animation settings");
|
||||
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutRightHandAnimationSettings, delegate { DrawHandAnimationSettings(leftHand); });
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
content = new GUIContent("Right Hand", "Right hand animation settings");
|
||||
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutLeftHandAnimationSettings, delegate { DrawHandAnimationSettings(rightHand); });
|
||||
}
|
||||
}
|
||||
|
||||
private void AnimationSettingsConsoleUpdate()
|
||||
{
|
||||
VR_HandAnimationSettings leftHand = grabbable.LeftHandAnimationSettings;
|
||||
VR_HandAnimationSettings rightHand = grabbable.RightHandAnimationSettings;
|
||||
VR_HandAnimationSettings share = grabbable.HandAnimationSettings;
|
||||
|
||||
ConsoleMessage animationEmptyLog = new ConsoleMessage("You have missing grab animations, default grab animation will be use", MessageType.Warning);
|
||||
|
||||
if (shareHandAnimationSettings.boolValue)
|
||||
{
|
||||
if (!share.hideHandOnGrab && share.animation == null)
|
||||
consoleList.Add(animationEmptyLog);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!leftHand.hideHandOnGrab && leftHand.animation == null)
|
||||
consoleList.Add(animationEmptyLog);
|
||||
else if (!rightHand.hideHandOnGrab && rightHand.animation == null)
|
||||
consoleList.Add(animationEmptyLog);
|
||||
}
|
||||
}
|
||||
|
||||
private void GrabSettingsConsoleUpdate()
|
||||
{
|
||||
VR_HandInteractSettings leftHand = grabbable.LeftHandSettings;
|
||||
VR_HandInteractSettings rightHand = grabbable.RightHandSettings;
|
||||
VR_HandInteractSettings share = grabbable.HandSettings;
|
||||
|
||||
|
||||
ConsoleMessage grabPointMissing = new ConsoleMessage("You forget to assign a grab point in GrabSettings", MessageType.Error);
|
||||
ConsoleMessage highlightPointMissing = new ConsoleMessage("You forget to assign a higlight point in GrabSettings", MessageType.Warning);
|
||||
|
||||
if (!shareHandInteractSettings.boolValue)
|
||||
{
|
||||
if ( editorPart.IsMissingGrabPoint( rightHand ) || editorPart.IsMissingGrabPoint(leftHand ))
|
||||
consoleList.Add(grabPointMissing);
|
||||
if ( editorPart.IsMissinHiglightPoint(rightHand) || editorPart.IsMissinHiglightPoint(leftHand) )
|
||||
consoleList.Add(highlightPointMissing);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("share hand interact settings value " + shareHandAnimationSettings.boolValue);
|
||||
|
||||
if ( editorPart.IsMissingGrabPoint(share) )
|
||||
consoleList.Add(grabPointMissing);
|
||||
if (editorPart.IsMissinHiglightPoint(share))
|
||||
consoleList.Add(highlightPointMissing);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void DrawHandAnimationSettings(SerializedProperty property)
|
||||
{
|
||||
SerializedProperty hideOnGrab = property.FindPropertyRelative("hideHandOnGrab");
|
||||
SerializedProperty animation = property.FindPropertyRelative("animation");
|
||||
|
||||
EditorGUILayout.BeginVertical("Box");
|
||||
GUIContent content = new GUIContent("Hide Hand?", "Should this hand hide while grabbing the object?");
|
||||
hideOnGrab.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content , hideOnGrab.boolValue);
|
||||
|
||||
if (!hideOnGrab.boolValue)
|
||||
{
|
||||
content = new GUIContent("Grab Animation", "The animation use while grabbing the object");
|
||||
EditorGUILayout.PropertyField(animation , content);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void DrawGrabSettings()
|
||||
{
|
||||
DrawGrabSettingsHeader();
|
||||
PlatinioEditorGUILayout.Space(3);
|
||||
DrawGrabSettingsBody();
|
||||
}
|
||||
|
||||
protected virtual void DrawGrabSettingsHeader()
|
||||
{
|
||||
PlatinioEditorGUILayout.DrawTooltipBox(handIcon, "Grab Settings",
|
||||
"In this section you can define the behavior of the grabbable object, for example should this object move to the hand position? use " +
|
||||
"toggle or use auto grab feature");
|
||||
}
|
||||
|
||||
protected virtual void DrawGrabSettingsBody()
|
||||
{
|
||||
GUIContent content = new GUIContent("Basic", "Grabbable basic settings");
|
||||
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutBasic, DrawGrabBasicSettings);
|
||||
|
||||
PlatinioEditorGUILayout.Space(2);
|
||||
|
||||
content = new GUIContent("Interaction", "Grabbable interaction settings");
|
||||
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutInteraction, DrawHandInteractionSettings);
|
||||
|
||||
PlatinioEditorGUILayout.Space(2);
|
||||
|
||||
content = new GUIContent("Input", "Grabbable input settings");
|
||||
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutInput, DrawGrabInput);
|
||||
|
||||
content = new GUIContent("Editor Tools", "");
|
||||
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutEditorTools, DrawEditorTools);
|
||||
}
|
||||
|
||||
private void DrawEditorTools()
|
||||
{
|
||||
EditorGUILayout.BeginVertical("Box");
|
||||
if (GUILayout.Button("Update Grab Position Offset"))
|
||||
{
|
||||
grabbable.UpdateGrabPositionOffset();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
protected virtual void DrawGrabInput()
|
||||
{
|
||||
EditorGUILayout.BeginVertical("Box");
|
||||
|
||||
GUIContent content = new GUIContent("Use Auto Grab", "Button use in controller for grabbing");
|
||||
autoGrab.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content , autoGrab.boolValue);
|
||||
|
||||
if (!autoGrab.boolValue)
|
||||
{
|
||||
grabbable.SetStartOnLeftHand(false);
|
||||
grabbable.SetStartOnRightHand(false);
|
||||
|
||||
content = new GUIContent("Grab Button", "Button use in controller for grabbing");
|
||||
grabButton.enumValueIndex = (int)(VR_InputButton)EditorGUILayout.EnumPopup(content, (VR_InputButton) grabButton.enumValueIndex);
|
||||
|
||||
content = new GUIContent("Use Toggle", "Button use in controller for grabbing");
|
||||
toggleGrab.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content , toggleGrab.boolValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
int newSelection = startOnLeftController.boolValue ? 1 : 0;
|
||||
newSelection = PlatinioEditorGUILayout.DrawGridButtons(newSelection, 2,
|
||||
new GUIContent(" Right Hand"),
|
||||
new GUIContent(" Left Hand")
|
||||
|
||||
);
|
||||
|
||||
startOnLeftController.boolValue = newSelection == 1;
|
||||
startOnRightController.boolValue = newSelection == 0;
|
||||
editorPart.handSelected = newSelection;
|
||||
|
||||
}
|
||||
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
protected virtual void DrawGrabBasicSettings()
|
||||
{
|
||||
EditorGUILayout.BeginVertical("Box");
|
||||
|
||||
GUIContent content = new GUIContent("Use Distance Grab?", "Enable this object to be grabbed by the user very far away " +
|
||||
"by just pointing the hand to the object and pressing the grab button");
|
||||
useDistanceGrab.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content, useDistanceGrab.boolValue);
|
||||
|
||||
content = new GUIContent("Grab Distance", "How far the hand can be it order to grab the object");
|
||||
grabDistance.floatValue = EditorGUILayout.FloatField(content, grabDistance.floatValue);
|
||||
|
||||
content = new GUIContent("Update Grab Point?", "If in use the object grab point will be update base on the hand position");
|
||||
perfectGrab.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content , perfectGrab.boolValue);
|
||||
|
||||
if (!perfectGrab.boolValue)
|
||||
{
|
||||
content = new GUIContent("Use Fly?", "Should this object fly to the hand?");
|
||||
shouldFly.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content , shouldFly.boolValue);
|
||||
|
||||
if (shouldFly.boolValue)
|
||||
{
|
||||
content = new GUIContent("Fly Time", "time in seconds use in order to fly to the hand");
|
||||
grabFlyTime.floatValue = EditorGUILayout.FloatField(content, grabFlyTime.floatValue);
|
||||
}
|
||||
}
|
||||
|
||||
content = new GUIContent("Interactable Type", "The type of interactable type (Recommended Distance)");
|
||||
interactableType.enumValueIndex = (int)(InteractableType)EditorGUILayout.EnumPopup(content, (InteractableType) interactableType.enumValueIndex);
|
||||
|
||||
if (interactableType.enumValueIndex == (int) InteractableType.Collider)
|
||||
{
|
||||
content = new GUIContent("Grabbable Collider", "Collider use to detect interactions");
|
||||
grabbableCollider.objectReferenceValue = EditorGUILayout.ObjectField(content, grabbableCollider.objectReferenceValue, typeof(Collider), true);
|
||||
|
||||
if (grabbableCollider.objectReferenceValue == null)
|
||||
{
|
||||
ConsoleMessage colliderMissing = new ConsoleMessage("You forget to assign an interact collider in Grab Settings", MessageType.Error);
|
||||
consoleList.Add(colliderMissing);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
}
|
||||
|
||||
protected virtual void DrawHandInteractionSettings()
|
||||
{
|
||||
EditorGUILayout.BeginVertical("Box");
|
||||
|
||||
SerializedProperty share = serializedObject.FindProperty("handSettings");
|
||||
SerializedProperty leftHand = serializedObject.FindProperty("leftHandSettings");
|
||||
SerializedProperty rightHand = serializedObject.FindProperty("rightHandSettings");
|
||||
|
||||
|
||||
GUIContent content = new GUIContent("Share Settings?", "Use the same settings for the left and right hand?");
|
||||
shareHandInteractSettings.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content , shareHandInteractSettings.boolValue);
|
||||
|
||||
|
||||
if (shareHandInteractSettings.boolValue)
|
||||
{
|
||||
content = new GUIContent("Both Hands", "Share settings for both hands");
|
||||
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutShareHandInteractSettings, 1, delegate { DrawHandInteractionInspector(share); });
|
||||
}
|
||||
else
|
||||
{
|
||||
content = new GUIContent("Right Hand", "Settings apply just to the right hand");
|
||||
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutRightHandInteractSettings, 1, delegate { DrawHandInteractionInspector(rightHand); });
|
||||
|
||||
content = new GUIContent("Left Hand", "Settings apply just to the left hand");
|
||||
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutLeftHandInteractSettings, 1, delegate { DrawHandInteractionInspector(leftHand); });
|
||||
}
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void DrawHandInteractionInspector(SerializedProperty property)
|
||||
{
|
||||
GUIContent content;
|
||||
Rect rect;
|
||||
|
||||
SerializedProperty canInteract = property.FindPropertyRelative("canInteract");
|
||||
SerializedProperty interactPoint = property.FindPropertyRelative("interactPoint");
|
||||
SerializedProperty higlightPoint = property.FindPropertyRelative("highlightPoint");
|
||||
SerializedProperty rotationOffset = property.FindPropertyRelative("rotationOffset");
|
||||
|
||||
if (!shareHandInteractSettings.boolValue)
|
||||
{
|
||||
content = new GUIContent("Can Grab?", "Can this hand grab the object?");
|
||||
rect = GUILayoutUtility.GetRect(40f, 60f, 16f, 16f);
|
||||
rect.width -= 25;
|
||||
rect.x += 25;
|
||||
|
||||
canInteract.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content , rect , canInteract.boolValue);
|
||||
EditorGUILayout.Space(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
property.FindPropertyRelative("canInteract").boolValue = true;
|
||||
}
|
||||
|
||||
|
||||
if (canInteract.boolValue)
|
||||
{
|
||||
content = new GUIContent("Grab Point", "The point from where this object can be grabbed");
|
||||
rect = GUILayoutUtility.GetRect(40f, 60f, 16f, 16f);
|
||||
rect.width -= 25;
|
||||
rect.x += 25;
|
||||
|
||||
EditorGUI.PropertyField(rect, interactPoint, content);
|
||||
EditorGUILayout.Space(3);
|
||||
|
||||
content = new GUIContent("Highlight Point", "The point from where this object start the higlight");
|
||||
rect = GUILayoutUtility.GetRect(40f, 60f, 16f, 16f);
|
||||
rect.width -= 25;
|
||||
rect.x += 25;
|
||||
|
||||
EditorGUI.PropertyField(rect, higlightPoint, content);
|
||||
|
||||
content = new GUIContent("Rotation offset", "The rotation offset used while the object is being grab");
|
||||
rect = GUILayoutUtility.GetRect(80f, 80f, 45f, 45f);
|
||||
rect.width -= 25;
|
||||
rect.x += 25;
|
||||
|
||||
EditorGUI.PropertyField(rect , rotationOffset , content);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void DrawOtherSettings()
|
||||
{
|
||||
DrawOtherSettingsHeader();
|
||||
EditorGUILayout.Space(10);
|
||||
EditorGUILayout.BeginVertical("Box");
|
||||
DrawOtherSettingsBody();
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
protected virtual void DrawOtherSettingsHeader()
|
||||
{
|
||||
PlatinioEditorGUILayout.DrawTooltipBox(settingsIcon, "Other Settings",
|
||||
"In this section you have no so common settings but still useful in some cases");
|
||||
}
|
||||
|
||||
protected virtual void DrawOtherSettingsBody()
|
||||
{
|
||||
|
||||
|
||||
GUIContent content = new GUIContent("Preserve Kinematic? ", "The normal behaviour in a grabbable item is override the kinematic state " +
|
||||
"of the object so I can respond to physics once it is dropped, use this if you wanna to preserve the kinematic state of an object once it is dropped");
|
||||
preserveKinematicState.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content, preserveKinematicState.boolValue);
|
||||
|
||||
content = new GUIContent("Use Collider? ", "Use collider while grabbing?");
|
||||
enableColliderOnGrab.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content, enableColliderOnGrab.boolValue);
|
||||
|
||||
content = new GUIContent("Grab Layer ", "Collision layer used while this object is in grab state");
|
||||
grabLayer.intValue = EditorGUILayout.LayerField(content, grabLayer.intValue);
|
||||
|
||||
content = new GUIContent("UnGrab Layer ", "Collision layer used while this object is ungrab state");
|
||||
unGrabLayer.intValue = EditorGUILayout.LayerField(content, unGrabLayer.intValue);
|
||||
|
||||
PlatinioEditorGUILayout.PropertyField(ignoreColliderList, true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void DrawEventSettings()
|
||||
{
|
||||
|
||||
DrawEventSettingsHeader();
|
||||
EditorGUILayout.Space(10);
|
||||
DrawEventSettingsBody();
|
||||
|
||||
}
|
||||
|
||||
protected virtual void DrawEventSettingsHeader()
|
||||
{
|
||||
PlatinioEditorGUILayout.DrawTooltipBox(eventIcon, "Events",
|
||||
"You can control the logic from your grabbables in your game mostly by using this event, it sends an enum called" +
|
||||
"GrabState, and every value define a diferent action made by the user.\n\n" +
|
||||
"<b>Grab:</b> called the first frame when the player try to grab this object.\n" +
|
||||
"<b>Drop:</b> called the first frame when the player drops this object.\n" +
|
||||
"<b>UnGrab:</b> called inmediatly after drop, and stay in UnGrab state until grab event is raise again\n");
|
||||
}
|
||||
|
||||
protected virtual void DrawEventSettingsBody()
|
||||
{
|
||||
EditorGUILayout.BeginVertical("Box");
|
||||
PlatinioEditorGUILayout.PropertyField(onGrabStateChange);
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
|
||||
public void OnSceneGUI()
|
||||
{
|
||||
|
||||
float newGrabDistance = grabbable.GrabDistance;
|
||||
Transform center = null;
|
||||
|
||||
if (shareHandInteractSettings.boolValue)
|
||||
{
|
||||
center = grabbable.HandSettings.interactPoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
center = grabbable.RightHandSettings.interactPoint == null ? grabbable.LeftHandSettings.interactPoint : grabbable.RightHandSettings.interactPoint;
|
||||
}
|
||||
|
||||
if (center == null)
|
||||
center = grabbable.transform;
|
||||
|
||||
newGrabDistance = DrawDiscRadiusHandler(center.position, newGrabDistance);
|
||||
|
||||
grabbable.SetInteractDistanceViaInspector(newGrabDistance);
|
||||
EditorUtility.SetDirty(grabbable);
|
||||
|
||||
}
|
||||
|
||||
private float DrawDiscRadiusHandler(Vector3 center , float radius)
|
||||
{
|
||||
if (Camera.current == null)
|
||||
return radius;
|
||||
|
||||
Handles.color = Color.blue;
|
||||
Handles.color = new Color(0.0f, 0.0f, 1.0f, 0.125f);
|
||||
Handles.DrawSolidDisc(center, Camera.current.transform.forward, radius);
|
||||
Handles.color = new Color(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
|
||||
return Handles.RadiusHandle(Quaternion.LookRotation(Camera.current.transform.forward * -1.0f), center, radius, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 328f8501609a35d45b2cf5a39771103e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Editor/I_VR_GrabbableInspector.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,101 @@
|
||||
using Platinio.SDK.EditorTools;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
namespace VRSDK.EditorCode
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor( typeof( VR_GrabbableZone ) )]
|
||||
public class I_VR_GrabbableZoneInspector : Editor
|
||||
{
|
||||
|
||||
private SerializedProperty interactDistance = null;
|
||||
private SerializedProperty interactButton = null;
|
||||
private SerializedProperty usePerHandSettings = null;
|
||||
private SerializedProperty leftHandSettings = null;
|
||||
private SerializedProperty handSettings = null;
|
||||
private SerializedProperty rightHandSettings = null;
|
||||
private SerializedProperty grabbable = null;
|
||||
private VR_GrabbableZone targetScript = null;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
interactDistance = serializedObject.FindProperty( "interactDistance" );
|
||||
interactButton = serializedObject.FindProperty( "interactButton" );
|
||||
usePerHandSettings = serializedObject.FindProperty( "usePerHandSettings" );
|
||||
rightHandSettings = serializedObject.FindProperty( "rightHandSettings" );
|
||||
leftHandSettings = serializedObject.FindProperty( "leftHandSettings" );
|
||||
handSettings = serializedObject.FindProperty( "handSettings" );
|
||||
grabbable = serializedObject.FindProperty("grabbable");
|
||||
|
||||
targetScript = (VR_GrabbableZone) target;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
PlatinioEditorGUILayout.PropertyField( grabbable );
|
||||
PlatinioEditorGUILayout.PropertyField( interactDistance );
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void DrawHandSettings(SerializedProperty settings)
|
||||
{
|
||||
EditorGUILayout.PropertyField( settings, true );
|
||||
}
|
||||
|
||||
|
||||
public void OnSceneGUI()
|
||||
{/*
|
||||
if (targetScript == null)
|
||||
OnEnable();
|
||||
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
Handles.color = Color.blue;
|
||||
|
||||
|
||||
if (usePerHandSettings.boolValue)
|
||||
{
|
||||
float rightValue = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointRightHand == null ? targetScript.transform.position : targetScript.HighlightPointRightHand.position, interactDistance.floatValue );
|
||||
float leftValue = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointLeftHand == null ? targetScript.transform.position : targetScript.HighlightPointLeftHand.position, interactDistance.floatValue );
|
||||
|
||||
UpdateGrabDistanceValue( rightValue, leftValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (targetScript.HighlightPointHandSettings == null)
|
||||
return;
|
||||
|
||||
float value = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointHandSettings.position, interactDistance.floatValue );
|
||||
|
||||
targetScript.Grabbable.SetInteractDistanceViaInspector( value);
|
||||
EditorUtility.SetDirty( targetScript );
|
||||
//EditorSceneManager.MarkAllScenesDirty();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void UpdateGrabDistanceValue(float rightValue, float leftValue)
|
||||
{
|
||||
if (interactDistance.floatValue != rightValue)
|
||||
{
|
||||
targetScript.Grabbable.SetInteractDistanceViaInspector( rightValue );
|
||||
EditorUtility.SetDirty( targetScript );
|
||||
EditorSceneManager.MarkAllScenesDirty();
|
||||
}
|
||||
else if (interactDistance.floatValue != leftValue)
|
||||
{
|
||||
targetScript.Grabbable.SetInteractDistanceViaInspector( leftValue );
|
||||
EditorUtility.SetDirty( targetScript );
|
||||
EditorSceneManager.MarkAllScenesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62671d04d4f0c154baa3afa01f4c2444
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Editor/I_VR_GrabbableZoneInspector.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,112 @@
|
||||
using Platinio.SDK.EditorTools;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
namespace VRSDK.EditorCode
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(VR_Interactable))]
|
||||
public class I_VR_InteractableInspector : Editor
|
||||
{
|
||||
|
||||
private SerializedProperty interactDistance = null;
|
||||
private SerializedProperty interactButton = null;
|
||||
private SerializedProperty usePerHandSettings = null;
|
||||
private SerializedProperty leftHandSettings = null;
|
||||
private SerializedProperty handSettings = null;
|
||||
private SerializedProperty rightHandSettings = null;
|
||||
private SerializedProperty onInteractEvent = null;
|
||||
|
||||
private VR_Interactable targetScript = null;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
interactDistance = serializedObject.FindProperty("interactDistance");
|
||||
interactButton = serializedObject.FindProperty("interactButton");
|
||||
usePerHandSettings = serializedObject.FindProperty( "usePerHandSettings" );
|
||||
rightHandSettings = serializedObject.FindProperty( "rightHandSettings" );
|
||||
leftHandSettings = serializedObject.FindProperty( "leftHandSettings" );
|
||||
handSettings = serializedObject.FindProperty( "handSettings" );
|
||||
onInteractEvent = serializedObject.FindProperty( "onInteractEvent" );
|
||||
|
||||
targetScript = (VR_Interactable) target;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
PlatinioEditorGUILayout.PropertyField( interactDistance );
|
||||
PlatinioEditorGUILayout.PropertyField( usePerHandSettings );
|
||||
|
||||
if (usePerHandSettings.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField( rightHandSettings, true );
|
||||
EditorGUILayout.PropertyField( leftHandSettings, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField( handSettings, true );
|
||||
}
|
||||
|
||||
PlatinioEditorGUILayout.PropertyField( interactButton );
|
||||
PlatinioEditorGUILayout.PropertyField( onInteractEvent );
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void DrawHandSettings(SerializedProperty settings)
|
||||
{
|
||||
EditorGUILayout.PropertyField( settings, true );
|
||||
}
|
||||
|
||||
|
||||
public void OnSceneGUI()
|
||||
{
|
||||
if (targetScript == null)
|
||||
OnEnable();
|
||||
|
||||
//handler for interact distance
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
Handles.color = Color.blue;
|
||||
|
||||
|
||||
if (usePerHandSettings.boolValue)
|
||||
{
|
||||
float rightValue = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointRightHand == null ? targetScript.transform.position : targetScript.HighlightPointRightHand.position, interactDistance.floatValue );
|
||||
float leftValue = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointLeftHand == null ? targetScript.transform.position : targetScript.HighlightPointLeftHand.position, interactDistance.floatValue );
|
||||
|
||||
UpdateGrabDistanceValue( rightValue, leftValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (targetScript.HighlightPointHandSettings == null)
|
||||
return;
|
||||
|
||||
float value = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointHandSettings.position, interactDistance.floatValue );
|
||||
interactDistance.floatValue = value;
|
||||
}
|
||||
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void UpdateGrabDistanceValue(float rightValue, float leftValue)
|
||||
{
|
||||
if (interactDistance.floatValue != rightValue)
|
||||
{
|
||||
targetScript.SetInteractDistanceViaInspector( rightValue );
|
||||
EditorUtility.SetDirty( targetScript );
|
||||
EditorSceneManager.MarkAllScenesDirty();
|
||||
}
|
||||
else if (interactDistance.floatValue != leftValue)
|
||||
{
|
||||
targetScript.SetInteractDistanceViaInspector( leftValue );
|
||||
EditorUtility.SetDirty( targetScript );
|
||||
EditorSceneManager.MarkAllScenesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53ae1dabd110fdd45b91d120cec21153
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Editor/I_VR_InteractableInspector.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,139 @@
|
||||
using Platinio.SDK.EditorTools;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
namespace VRSDK.EditorCode
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(VR_Lever))]
|
||||
public class I_VR_LeverInspector : Editor
|
||||
{
|
||||
private SerializedProperty grabButton = null;
|
||||
private SerializedProperty grabDistance = null;
|
||||
private SerializedProperty transformBase = null;
|
||||
private SerializedProperty solverIterations = null;
|
||||
private SerializedProperty shouldBackToStartingPosition = null;
|
||||
private SerializedProperty onGrabStateChange = null;
|
||||
private SerializedProperty onValueChange = null;
|
||||
private SerializedProperty backForce = null;
|
||||
private SerializedProperty usePerHandSettings = null;
|
||||
private SerializedProperty leftHandSettings = null;
|
||||
private SerializedProperty handSettings = null;
|
||||
private SerializedProperty rightHandSettings = null;
|
||||
private SerializedProperty unGrabLayer = null;
|
||||
private SerializedProperty grabLayer = null;
|
||||
|
||||
private VR_Lever targetScript = null;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
transformBase = serializedObject.FindProperty( "transformBase" );
|
||||
solverIterations = serializedObject.FindProperty( "solverIterations" );
|
||||
shouldBackToStartingPosition = serializedObject.FindProperty( "shouldBackToStartingPosition" );
|
||||
onValueChange = serializedObject.FindProperty( "onValueChange" );
|
||||
backForce = serializedObject.FindProperty( "backForce" );
|
||||
onGrabStateChange = serializedObject.FindProperty( "onGrabStateChange" );
|
||||
grabDistance = serializedObject.FindProperty( "interactDistance" );
|
||||
grabButton = serializedObject.FindProperty( "interactButton" );
|
||||
usePerHandSettings = serializedObject.FindProperty( "usePerHandSettings" );
|
||||
rightHandSettings = serializedObject.FindProperty( "rightHandSettings" );
|
||||
leftHandSettings = serializedObject.FindProperty( "leftHandSettings" );
|
||||
handSettings = serializedObject.FindProperty( "handSettings" );
|
||||
unGrabLayer = serializedObject.FindProperty("unGrabLayer");
|
||||
grabLayer = serializedObject.FindProperty("grabLayer");
|
||||
|
||||
|
||||
targetScript = (VR_Lever) target;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
|
||||
PlatinioEditorGUILayout.PropertyField( grabDistance );
|
||||
PlatinioEditorGUILayout.PropertyField(usePerHandSettings);
|
||||
|
||||
if (usePerHandSettings.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField( rightHandSettings, true );
|
||||
EditorGUILayout.PropertyField( leftHandSettings, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField( handSettings, true );
|
||||
}
|
||||
|
||||
PlatinioEditorGUILayout.PropertyField( grabButton );
|
||||
PlatinioEditorGUILayout.PropertyField(transformBase);
|
||||
PlatinioEditorGUILayout.PropertyField(solverIterations);
|
||||
PlatinioEditorGUILayout.PropertyField(shouldBackToStartingPosition);
|
||||
PlatinioEditorGUILayout.PropertyField(backForce);
|
||||
|
||||
grabLayer.intValue = EditorGUILayout.LayerField( "Grab Layer", grabLayer.intValue );
|
||||
unGrabLayer.intValue = EditorGUILayout.LayerField( "UnGrab Layer", unGrabLayer.intValue );
|
||||
|
||||
PlatinioEditorGUILayout.PropertyField(onValueChange);
|
||||
PlatinioEditorGUILayout.PropertyField( onGrabStateChange );
|
||||
|
||||
|
||||
|
||||
//layer = EditorGUILayout.LayerField(layer);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void DrawHandSettings(SerializedProperty settings)
|
||||
{
|
||||
EditorGUILayout.PropertyField( settings, true );
|
||||
}
|
||||
|
||||
|
||||
public void OnSceneGUI()
|
||||
{
|
||||
if (targetScript == null)
|
||||
OnEnable();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
Handles.color = Color.blue;
|
||||
|
||||
|
||||
if (usePerHandSettings.boolValue)
|
||||
{
|
||||
float rightValue = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointRightHand == null ? targetScript.transform.position : targetScript.HighlightPointRightHand.position, grabDistance.floatValue );
|
||||
float leftValue = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointLeftHand == null ? targetScript.transform.position : targetScript.HighlightPointLeftHand.position, grabDistance.floatValue );
|
||||
|
||||
UpdateGrabDistanceValue( rightValue, leftValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (targetScript.HighlightPointHandSettings == null)
|
||||
return;
|
||||
|
||||
float value = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointHandSettings.position, grabDistance.floatValue );
|
||||
targetScript.SetInteractDistanceViaInspector( value );
|
||||
EditorUtility.SetDirty( targetScript );
|
||||
EditorSceneManager.MarkAllScenesDirty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void UpdateGrabDistanceValue(float rightValue, float leftValue)
|
||||
{
|
||||
if (grabDistance.floatValue != rightValue)
|
||||
{
|
||||
targetScript.SetInteractDistanceViaInspector( rightValue );
|
||||
EditorUtility.SetDirty( targetScript );
|
||||
EditorSceneManager.MarkAllScenesDirty();
|
||||
}
|
||||
else if (grabDistance.floatValue != leftValue)
|
||||
{
|
||||
targetScript.SetInteractDistanceViaInspector( leftValue );
|
||||
EditorUtility.SetDirty( targetScript );
|
||||
EditorSceneManager.MarkAllScenesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 077beb8dc16639a40beef61bb0855821
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Editor/I_VR_LeverInspector.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,221 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Platinio.SDK.EditorTools;
|
||||
|
||||
namespace VRSDK.EditorCode
|
||||
{
|
||||
[CustomEditor( typeof( VR_Manager ) )]
|
||||
public class I_VR_ManagerInspector : Editor
|
||||
{
|
||||
private SerializedProperty currentSDK = null;
|
||||
private SerializedProperty gestureConfig = null;
|
||||
|
||||
const string DEFINES_FILE_PATH = "Assets/mcs.rsp";
|
||||
const string STEAM_VR_DEFINITION = "SDK_STEAM_VR";
|
||||
const string OCULUS_VR_DEFINITION = "SDK_OCULUS";
|
||||
const string UNITY_XR_DEFINITION = "UNITY_XR";
|
||||
const string VR_MANAGER_FILE_PATH = "VRLAB/Scripts/VR/VR_Manager.cs";
|
||||
|
||||
private int startSDKIndex = 0;
|
||||
private static VR_Manager targetScript = null;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
currentSDK = serializedObject.FindProperty( "currentSDK" );
|
||||
gestureConfig = serializedObject.FindProperty( "gestureConfig" );
|
||||
|
||||
targetScript = target as VR_Manager;
|
||||
targetScript.SetCurrentSDKViaEditor( GetCurrentEnableSDK() );
|
||||
startSDKIndex = (int) targetScript.CurrentSDK;
|
||||
}
|
||||
|
||||
private VR_SDK GetCurrentEnableSDK()
|
||||
{
|
||||
List<string> defList = GlobalDefinitionsManager.GetCurrentDefinitios();
|
||||
|
||||
|
||||
for (int n = 0; n < defList.Count; n++)
|
||||
{
|
||||
string def = defList[n].Replace( " ", "" );
|
||||
|
||||
|
||||
if (def == STEAM_VR_DEFINITION)
|
||||
{
|
||||
return VR_SDK.Steam_VR;
|
||||
}
|
||||
else if (def == OCULUS_VR_DEFINITION)
|
||||
{
|
||||
return VR_SDK.Oculus;
|
||||
}
|
||||
else if (def == UNITY_XR_DEFINITION)
|
||||
{
|
||||
return VR_SDK.UnityXR;
|
||||
}
|
||||
}
|
||||
|
||||
return VR_SDK.None;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (currentSDK == null)
|
||||
return;
|
||||
|
||||
PlatinioEditorGUILayout.PropertyField( currentSDK );
|
||||
EditorGUILayout.PropertyField( gestureConfig , true );
|
||||
|
||||
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
|
||||
if ((int) targetScript.CurrentSDK != startSDKIndex)
|
||||
{
|
||||
if (GUILayout.Button( "Update SDK" ))
|
||||
{
|
||||
UpdateDefinitions(targetScript.CurrentSDK);
|
||||
}
|
||||
}
|
||||
|
||||
#if SDK_STEAM_VR
|
||||
|
||||
if (GUILayout.Button( "Create Input Bindings" ))
|
||||
{
|
||||
if (EditorUtility.DisplayDialog( "Create Input Bindings", "Are you sure you want to overwrite your current SteamVR Input Bindings", "Overwrite", "Cancel" ))
|
||||
{
|
||||
CreateSteamVRInputBindings();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
private void CreateSteamVRInputBindings()
|
||||
{
|
||||
Directory.CreateDirectory(Application.dataPath + "/StreamingAssets/SteamVR" );
|
||||
CopyFilesFromTo( Application.dataPath + "/VRShooterKit/SteamVR_Default_Input" , Application.dataPath + "/StreamingAssets/SteamVR" );
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
private void CopyFilesFromTo(string from , string to)
|
||||
{
|
||||
if (System.IO.Directory.Exists( from ))
|
||||
{
|
||||
string[] files = System.IO.Directory.GetFiles( from );
|
||||
|
||||
// Copy the files and overwrite destination files if they already exist.
|
||||
foreach (string s in files)
|
||||
{
|
||||
// Use static Path methods to extract only the file name from the path.
|
||||
string fileName = Path.GetFileName( s );
|
||||
string destFile = Path.Combine( to, fileName );
|
||||
File.Copy( s, destFile, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDefinitions(VR_SDK targetSDK)
|
||||
{
|
||||
targetScript.SetCurrentSDKViaEditor( targetSDK );
|
||||
startSDKIndex = (int) targetScript.CurrentSDK;
|
||||
|
||||
if (targetSDK == VR_SDK.None)
|
||||
{
|
||||
GlobalDefinitionsManager.RemoveDefinitions(OCULUS_VR_DEFINITION , STEAM_VR_DEFINITION , UNITY_XR_DEFINITION);
|
||||
OnUpdateDefinitions(targetSDK);
|
||||
return;
|
||||
}
|
||||
|
||||
string defString = GetDefString( targetSDK );
|
||||
|
||||
|
||||
if (GlobalDefinitionsManager.DefinitionExits( OCULUS_VR_DEFINITION ) || GlobalDefinitionsManager.DefinitionExits( STEAM_VR_DEFINITION ) || GlobalDefinitionsManager.DefinitionExits(UNITY_XR_DEFINITION))
|
||||
{
|
||||
List<string> defList = GlobalDefinitionsManager.GetCurrentDefinitios();
|
||||
|
||||
for (int n = 0; n < defList.Count; n++)
|
||||
{
|
||||
string def = defList[n].Replace( " ", "" );
|
||||
|
||||
//remove all sdk defines
|
||||
if (def == STEAM_VR_DEFINITION || def == OCULUS_VR_DEFINITION || def == UNITY_XR_DEFINITION)
|
||||
{
|
||||
defList.RemoveAt( n );
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
defList.Add( defString );
|
||||
GlobalDefinitionsManager.WriteDefinitions( defList );
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalDefinitionsManager.CreateAndWriteDefinition( defString );
|
||||
}
|
||||
|
||||
OnUpdateDefinitions( targetSDK );
|
||||
}
|
||||
|
||||
private string GetDefString(VR_SDK sdk)
|
||||
{
|
||||
if (sdk == VR_SDK.Oculus)
|
||||
{
|
||||
return OCULUS_VR_DEFINITION;
|
||||
}
|
||||
else if (sdk == VR_SDK.Steam_VR)
|
||||
{
|
||||
return STEAM_VR_DEFINITION;
|
||||
}
|
||||
else if (sdk == VR_SDK.UnityXR)
|
||||
{
|
||||
return UNITY_XR_DEFINITION;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void OnUpdateDefinitions(VR_SDK targetSDK)
|
||||
{
|
||||
ForceRebuild();
|
||||
AssetDatabase.Refresh();
|
||||
AssetDatabase.ImportAsset( VR_MANAGER_FILE_PATH, ImportAssetOptions.ForceUpdate );
|
||||
AssetDatabase.ImportAsset( DEFINES_FILE_PATH, ImportAssetOptions.ForceUpdate );
|
||||
targetScript.SetCurrentSDKViaEditor( targetSDK );
|
||||
}
|
||||
|
||||
|
||||
public static void ForceRebuild()
|
||||
{
|
||||
string[] rebuildSymbols = { "RebuildToggle1", "RebuildToggle2" };
|
||||
string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(
|
||||
EditorUserBuildSettings.selectedBuildTargetGroup );
|
||||
var definesStringTemp = definesString;
|
||||
if (definesStringTemp.Contains( rebuildSymbols[0] ))
|
||||
{
|
||||
definesStringTemp = definesStringTemp.Replace( rebuildSymbols[0], rebuildSymbols[1] );
|
||||
}
|
||||
else if (definesStringTemp.Contains( rebuildSymbols[1] ))
|
||||
{
|
||||
definesStringTemp = definesStringTemp.Replace( rebuildSymbols[1], rebuildSymbols[0] );
|
||||
}
|
||||
else
|
||||
{
|
||||
definesStringTemp += ";" + rebuildSymbols[0];
|
||||
}
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(
|
||||
EditorUserBuildSettings.selectedBuildTargetGroup,
|
||||
definesStringTemp );
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(
|
||||
EditorUserBuildSettings.selectedBuildTargetGroup,
|
||||
definesString );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f812e13ecf0972468b516b22cf65566
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Editor/I_VR_ManagerInspector.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,48 @@
|
||||
using Platinio.SDK.EditorTools;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace VRSDK.EditorCode
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(VR_Slider))]
|
||||
public class I_VR_SliderInspector : I_VR_GrabbableInspector
|
||||
{
|
||||
private SerializedProperty slideAxis = null;
|
||||
private SerializedProperty slideStartMarker = null;
|
||||
private SerializedProperty slideEndMarker = null;
|
||||
private SerializedProperty onValueChange = null;
|
||||
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
slideAxis = serializedObject.FindProperty("slideAxis");
|
||||
slideStartMarker = serializedObject.FindProperty("slideStartMarker");
|
||||
slideEndMarker = serializedObject.FindProperty("slideEndMarker");
|
||||
onValueChange = serializedObject.FindProperty("onValueChange");
|
||||
|
||||
base.OnEnable();
|
||||
}
|
||||
|
||||
|
||||
protected override void DrawOtherSettingsBody()
|
||||
{
|
||||
GUIContent content = new GUIContent("Slide Axis", "The axis use by this object in local space in order to slide");
|
||||
slideAxis.enumValueIndex = (int)(Axis)EditorGUILayout.EnumPopup(content, (Axis)slideAxis.enumValueIndex);
|
||||
|
||||
content = new GUIContent("Slider Start Marker", "");
|
||||
slideStartMarker.objectReferenceValue = EditorGUILayout.ObjectField(content, slideStartMarker.objectReferenceValue, typeof(Transform), true);
|
||||
|
||||
content = new GUIContent("Slider End Marker", "");
|
||||
slideEndMarker.objectReferenceValue = EditorGUILayout.ObjectField(content, slideEndMarker.objectReferenceValue, typeof(Transform), true);
|
||||
|
||||
|
||||
PlatinioEditorGUILayout.PropertyField(onValueChange);
|
||||
|
||||
base.DrawOtherSettingsBody();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a197059cd5ced63438ddf98eeffbf8cb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Editor/I_VR_SliderInspector.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,243 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace VRSDK.EditorCode
|
||||
{
|
||||
//this script os a little especial and usefull can help you create dinamyc Enum using scriptable objects
|
||||
//it creates a small script containing the VR_Tag enum that gest update every time the scritable object changes
|
||||
//this VR_Tag is curretly in use in the DropZone, so it can know what objects can be dropped
|
||||
|
||||
[CustomEditor( typeof( VR_TagsManager ) )]
|
||||
public class I_VR_TagsManager : Editor
|
||||
{
|
||||
private VR_TagsManager targetScript = null;
|
||||
private string[] previusTagList = null;
|
||||
|
||||
private const string FileName = "VR_TagEnum";
|
||||
private const string FileExtension = ".cs";
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
targetScript = (VR_TagsManager) target;
|
||||
|
||||
previusTagList = new string[targetScript.TagList.Count];
|
||||
targetScript.TagList.CopyTo( previusTagList );
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
|
||||
if (targetScript.TagList == null)
|
||||
targetScript.TagList = new List<string>();
|
||||
|
||||
EditorGUILayout.LabelField( "Tags", EditorStyles.boldLabel );
|
||||
|
||||
for (int n = 0; n < targetScript.TagList.Count; n++)
|
||||
{
|
||||
targetScript.TagList[n] = EditorGUILayout.TextArea( targetScript.TagList[n] );
|
||||
|
||||
if (GUILayout.Button( "-", GUILayout.Width( 20 ) ))
|
||||
targetScript.TagList.RemoveAt( n );
|
||||
}
|
||||
|
||||
if (GUILayout.Button( "+", GUILayout.Width( 20 ) ))
|
||||
targetScript.TagList.Add( "" );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find a path for our enum holder script
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string GetPath()
|
||||
{
|
||||
//find is there is a file with the same name already
|
||||
string[] files = Directory.GetFiles( Application.dataPath, "*" + FileExtension, SearchOption.AllDirectories );
|
||||
|
||||
for (int n = 0; n < files.Length; n++)
|
||||
{
|
||||
|
||||
//there is already a script with that name lest replace it
|
||||
if (files[n].Contains( FileName ))
|
||||
{
|
||||
//we need to use paths relative to the assets folder
|
||||
string globalPath = files[n].Replace( '\\', '/' );
|
||||
int startIndex = globalPath.IndexOf( "Assets", 0 );
|
||||
string relativePath = globalPath.Substring( startIndex, globalPath.Length - ( startIndex ) );
|
||||
|
||||
return relativePath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//find the VRShooterKit folder
|
||||
string[] directoryArray = Directory.GetDirectories( Application.dataPath );
|
||||
|
||||
for (int n = 0; n < directoryArray.Length; n++)
|
||||
{
|
||||
if (directoryArray[n].Contains( "VRShooterKit" ))
|
||||
{
|
||||
string path = directoryArray[n];
|
||||
|
||||
path = path.Replace( '\\', '/' );
|
||||
|
||||
return path + "/" + FileName + FileExtension;
|
||||
}
|
||||
}
|
||||
|
||||
//create the VRShooterKit folder
|
||||
return Application.dataPath + "/VRShooterKit/" + FileName + FileExtension;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// update the enum script
|
||||
/// </summary>
|
||||
private void UpdateEnumScript()
|
||||
{
|
||||
|
||||
string script = "namespace VRShooterKit" +
|
||||
"{ " +
|
||||
"public enum VR_TagsEnum" +
|
||||
"{";
|
||||
|
||||
if (targetScript.TagList.Count > 0)
|
||||
{
|
||||
for (int n = 0; n < targetScript.TagList.Count; n++)
|
||||
{
|
||||
script += targetScript.TagList[n];
|
||||
|
||||
if (n != targetScript.TagList.Count - 1)
|
||||
script += ",";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
script += "Empty";
|
||||
}
|
||||
|
||||
|
||||
script += "}";
|
||||
script += "}";
|
||||
|
||||
string path = GetPath();
|
||||
|
||||
File.WriteAllText( path, script );
|
||||
|
||||
//rebuild
|
||||
AssetDatabase.Refresh();
|
||||
AssetDatabase.ImportAsset( path, ImportAssetOptions.ForceUpdate );
|
||||
|
||||
//save
|
||||
EditorUtility.SetDirty( targetScript );
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the content of the list is valid?
|
||||
/// </summary>
|
||||
private bool IsValid()
|
||||
{
|
||||
for (int n = 0; n < targetScript.TagList.Count; n++)
|
||||
{
|
||||
//find empty
|
||||
if (targetScript.TagList[n].Length == 0)
|
||||
{
|
||||
Debug.LogWarning( "TagManager found empty Tag reverting changes!" );
|
||||
return false;
|
||||
}
|
||||
|
||||
//the tag start with a number
|
||||
if (char.IsDigit( targetScript.TagList[n][0] ))
|
||||
{
|
||||
Debug.LogWarning( "TagManager found invalid Tag name reverting changes!" );
|
||||
return false;
|
||||
}
|
||||
|
||||
//find invalid characters
|
||||
for (int j = 0; j < targetScript.TagList[n].Length; j++)
|
||||
{
|
||||
|
||||
if (!IsCharValid(targetScript.TagList[n][j]))
|
||||
{
|
||||
Debug.LogWarning( "TagManager found invalid Tag name reverting changes!" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<string> duplicateList = targetScript.TagList.GroupBy( x => x )
|
||||
.Where( group => group.Count() > 1 )
|
||||
.Select( group => group.Key ).ToList();
|
||||
|
||||
if (duplicateList.Count > 0)
|
||||
{
|
||||
Debug.LogWarning( "TagManager found repeat Tag reverting changes!" );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool IsCharValid(char c)
|
||||
{
|
||||
c = char.ToLower(c);
|
||||
return char.IsDigit(c) || (c >= 'a' && c <= 'z' ) || c == '_';
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove white spaces from all names
|
||||
/// </summary>
|
||||
private void RemoveWhiteSpaces()
|
||||
{
|
||||
for (int n = 0; n < targetScript.TagList.Count; n++)
|
||||
{
|
||||
targetScript.TagList[n] = targetScript.TagList[n].Replace( " ", string.Empty );
|
||||
}
|
||||
}
|
||||
|
||||
private void RevertChanges()
|
||||
{
|
||||
targetScript.TagList = previusTagList.ToList();
|
||||
}
|
||||
|
||||
private bool NeedRebuild()
|
||||
{
|
||||
|
||||
if (previusTagList.Length != targetScript.TagList.Count)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int n = 0; n < targetScript.TagList.Count; n++)
|
||||
{
|
||||
if (previusTagList[n] != targetScript.TagList[n])
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public void OnDestroy()
|
||||
{
|
||||
//remove white spaces
|
||||
RemoveWhiteSpaces();
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
RevertChanges();
|
||||
return;
|
||||
}
|
||||
|
||||
if (NeedRebuild())
|
||||
{
|
||||
UpdateEnumScript();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12be308ec92d1de4783a5a833257d161
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Editor/I_VR_TagsManager.cs
|
||||
uploadId: 546658
|
||||
Reference in New Issue
Block a user