Replace UltimateXR with HurricaneVR
This commit is contained in:
55
Assets/HurricaneVR/Framework/Editor/HVRGunPartEditor.cs
Normal file
55
Assets/HurricaneVR/Framework/Editor/HVRGunPartEditor.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using HurricaneVR.Framework.Weapons;
|
||||
using HurricaneVR.Framework.Weapons.Guns;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HurricaneVR.Editor
|
||||
{
|
||||
[CustomEditor(typeof(HVRGunPart), true)]
|
||||
public class HVRGunPartEditor : UnityEditor.Editor
|
||||
{
|
||||
private SerializedProperty ForwardPosition;
|
||||
private SerializedProperty BackwardPosition;
|
||||
public HVRGunPart component;
|
||||
|
||||
protected void OnEnable()
|
||||
{
|
||||
ForwardPosition = serializedObject.FindProperty("ForwardPosition");
|
||||
BackwardPosition = serializedObject.FindProperty("BackwardPosition");
|
||||
component = target as HVRGunPart;
|
||||
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawButtons("Forward", ForwardPosition);
|
||||
DrawButtons("Backward", BackwardPosition);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
base.OnInspectorGUI();
|
||||
}
|
||||
|
||||
private void DrawButtons(string label, SerializedProperty property)
|
||||
{
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button($"Save {label}"))
|
||||
{
|
||||
property.vector3Value = component.transform.localPosition;
|
||||
}
|
||||
|
||||
|
||||
if (GUILayout.Button($"GoTo {label}"))
|
||||
{
|
||||
Undo.RecordObject(component.transform, $"Goto {label}");
|
||||
component.transform.localPosition = property.vector3Value;
|
||||
}
|
||||
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user