void OnGUI() { GUILayout.BeginVertical(); GUILayout.ExpandHeight(true); var gameobject = Selection.activeGameObject; if (gameobject != null) { GUILayout.Label(gameobject.name, EditorStyles.boldLabel); var customAnimationContrller = gameobject.GetComponent <CustomAnimationController>(); if (customAnimationContrller != null && customAnimationContrller.ActionList != null) { _lastSellectedController = customAnimationContrller; for (int i = 0; i < customAnimationContrller.ActionList.Count; ++i) { var action = customAnimationContrller.ActionList[i]; GUILayout.Label(action.GetType().ToString(), EditorStyles.boldLabel); if (GUILayout.Button("Remove Action", GUILayout.Width(100))) { if (customAnimationContrller.ActionList.Remove(action)) { --i; continue; } } try { foreach (var property in action.GetType().GetProperties()) { var propertyValue = property.GetValue(action, null); if (propertyValue is float) { EditorGUILayout.FloatField(property.Name.ToString(), (float)propertyValue); } } } catch (Exception ex) { Debug.Log(ex.Message); } } GUILayout.BeginHorizontal(); GUILayout.ExpandWidth(true); if (GUILayout.Button("Add Action")) { AddActionWindow.ShowWindow(); } GUILayout.ExpandWidth(false); GUILayout.EndHorizontal(); } } GUILayout.ExpandHeight(false); GUILayout.EndVertical(); }
void OnGUI() { EditorGUILayout.LabelField("Add Instruction:"); instruction.Name = EditorGUILayout.TextField("Name", instruction.Name); instruction.ID = EditorGUILayout.TextField("ID", instruction.ID); EditorGUILayout.LabelField("Motion Type:"); motionTypeIndex = EditorGUILayout.Popup(motionTypeIndex, motionTypeOptions); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Properties:"); foreach (var entry in instruction.Properties) { EditorGUILayout.LabelField(entry.Key + " : " + entry.Value); } if (GUILayout.Button("Add Parameter")) { //Get selected MMUDescription MMUDescription description = this.mmuDescriptions[this.motionTypeIndex]; AddParameterWindow window = new AddParameterWindow(ref instruction, description); window.Show(); } EditorGUILayout.LabelField("Start Condition:"); if (this.instruction.StartCondition != null) { EditorGUILayout.LabelField(this.instruction.StartCondition); } EditorGUILayout.LabelField("End Condition:"); if (this.instruction.EndCondition != null) { EditorGUILayout.LabelField(this.instruction.EndCondition); } if (GUILayout.Button("Add Condition")) { AddConditionWindow window = new AddConditionWindow(ref this.instruction, ref this.instructionList); window.Show(); } if (GUILayout.Button("Add Action")) { //Get selected MMUDescription MMUDescription description = this.mmuDescriptions[this.motionTypeIndex]; AddActionWindow window = new AddActionWindow(ref instruction, ref this.instructionList); window.Show(); } if (GUILayout.Button("Ok")) { //Finally assign the motion type this.instruction.MotionType = this.motionTypeOptions[this.motionTypeIndex]; //Check if all required parameters are set if (this.CheckParameters()) { this.instructionList.Add(this.instruction); Close(); } } //if (GUILayout.Button("Save")) //{ // //Finally assign the motion type // this.instruction.MotionType = this.motionTypeOptions[this.motionTypeIndex]; // string outputPath = EditorUtility.SaveFilePanel("Select the output file", "Instructions/", name, "json"); // System.IO.File.WriteAllText(outputPath, MMICSharp.Common.Communication.Serialization.ToJsonString(this.instruction)); // EditorUtility.DisplayDialog("Instruction list successfully saved.", "The instructions have been successfully exported to your desired output directory.", "Continue"); //} if (GUILayout.Button("Abort")) { Close(); } }