void OnEnable() { cTarg = target as HotspotPositionCalc; dist = cTarg.distance; p = cTarg.pitch; y = cTarg.yaw; }
void OnEnable() { instance = this; mTarget = target as HotspotButtonGaze; posCalc = mTarget.GetComponent <HotspotPositionCalc>(); posCalcSO = new SerializedObject(posCalc); }
void Position() { if (GUILayout.Button("Position" + (posOpen ? "" : " (click to expand)"), EditorStyles.boldLabel)) { posOpen = !posOpen; } if (!posOpen) { return; } EditorGUI.BeginChangeCheck(); if (posCalcSO == null) { posCalc = mTarget.GetComponent <HotspotPositionCalc>(); posCalcSO = new SerializedObject(posCalc); } posCalcSO.Update(); posCalc.Apply(); SerializedProperty distance = posCalcSO.FindProperty("distance"); SerializedProperty pitch = posCalcSO.FindProperty("pitch"); SerializedProperty yaw = posCalcSO.FindProperty("yaw"); EditorGUI.indentLevel++; GUILayout.BeginHorizontal(); GUILayout.Label("Distance: ", GUILayout.Width(65)); distance.floatValue = GUILayout.HorizontalSlider(distance.floatValue, 1, 500); GUILayout.Label(distance.floatValue.ToString("F1"), GUILayout.Width(40)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Pitch: ", GUILayout.Width(65)); pitch.floatValue = GUILayout.HorizontalSlider(pitch.floatValue, 0, 180); GUILayout.Label(pitch.floatValue.ToString("F1"), GUILayout.Width(40)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Yaw: ", GUILayout.Width(65)); yaw.floatValue = GUILayout.HorizontalSlider(yaw.floatValue, -180, 180); GUILayout.Label(yaw.floatValue.ToString("F1"), GUILayout.Width(40)); GUILayout.EndHorizontal(); EditorGUI.indentLevel--; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(posCalcSO.targetObject, "Hotspot Position"); posCalcSO.ApplyModifiedProperties(); Repaint(); } }
void UpdateSelection() { if (Selection.activeGameObject != null) { HotspotPositionCalc hpc = Selection.activeGameObject.GetComponent <HotspotPositionCalc>(); if (hpc) { cam.transform.LookAt(hpc.transform.position); } } }