diff --git a/unity/Assets/Editor.meta b/unity/Assets/Editor.meta deleted file mode 100644 index 25d459411..000000000 --- a/unity/Assets/Editor.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: cd3b771e2f9df4f6bb8d4b3e01545173 -folderAsset: yes -timeCreated: 1444335271 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/unity/Assets/Editor/Editor.asmdef b/unity/Assets/Editor/Editor.asmdef deleted file mode 100644 index a77d2942c..000000000 --- a/unity/Assets/Editor/Editor.asmdef +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "Editor", - "rootNamespace": "", - "references": [ - "GUID:20a3f6c7643c02b4f91ee2b86822b6a7", - "GUID:c4aed1b7b59d62c48ab35dda9c36ff44", - "GUID:f3ea3a281defb5d4fa9983d10a689570", - "GUID:69316dfcff46f124e8f6f838a57ff6c2" - ], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/unity/Assets/Editor/Editor.asmdef.meta b/unity/Assets/Editor/Editor.asmdef.meta deleted file mode 100644 index a2605d773..000000000 --- a/unity/Assets/Editor/Editor.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: d8a9a489052b30b429ac4f89ce4310f7 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/unity/Assets/Editor/ButtonAction.cs b/unity/Assets/Maroon/Editor/ButtonAction.cs similarity index 96% rename from unity/Assets/Editor/ButtonAction.cs rename to unity/Assets/Maroon/Editor/ButtonAction.cs index dc8f0fea3..45b35e164 100644 --- a/unity/Assets/Editor/ButtonAction.cs +++ b/unity/Assets/Maroon/Editor/ButtonAction.cs @@ -1,34 +1,34 @@ -using UnityEngine; - -[System.Serializable] -public class ButtonAction -{ - // public settings - public Object target; - public string method; - - // inspactor cache - public string[] candidates = { }; - public int index; - - // invocation - public System.Action action; - - public void Awake() - { - action = System.Action.CreateDelegate(typeof(System.Action), target, target.GetType().GetMethod(method)) as System.Action; - } -} - -public class ButtonActionAttribute : PropertyAttribute -{ - public System.Type returnType; - public System.Type[] paramTypes; - public ButtonActionAttribute(System.Type returnType = null, params System.Type[] paramTypes) - { - this.returnType = returnType != null ? returnType : typeof(void); - this.paramTypes = paramTypes != null ? paramTypes : new System.Type[0]; - } - - public System.Delegate method; -} +using UnityEngine; + +[System.Serializable] +public class ButtonAction +{ + // public settings + public Object target; + public string method; + + // inspactor cache + public string[] candidates = { }; + public int index; + + // invocation + public System.Action action; + + public void Awake() + { + action = System.Action.CreateDelegate(typeof(System.Action), target, target.GetType().GetMethod(method)) as System.Action; + } +} + +public class ButtonActionAttribute : PropertyAttribute +{ + public System.Type returnType; + public System.Type[] paramTypes; + public ButtonActionAttribute(System.Type returnType = null, params System.Type[] paramTypes) + { + this.returnType = returnType != null ? returnType : typeof(void); + this.paramTypes = paramTypes != null ? paramTypes : new System.Type[0]; + } + + public System.Delegate method; +} diff --git a/unity/Assets/Editor/ButtonAction.cs.meta b/unity/Assets/Maroon/Editor/ButtonAction.cs.meta similarity index 95% rename from unity/Assets/Editor/ButtonAction.cs.meta rename to unity/Assets/Maroon/Editor/ButtonAction.cs.meta index 5a2ae8ee7..6543067f1 100644 --- a/unity/Assets/Editor/ButtonAction.cs.meta +++ b/unity/Assets/Maroon/Editor/ButtonAction.cs.meta @@ -1,12 +1,12 @@ -fileFormatVersion: 2 -guid: ef58c618285d1774fb4133911861a286 -timeCreated: 1491905839 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: ef58c618285d1774fb4133911861a286 +timeCreated: 1491905839 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/unity/Assets/Editor/ButtonActionDrawer.cs b/unity/Assets/Maroon/Editor/ButtonActionDrawer.cs similarity index 97% rename from unity/Assets/Editor/ButtonActionDrawer.cs rename to unity/Assets/Maroon/Editor/ButtonActionDrawer.cs index 090701350..fd47f1ec7 100644 --- a/unity/Assets/Editor/ButtonActionDrawer.cs +++ b/unity/Assets/Maroon/Editor/ButtonActionDrawer.cs @@ -1,158 +1,158 @@ -using UnityEngine; -using UnityEditor; -using System.Reflection; -using System.Collections.Generic; - -public class ButtonActionDrawer : PropertyDrawer -{ - const float rows = 3; - - public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) - { - SerializedProperty targetProperty = property.FindPropertyRelative("target"); - SerializedProperty methodNameProperty = property.FindPropertyRelative("method"); - SerializedProperty candidateNamesProperty = property.FindPropertyRelative("candidates"); - SerializedProperty indexProperty = property.FindPropertyRelative("index"); - - // pass through label - EditorGUIUtility.LookLikeControls(); - EditorGUI.LabelField(new Rect(position.x, position.y, position.width / 2, position.height / rows), label); - - // target + method section - EditorGUI.indentLevel++; - EditorGUI.BeginChangeCheck(); - - // slect target - EditorGUI.PropertyField( - new Rect(position.x, position.y += position.height/rows, position.width, position.height/ rows), - targetProperty - ); - - if (targetProperty.objectReferenceValue == null) - return; // null objects have no methods - don't continue - - // populate method condidate names - string[] methodCandidateNames; - if (EditorGUI.EndChangeCheck()) - { - methodCandidateNames = RepopulateCandidateList(targetProperty, candidateNamesProperty, indexProperty); - } - else - { - methodCandidateNames = new string[candidateNamesProperty.arraySize]; - int i = 0; - foreach (SerializedProperty element in candidateNamesProperty) - { - methodCandidateNames[i++] = element.stringValue; - } - } - - // place holder when no candidates are available - if(methodCandidateNames.Length == 0) - { - EditorGUI.LabelField( - new Rect(position.x, position.y += position.height/rows, position.width, position.height/rows), - "Method", - "none" - ); - return; // no names no games - } - - // select method from candidates - indexProperty.intValue = EditorGUI.Popup( - new Rect(position.x, position.y += position.height / rows, position.width, position.height / rows), - "Method (" + targetProperty.objectReferenceValue.GetType().ToString() + ")", - indexProperty.intValue, - methodCandidateNames - ); - - methodNameProperty.stringValue = methodCandidateNames[indexProperty.intValue]; - EditorGUI.indentLevel--; - } - - public string[] RepopulateCandidateList( - SerializedProperty targetProperty, - SerializedProperty candidateNamesProperty, - SerializedProperty indexProperty - ) - { - System.Type type = targetProperty.objectReferenceValue.GetType(); - System.Type[] paramTypes = this.paramTypes; - IList candidateList = new List(); - string[] candidateNames; - int i = 0; - - Debug.Log("Candidate Criteria:"); - Debug.Log("\treturn type:" + returnType.ToString()); - Debug.Log("\tparam count:" + paramTypes.Length); - foreach (System.Type paramType in paramTypes) - Debug.Log("\t\t" + paramType.ToString()); - - type.FindMembers( - MemberTypes.Method, - BindingFlags.Instance | BindingFlags.Public, - (member, criteria) => - { - Debug.Log("matching " + member.Name); - MethodInfo method; - if ((method = type.GetMethod(member.Name, paramTypes)) != null && method.ReturnType == returnType) - { - candidateList.Add(method); - return true; - } - return false; - }, - null - ); - - // clear/resize/initalize storage containers - candidateNamesProperty.ClearArray(); - candidateNamesProperty.arraySize = candidateList.Count; - candidateNames = new string[candidateList.Count]; - - // assign storage containers - i = 0; - foreach(SerializedProperty element in candidateNamesProperty) - { - element.stringValue = candidateNames[i] = candidateList[i++].Name; - } - - // reset popup index - indexProperty.intValue = 0; - - return candidateNames; - } - - public System.Type returnType - { - get - { - return attribute != null ? (attribute as ButtonActionAttribute).returnType : typeof(void); - } - } - - public System.Type[] paramTypes - { - get - { - return (attribute != null && (attribute as ButtonActionAttribute).paramTypes != null) ? (attribute as ButtonActionAttribute).paramTypes : new System.Type[0]; - } - } - - public System.Delegate method - { - get - { - return attribute != null ? (attribute as ButtonActionAttribute).method : null; - } - set - { - (attribute as ButtonActionAttribute).method = value; - } - } - - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - return base.GetPropertyHeight(property, label) * rows; - } -} +using UnityEngine; +using UnityEditor; +using System.Reflection; +using System.Collections.Generic; + +public class ButtonActionDrawer : PropertyDrawer +{ + const float rows = 3; + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + SerializedProperty targetProperty = property.FindPropertyRelative("target"); + SerializedProperty methodNameProperty = property.FindPropertyRelative("method"); + SerializedProperty candidateNamesProperty = property.FindPropertyRelative("candidates"); + SerializedProperty indexProperty = property.FindPropertyRelative("index"); + + // pass through label + EditorGUIUtility.LookLikeControls(); + EditorGUI.LabelField(new Rect(position.x, position.y, position.width / 2, position.height / rows), label); + + // target + method section + EditorGUI.indentLevel++; + EditorGUI.BeginChangeCheck(); + + // slect target + EditorGUI.PropertyField( + new Rect(position.x, position.y += position.height/rows, position.width, position.height/ rows), + targetProperty + ); + + if (targetProperty.objectReferenceValue == null) + return; // null objects have no methods - don't continue + + // populate method condidate names + string[] methodCandidateNames; + if (EditorGUI.EndChangeCheck()) + { + methodCandidateNames = RepopulateCandidateList(targetProperty, candidateNamesProperty, indexProperty); + } + else + { + methodCandidateNames = new string[candidateNamesProperty.arraySize]; + int i = 0; + foreach (SerializedProperty element in candidateNamesProperty) + { + methodCandidateNames[i++] = element.stringValue; + } + } + + // place holder when no candidates are available + if(methodCandidateNames.Length == 0) + { + EditorGUI.LabelField( + new Rect(position.x, position.y += position.height/rows, position.width, position.height/rows), + "Method", + "none" + ); + return; // no names no games + } + + // select method from candidates + indexProperty.intValue = EditorGUI.Popup( + new Rect(position.x, position.y += position.height / rows, position.width, position.height / rows), + "Method (" + targetProperty.objectReferenceValue.GetType().ToString() + ")", + indexProperty.intValue, + methodCandidateNames + ); + + methodNameProperty.stringValue = methodCandidateNames[indexProperty.intValue]; + EditorGUI.indentLevel--; + } + + public string[] RepopulateCandidateList( + SerializedProperty targetProperty, + SerializedProperty candidateNamesProperty, + SerializedProperty indexProperty + ) + { + System.Type type = targetProperty.objectReferenceValue.GetType(); + System.Type[] paramTypes = this.paramTypes; + IList candidateList = new List(); + string[] candidateNames; + int i = 0; + + Debug.Log("Candidate Criteria:"); + Debug.Log("\treturn type:" + returnType.ToString()); + Debug.Log("\tparam count:" + paramTypes.Length); + foreach (System.Type paramType in paramTypes) + Debug.Log("\t\t" + paramType.ToString()); + + type.FindMembers( + MemberTypes.Method, + BindingFlags.Instance | BindingFlags.Public, + (member, criteria) => + { + Debug.Log("matching " + member.Name); + MethodInfo method; + if ((method = type.GetMethod(member.Name, paramTypes)) != null && method.ReturnType == returnType) + { + candidateList.Add(method); + return true; + } + return false; + }, + null + ); + + // clear/resize/initalize storage containers + candidateNamesProperty.ClearArray(); + candidateNamesProperty.arraySize = candidateList.Count; + candidateNames = new string[candidateList.Count]; + + // assign storage containers + i = 0; + foreach(SerializedProperty element in candidateNamesProperty) + { + element.stringValue = candidateNames[i] = candidateList[i++].Name; + } + + // reset popup index + indexProperty.intValue = 0; + + return candidateNames; + } + + public System.Type returnType + { + get + { + return attribute != null ? (attribute as ButtonActionAttribute).returnType : typeof(void); + } + } + + public System.Type[] paramTypes + { + get + { + return (attribute != null && (attribute as ButtonActionAttribute).paramTypes != null) ? (attribute as ButtonActionAttribute).paramTypes : new System.Type[0]; + } + } + + public System.Delegate method + { + get + { + return attribute != null ? (attribute as ButtonActionAttribute).method : null; + } + set + { + (attribute as ButtonActionAttribute).method = value; + } + } + + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + return base.GetPropertyHeight(property, label) * rows; + } +} diff --git a/unity/Assets/Editor/ButtonActionDrawer.cs.meta b/unity/Assets/Maroon/Editor/ButtonActionDrawer.cs.meta similarity index 95% rename from unity/Assets/Editor/ButtonActionDrawer.cs.meta rename to unity/Assets/Maroon/Editor/ButtonActionDrawer.cs.meta index 324a325c5..18885c22e 100644 --- a/unity/Assets/Editor/ButtonActionDrawer.cs.meta +++ b/unity/Assets/Maroon/Editor/ButtonActionDrawer.cs.meta @@ -1,12 +1,12 @@ -fileFormatVersion: 2 -guid: 5c60ca78e66be9d4fbb77b5b5603bd0f -timeCreated: 1491905997 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 5c60ca78e66be9d4fbb77b5b5603bd0f +timeCreated: 1491905997 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/unity/Assets/Editor/ChainEditor.cs b/unity/Assets/Maroon/Editor/ChainEditor.cs similarity index 97% rename from unity/Assets/Editor/ChainEditor.cs rename to unity/Assets/Maroon/Editor/ChainEditor.cs index 3084a0e81..bfca543ca 100644 --- a/unity/Assets/Editor/ChainEditor.cs +++ b/unity/Assets/Maroon/Editor/ChainEditor.cs @@ -1,108 +1,108 @@ -using UnityEditor; - -[CustomEditor(typeof(Chain))] -public class ChainEditor : Editor -{ - private Chain chain; - - private SerializedProperty chainAxis; - - // Link Properties - private SerializedProperty linkScale; - private SerializedProperty linkOffset; - private SerializedProperty linkCount; - private SerializedProperty customLinkObject; - - // Joint Properties - private SerializedProperty jointAxis; - private SerializedProperty jointSwingAxis; - private SerializedProperty jointSwingLimit; - - private void Awake() - { - chain = (Chain)target; - } - - private void OnEnable() - { - chainAxis = serializedObject.FindProperty("chainAxis"); - - // Find Link Proberties - linkScale = serializedObject.FindProperty("linkScale"); - linkOffset = serializedObject.FindProperty("linkOffset"); - linkCount = serializedObject.FindProperty("linkCount"); - customLinkObject = serializedObject.FindProperty("customLinkObject"); - - // Find Joint Proberties - jointAxis = serializedObject.FindProperty("jointAxis"); - jointSwingAxis = serializedObject.FindProperty("jointSwingAxis"); - jointSwingLimit = serializedObject.FindProperty("jointSwingLimit"); - } - - public override void OnInspectorGUI() - { - serializedObject.Update(); - - //-------------------------------------------------------------------------- - // Check if Chain Axis has changed - //-------------------------------------------------------------------------- - EditorGUI.BeginChangeCheck(); - - EditorGUILayout.PropertyField(chainAxis); - - //serializedObject.ApplyModifiedProperties(); - //if (EditorGUI.EndChangeCheck()) - // Debug.Log("Chain Axis changed"); - - //-------------------------------------------------------------------------- - EditorGUILayout.Space(); - - //-------------------------------------------------------------------------- - // Check if Link Settings has changed - //-------------------------------------------------------------------------- - EditorGUILayout.LabelField("Link settings", EditorStyles.boldLabel); - - //EditorGUI.BeginChangeCheck(); - EditorGUILayout.PropertyField(linkScale); - EditorGUILayout.PropertyField(linkOffset); - serializedObject.ApplyModifiedProperties(); - if (EditorGUI.EndChangeCheck()) - chain.UpdateSettings(); - - EditorGUI.BeginChangeCheck(); - EditorGUILayout.PropertyField(linkCount); - if (linkCount.intValue < 0) - linkCount.intValue = 0; - serializedObject.ApplyModifiedProperties(); - if (EditorGUI.EndChangeCheck()) - chain.UpdateNumberOfLinks(); - - EditorGUI.BeginChangeCheck(); - EditorGUILayout.PropertyField(customLinkObject); - serializedObject.ApplyModifiedProperties(); - if (EditorGUI.EndChangeCheck()) - chain.UpdateCustomLinkObjects(); - - //-------------------------------------------------------------------------- - - EditorGUILayout.Space(); - - //-------------------------------------------------------------------------- - // Check if Joint Settings has changed - //-------------------------------------------------------------------------- - EditorGUILayout.LabelField("Joint settings", EditorStyles.boldLabel); - - EditorGUI.BeginChangeCheck(); - - EditorGUILayout.PropertyField(jointAxis); - EditorGUILayout.PropertyField(jointSwingAxis); - EditorGUILayout.PropertyField(jointSwingLimit); - - serializedObject.ApplyModifiedProperties(); - if (EditorGUI.EndChangeCheck()) - chain.UpdateSettings(); - - //-------------------------------------------------------------------------- - - } -} +using UnityEditor; + +[CustomEditor(typeof(Chain))] +public class ChainEditor : Editor +{ + private Chain chain; + + private SerializedProperty chainAxis; + + // Link Properties + private SerializedProperty linkScale; + private SerializedProperty linkOffset; + private SerializedProperty linkCount; + private SerializedProperty customLinkObject; + + // Joint Properties + private SerializedProperty jointAxis; + private SerializedProperty jointSwingAxis; + private SerializedProperty jointSwingLimit; + + private void Awake() + { + chain = (Chain)target; + } + + private void OnEnable() + { + chainAxis = serializedObject.FindProperty("chainAxis"); + + // Find Link Proberties + linkScale = serializedObject.FindProperty("linkScale"); + linkOffset = serializedObject.FindProperty("linkOffset"); + linkCount = serializedObject.FindProperty("linkCount"); + customLinkObject = serializedObject.FindProperty("customLinkObject"); + + // Find Joint Proberties + jointAxis = serializedObject.FindProperty("jointAxis"); + jointSwingAxis = serializedObject.FindProperty("jointSwingAxis"); + jointSwingLimit = serializedObject.FindProperty("jointSwingLimit"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + //-------------------------------------------------------------------------- + // Check if Chain Axis has changed + //-------------------------------------------------------------------------- + EditorGUI.BeginChangeCheck(); + + EditorGUILayout.PropertyField(chainAxis); + + //serializedObject.ApplyModifiedProperties(); + //if (EditorGUI.EndChangeCheck()) + // Debug.Log("Chain Axis changed"); + + //-------------------------------------------------------------------------- + EditorGUILayout.Space(); + + //-------------------------------------------------------------------------- + // Check if Link Settings has changed + //-------------------------------------------------------------------------- + EditorGUILayout.LabelField("Link settings", EditorStyles.boldLabel); + + //EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(linkScale); + EditorGUILayout.PropertyField(linkOffset); + serializedObject.ApplyModifiedProperties(); + if (EditorGUI.EndChangeCheck()) + chain.UpdateSettings(); + + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(linkCount); + if (linkCount.intValue < 0) + linkCount.intValue = 0; + serializedObject.ApplyModifiedProperties(); + if (EditorGUI.EndChangeCheck()) + chain.UpdateNumberOfLinks(); + + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(customLinkObject); + serializedObject.ApplyModifiedProperties(); + if (EditorGUI.EndChangeCheck()) + chain.UpdateCustomLinkObjects(); + + //-------------------------------------------------------------------------- + + EditorGUILayout.Space(); + + //-------------------------------------------------------------------------- + // Check if Joint Settings has changed + //-------------------------------------------------------------------------- + EditorGUILayout.LabelField("Joint settings", EditorStyles.boldLabel); + + EditorGUI.BeginChangeCheck(); + + EditorGUILayout.PropertyField(jointAxis); + EditorGUILayout.PropertyField(jointSwingAxis); + EditorGUILayout.PropertyField(jointSwingLimit); + + serializedObject.ApplyModifiedProperties(); + if (EditorGUI.EndChangeCheck()) + chain.UpdateSettings(); + + //-------------------------------------------------------------------------- + + } +} diff --git a/unity/Assets/Editor/ChainEditor.cs.meta b/unity/Assets/Maroon/Editor/ChainEditor.cs.meta similarity index 100% rename from unity/Assets/Editor/ChainEditor.cs.meta rename to unity/Assets/Maroon/Editor/ChainEditor.cs.meta diff --git a/unity/Assets/Editor/DynamicSceneGenerator.cs b/unity/Assets/Maroon/Editor/DynamicSceneGenerator.cs similarity index 96% rename from unity/Assets/Editor/DynamicSceneGenerator.cs rename to unity/Assets/Maroon/Editor/DynamicSceneGenerator.cs index 43c9bdbed..2fac01fbc 100644 --- a/unity/Assets/Editor/DynamicSceneGenerator.cs +++ b/unity/Assets/Maroon/Editor/DynamicSceneGenerator.cs @@ -1,87 +1,87 @@ -using UnityEngine; -using UnityEditor; - -public class DynamicSceneGenerator : EditorWindow -{ - string myString = "Hello World"; - bool groupEnabled; - bool myBool = true; - float myFloat = 1.23f; - - private int tab = 0; - private string[] tabStrings = { "Build Scene", "Parameters", "Quiz" }; - - // Add menu named "Dynamic Scene Generator" to the Window menu - [MenuItem("Window/Dynamic Scene Generator")] - static void Init() - { - // Get existing open window or if none, make a new one: - DynamicSceneGenerator window = (DynamicSceneGenerator)EditorWindow.GetWindow(typeof(DynamicSceneGenerator), false, "Dynamic Scene Generator"); - window.Show(); - } - - private void OnGUI() - { - tab = GUILayout.Toolbar(tab, tabStrings); - switch(tab) - { - case 0: - showBuildSceneTab(); - break; - case 1: - showParameterTab(); - break; - case 2: - showQuizTab(); - break; - default: - Debug.LogError("DynamicSceneGenerator: Unknown Tab Index."); - break; - } - } - - private void showBuildSceneTab() - { - EditorGUILayout.BeginVertical(); - { - GUILayout.Label("Base Settings", EditorStyles.boldLabel); - myString = EditorGUILayout.TextField("Text Field", myString); - - GUILayout.FlexibleSpace(); - - EditorGUILayout.BeginHorizontal(); - { - GUILayout.FlexibleSpace(); - - if (GUILayout.Button("Build Web View Scene ...")) - { - - } - - EditorGUILayout.Space(); - - if (GUILayout.Button("Build Physic Lab Scene ...")) - { - - } - } - EditorGUILayout.EndHorizontal(); - - EditorGUILayout.Space(); - } - EditorGUILayout.EndVertical(); - } - - private void showParameterTab() - { - groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Settings", groupEnabled); - myBool = EditorGUILayout.Toggle("Toggle", myBool); - myFloat = EditorGUILayout.Slider("Slider", myFloat, -3, 3); - EditorGUILayout.EndToggleGroup(); - } - - private void showQuizTab() - { - - } -} +using UnityEngine; +using UnityEditor; + +public class DynamicSceneGenerator : EditorWindow +{ + string myString = "Hello World"; + bool groupEnabled; + bool myBool = true; + float myFloat = 1.23f; + + private int tab = 0; + private string[] tabStrings = { "Build Scene", "Parameters", "Quiz" }; + + // Add menu named "Dynamic Scene Generator" to the Window menu + [MenuItem("Window/Dynamic Scene Generator")] + static void Init() + { + // Get existing open window or if none, make a new one: + DynamicSceneGenerator window = (DynamicSceneGenerator)EditorWindow.GetWindow(typeof(DynamicSceneGenerator), false, "Dynamic Scene Generator"); + window.Show(); + } + + private void OnGUI() + { + tab = GUILayout.Toolbar(tab, tabStrings); + switch(tab) + { + case 0: + showBuildSceneTab(); + break; + case 1: + showParameterTab(); + break; + case 2: + showQuizTab(); + break; + default: + Debug.LogError("DynamicSceneGenerator: Unknown Tab Index."); + break; + } + } + + private void showBuildSceneTab() + { + EditorGUILayout.BeginVertical(); + { + GUILayout.Label("Base Settings", EditorStyles.boldLabel); + myString = EditorGUILayout.TextField("Text Field", myString); + + GUILayout.FlexibleSpace(); + + EditorGUILayout.BeginHorizontal(); + { + GUILayout.FlexibleSpace(); + + if (GUILayout.Button("Build Web View Scene ...")) + { + + } + + EditorGUILayout.Space(); + + if (GUILayout.Button("Build Physic Lab Scene ...")) + { + + } + } + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.Space(); + } + EditorGUILayout.EndVertical(); + } + + private void showParameterTab() + { + groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Settings", groupEnabled); + myBool = EditorGUILayout.Toggle("Toggle", myBool); + myFloat = EditorGUILayout.Slider("Slider", myFloat, -3, 3); + EditorGUILayout.EndToggleGroup(); + } + + private void showQuizTab() + { + + } +} diff --git a/unity/Assets/Editor/DynamicSceneGenerator.cs.meta b/unity/Assets/Maroon/Editor/DynamicSceneGenerator.cs.meta similarity index 95% rename from unity/Assets/Editor/DynamicSceneGenerator.cs.meta rename to unity/Assets/Maroon/Editor/DynamicSceneGenerator.cs.meta index b25efd99d..1382f9f1e 100644 --- a/unity/Assets/Editor/DynamicSceneGenerator.cs.meta +++ b/unity/Assets/Maroon/Editor/DynamicSceneGenerator.cs.meta @@ -1,12 +1,12 @@ -fileFormatVersion: 2 -guid: ae6f632907fece84c85a72c33a86f908 -timeCreated: 1489594717 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: ae6f632907fece84c85a72c33a86f908 +timeCreated: 1489594717 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/unity/Assets/Maroon/Editor/Maroon.Editor.asmdef b/unity/Assets/Maroon/Editor/Maroon.Editor.asmdef index 402dff28c..b23b97558 100644 --- a/unity/Assets/Maroon/Editor/Maroon.Editor.asmdef +++ b/unity/Assets/Maroon/Editor/Maroon.Editor.asmdef @@ -2,8 +2,11 @@ "name": "Maroon.Editor", "rootNamespace": "", "references": [ + "GUID:e40ba710768534012815d3193fa296cb", + "GUID:c4aed1b7b59d62c48ab35dda9c36ff44", "GUID:b2f676e7b88c22d488081c7479661f0d", - "GUID:e40ba710768534012815d3193fa296cb" + "GUID:f3ea3a281defb5d4fa9983d10a689570", + "GUID:69316dfcff46f124e8f6f838a57ff6c2" ], "includePlatforms": [ "Editor" diff --git a/unity/Assets/Editor/WaterPlaneEditor.cs b/unity/Assets/Maroon/Editor/WaterPlaneEditor.cs similarity index 97% rename from unity/Assets/Editor/WaterPlaneEditor.cs rename to unity/Assets/Maroon/Editor/WaterPlaneEditor.cs index 831950ae8..16b922dbe 100644 --- a/unity/Assets/Editor/WaterPlaneEditor.cs +++ b/unity/Assets/Maroon/Editor/WaterPlaneEditor.cs @@ -1,66 +1,66 @@ -using UnityEditor; - -[CustomEditor(typeof(WaterPlane))] -public class WaterPlaneEditor : Editor -{ - private WaterPlane waterPlane; - - private SerializedProperty material; - - private SerializedProperty verticesPerLength; - private SerializedProperty verticesPerWidth; - - private SerializedProperty slitPlate; - private SerializedProperty waterBasinGeneratorPosition; - private SerializedProperty useMaterialReset; - - private void Awake() - { - waterPlane = (WaterPlane)target; - } - - private void OnEnable() - { - material = serializedObject.FindProperty("material"); - - verticesPerLength = serializedObject.FindProperty("verticesPerLength"); - verticesPerWidth = serializedObject.FindProperty("verticesPerWidth"); - - slitPlate = serializedObject.FindProperty("slitPlate"); - waterBasinGeneratorPosition = serializedObject.FindProperty("waterBasinGeneratorPosition"); - useMaterialReset = serializedObject.FindProperty("useMaterialReset"); - } - - public override void OnInspectorGUI() - { - //-------------------------------------------------------------------------- - // Check if Material has changed - //-------------------------------------------------------------------------- - EditorGUI.BeginChangeCheck(); - - EditorGUILayout.PropertyField(material); - - serializedObject.ApplyModifiedProperties(); - if (EditorGUI.EndChangeCheck()) - waterPlane.UpdateMaterial(); - - //-------------------------------------------------------------------------- - // Check if Plane Dimensions has changed - //-------------------------------------------------------------------------- - EditorGUI.BeginChangeCheck(); - - EditorGUILayout.PropertyField(verticesPerLength); - EditorGUILayout.PropertyField(verticesPerWidth); - - serializedObject.ApplyModifiedProperties(); - if (EditorGUI.EndChangeCheck()) - waterPlane.CalculatePlaneMesh(); - - serializedObject.ApplyModifiedProperties(); - - EditorGUILayout.PropertyField(slitPlate); - EditorGUILayout.PropertyField(waterBasinGeneratorPosition); - EditorGUILayout.PropertyField(useMaterialReset); - serializedObject.ApplyModifiedProperties(); - } +using UnityEditor; + +[CustomEditor(typeof(WaterPlane))] +public class WaterPlaneEditor : Editor +{ + private WaterPlane waterPlane; + + private SerializedProperty material; + + private SerializedProperty verticesPerLength; + private SerializedProperty verticesPerWidth; + + private SerializedProperty slitPlate; + private SerializedProperty waterBasinGeneratorPosition; + private SerializedProperty useMaterialReset; + + private void Awake() + { + waterPlane = (WaterPlane)target; + } + + private void OnEnable() + { + material = serializedObject.FindProperty("material"); + + verticesPerLength = serializedObject.FindProperty("verticesPerLength"); + verticesPerWidth = serializedObject.FindProperty("verticesPerWidth"); + + slitPlate = serializedObject.FindProperty("slitPlate"); + waterBasinGeneratorPosition = serializedObject.FindProperty("waterBasinGeneratorPosition"); + useMaterialReset = serializedObject.FindProperty("useMaterialReset"); + } + + public override void OnInspectorGUI() + { + //-------------------------------------------------------------------------- + // Check if Material has changed + //-------------------------------------------------------------------------- + EditorGUI.BeginChangeCheck(); + + EditorGUILayout.PropertyField(material); + + serializedObject.ApplyModifiedProperties(); + if (EditorGUI.EndChangeCheck()) + waterPlane.UpdateMaterial(); + + //-------------------------------------------------------------------------- + // Check if Plane Dimensions has changed + //-------------------------------------------------------------------------- + EditorGUI.BeginChangeCheck(); + + EditorGUILayout.PropertyField(verticesPerLength); + EditorGUILayout.PropertyField(verticesPerWidth); + + serializedObject.ApplyModifiedProperties(); + if (EditorGUI.EndChangeCheck()) + waterPlane.CalculatePlaneMesh(); + + serializedObject.ApplyModifiedProperties(); + + EditorGUILayout.PropertyField(slitPlate); + EditorGUILayout.PropertyField(waterBasinGeneratorPosition); + EditorGUILayout.PropertyField(useMaterialReset); + serializedObject.ApplyModifiedProperties(); + } } \ No newline at end of file diff --git a/unity/Assets/Editor/WaterPlaneEditor.cs.meta b/unity/Assets/Maroon/Editor/WaterPlaneEditor.cs.meta similarity index 100% rename from unity/Assets/Editor/WaterPlaneEditor.cs.meta rename to unity/Assets/Maroon/Editor/WaterPlaneEditor.cs.meta