Last active
April 25, 2023 07:45
Revisions
-
ProGM revised this gist
Dec 7, 2016 . No changes.There are no files selected for viewing
-
ProGM revised this gist
Oct 19, 2016 . No changes.There are no files selected for viewing
-
ProGM revised this gist
Oct 18, 2016 . 1 changed file with 25 additions and 13 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,18 +10,30 @@ public class DraggablePoint : PropertyAttribute {} #if UNITY_EDITOR [CustomEditor(typeof(MonoBehaviour), true)] public class DraggablePointDrawer : Editor { readonly GUIStyle style = new GUIStyle(); void OnEnable(){ style.fontStyle = FontStyle.Bold; style.normal.textColor = Color.white; } public void OnSceneGUI () { var property = serializedObject.GetIterator (); while (property.Next (true)) { if (property.propertyType == SerializedPropertyType.Vector3) { var field = serializedObject.targetObject.GetType ().GetField (property.name); if (field == null) { continue; } var draggablePoints = field.GetCustomAttributes (typeof(DraggablePoint), false); if (draggablePoints.Length > 0) { Handles.Label(property.vector3Value, property.name); property.vector3Value = Handles.PositionHandle (property.vector3Value, Quaternion.identity); serializedObject.ApplyModifiedProperties (); } } } } } #endif -
ProGM revised this gist
Oct 9, 2016 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,8 +2,7 @@ using System.Collections; public class ExampleBehavior : MonoBehaviour { [DraggablePoint] public Vector3 SpawnPosition; public GameObject SpawnableObject; public void Spawn() { -
ProGM created this gist
Oct 9, 2016 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ using System; using UnityEngine; #if UNITY_EDITOR using UnityEditor; #endif public class DraggablePoint : PropertyAttribute {} #if UNITY_EDITOR [CustomEditor(typeof(MonoBehaviour), true)] public class DraggablePointDrawer : Editor { public void OnSceneGUI () { var property = serializedObject.GetIterator (); while (property.Next (true)) { if (property.propertyType == SerializedPropertyType.Vector3) { var draggablePoints = serializedObject.targetObject.GetType ().GetField (property.name).GetCustomAttributes (typeof(DraggablePoint), false); if (draggablePoints.Length > 0) { Handles.Label(property.vector3Value, property.name); property.vector3Value = Handles.PositionHandle (property.vector3Value, Quaternion.identity); serializedObject.ApplyModifiedProperties (); } } } } } #endif This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ using UnityEngine; using System.Collections; public class ExampleBehavior : MonoBehaviour { [DraggablePoint] public Vector3 SpawnPosition; public GameObject SpawnableObject; public void Spawn() { Instantiate(SpawnableObject, SpawnPosition, Quaternion.identity); } }