/// <summary>
    /// Draw sequene items
    /// </summary>
    void DrawEventArray()
    {
        EditorGUILayout.Separator();
        if (itsTarget.itsEntries.Count != 0)
        {
            for (int i = 0; i < itsTarget.itsEntries.Count; i++)
            {
                EditorGUILayout.Separator();

                // change color on error
                KGFGUIUtilityEditor.SetColorDefault();
                if (itsTarget.itsEntries[i].itsEvent == null || itsTarget.itsEntries[i].itsWaitBefore < 0 || itsTarget.itsEntries[i].itsWaitAfter < 0)
                {
                    KGFGUIUtilityEditor.SetColorError();
                }

                EditorGUILayout.BeginHorizontal(GUI.skin.box, GUILayout.Height(60));
                {
                    // draw navigation buttons
                    EditorGUILayout.BeginVertical(GUILayout.Width(40));
                    {
                        if (i != 0)
                        {
                            if (GUILayout.Button("up", GUILayout.ExpandHeight(true), GUILayout.Width(35)))
                            {
                                itsTarget.MoveUp(itsTarget.itsEntries[i]);
                            }
                        }
                        if (i != itsTarget.itsEntries.Count - 1)
                        {
                            if (GUILayout.Button("down", GUILayout.ExpandHeight(true), GUILayout.Width(35)))
                            {
                                itsTarget.MoveDown(itsTarget.itsEntries[i]);
                            }
                        }
                    }
                    EditorGUILayout.EndVertical();

                    // draw input fields
                    EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true));
                    {
                        float aValue = EditorGUILayout.FloatField("itsWaitBefore: ", itsTarget.itsEntries[i].itsWaitBefore, GUILayout.Height(20));
                        if (aValue != itsTarget.itsEntries[i].itsWaitBefore)
                        {
                            itsTarget.itsEntries[i].itsWaitBefore = aValue;
                            EditorUtility.SetDirty(itsTarget);
                        }
                        KGFEventBase anEvent = (KGFEventBase)EditorGUILayout.ObjectField("itsEvent " + i, itsTarget.itsEntries[i].itsEvent, typeof(KGFEventBase), true, GUILayout.Height(20));
                        if (anEvent != itsTarget.itsEntries[i].itsEvent)
                        {
                            itsTarget.itsEntries[i].itsEvent = anEvent;
                            EditorUtility.SetDirty(itsTarget);
                        }

                        aValue = EditorGUILayout.FloatField("itsWaitAfter: ", itsTarget.itsEntries[i].itsWaitAfter, GUILayout.Height(20));
                        if (aValue != itsTarget.itsEntries[i].itsWaitAfter)
                        {
                            itsTarget.itsEntries[i].itsWaitAfter = aValue;
                            EditorUtility.SetDirty(itsTarget);
                        }
                    }
                    EditorGUILayout.EndVertical();

                    // draw command buttons
                    EditorGUILayout.BeginVertical(GUILayout.Width(40));
                    {
                        if (GUILayout.Button("new", GUILayout.ExpandHeight(true), GUILayout.Width(35)))
                        {
                            itsTarget.Insert(itsTarget.itsEntries[i], new KGFEventSequence.KGFEventSequenceEntry());
                        }
                        if (i != 0)
                        {
                            if (GUILayout.Button("del", GUILayout.ExpandHeight(true), GUILayout.Width(35)))
                            {
                                itsTarget.Delete(itsTarget.itsEntries[i]);
                            }
                        }
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndHorizontal();
            }
        }

        EditorGUILayout.Separator();
    }
Exemplo n.º 2
0
 public override void OnInspectorGUI()
 {
     KGFGUIUtilityEditor.RenderKGFInspector(this, this.GetType());
 }
Exemplo n.º 3
0
 public override sealed void OnInspectorGUI()
 {
     KGFGUIUtility.SetSkinIndex(0);
     KGFGUIUtilityEditor.RenderKGFInspector(this, this.GetType(), CustomGui);
     KGFGUIUtility.SetSkinIndex(1);
 }
 /// <summary>
 /// Draw a single parameter field
 /// </summary>
 /// <param name="theParameter">The reflected parameter type</param>
 /// <param name="theValue">The parameter value</param>
 /// <param name="theIndex">Index of the parameter in the itsParameters array</param>
 static void DrawSingleParameter(UnityEngine.Object theTarget, KGFEvent.KGFEventData theEventData, ParameterInfo theParameter, KGFEvent.EventParameter theValue, int theIndex)
 {
     if (typeof(UnityEngine.Object).IsAssignableFrom(theParameter.ParameterType))
     {
         // if the parameter is derrived from unityengine.object, display an object field
         UnityEngine.Object aObject = EditorGUILayout.ObjectField(theParameter.Name, theValue.itsValueUnityObject, theParameter.ParameterType, true);
         if (aObject != theValue.itsValueUnityObject)
         {
             EditorUtility.SetDirty(theTarget);
             theValue.itsValueUnityObject = aObject;
         }
     }
     else
     {
         // Search for parameter with right name in EventParameter script and display it
         if (typeof(int).IsAssignableFrom(theParameter.ParameterType))
         {
             theValue.itsValueInt32 = (int)KGFGUIUtilityEditor.DrawField(theTarget, typeof(int), theParameter.Name, theValue.itsValueInt32);
         }
         else if (typeof(double).IsAssignableFrom(theParameter.ParameterType))
         {
             theValue.itsValueSingle = (float)KGFGUIUtilityEditor.DrawField(theTarget, typeof(float), theParameter.Name, theValue.itsValueSingle);
         }
         else if (typeof(float).IsAssignableFrom(theParameter.ParameterType))
         {
             theValue.itsValueDouble = (double)KGFGUIUtilityEditor.DrawField(theTarget, typeof(double), theParameter.Name, theValue.itsValueDouble);
         }
         else if (typeof(string).IsAssignableFrom(theParameter.ParameterType))
         {
             theValue.itsValueString = (string)KGFGUIUtilityEditor.DrawField(theTarget, typeof(string), theParameter.Name, theValue.itsValueString);
         }
         else if (typeof(Color).IsAssignableFrom(theParameter.ParameterType))
         {
             theValue.itsValueColor = (Color)KGFGUIUtilityEditor.DrawField(theTarget, typeof(Color), theParameter.Name, theValue.itsValueColor);
         }
         else if (typeof(Rect).IsAssignableFrom(theParameter.ParameterType))
         {
             theValue.itsValueRect = (Rect)KGFGUIUtilityEditor.DrawField(theTarget, typeof(Rect), theParameter.Name, theValue.itsValueRect);
         }
         else if (typeof(Vector2).IsAssignableFrom(theParameter.ParameterType))
         {
             theValue.itsValueVector2 = (Vector2)KGFGUIUtilityEditor.DrawField(theTarget, typeof(Vector2), theParameter.Name, theValue.itsValueVector2);
         }
         else if (typeof(Vector3).IsAssignableFrom(theParameter.ParameterType))
         {
             theValue.itsValueVector3 = (Vector3)KGFGUIUtilityEditor.DrawField(theTarget, typeof(Vector3), theParameter.Name, theValue.itsValueVector3);
         }
         else if (typeof(Vector4).IsAssignableFrom(theParameter.ParameterType))
         {
             theValue.itsValueVector4 = (Vector4)KGFGUIUtilityEditor.DrawField(theTarget, typeof(Vector4), theParameter.Name, theValue.itsValueVector4);
         }
         else if (typeof(bool).IsAssignableFrom(theParameter.ParameterType))
         {
             theValue.itsValueBoolean = (bool)KGFGUIUtilityEditor.DrawField(theTarget, typeof(bool), theParameter.Name, theValue.itsValueBoolean);
         }
         else if (typeof(Enum).IsAssignableFrom(theParameter.ParameterType))
         {
             Enum anEnumValue = null;
             try{
                 anEnumValue = (Enum)Enum.Parse(theParameter.ParameterType, theValue.itsValueString);
             }
             catch
             {
                 // choose first value of enum
                 foreach (Enum aValue in Enum.GetValues(theParameter.ParameterType))
                 {
                     anEnumValue = aValue;
                     break;
                 }
             }
             theValue.itsValueString = ((Enum)KGFGUIUtilityEditor.DrawField(theTarget, typeof(Enum), theParameter.Name, anEnumValue)).ToString();
         }
     }
 }