コード例 #1
0
        public override void OnInspectorGUI()
        {
            MoonGUILayout.DrawDefaultInspectorNoScript(serializedObject);

            serializedObject.Update();

            GUILayout.Space(5);

            list.DoLayoutList();


            serializedObject.ApplyModifiedProperties();
        }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            MoonGUILayout.DrawDefaultInspectorNoScript(serializedObject);

            serializedObject.Update();

            Math.MathMode mode = (Math.MathMode)Mode.enumValueIndex;

            EditorGUILayout.PropertyField(AValue);

            if (mode != Math.MathMode.Pow & mode != Math.MathMode.Sin & mode != Math.MathMode.Cosin &
                mode != Math.MathMode.Sqrt & mode != Math.MathMode.Round & mode != Math.MathMode.Tan)
            {
                EditorGUILayout.PropertyField(BValue);
            }

            EditorGUILayout.PropertyField(SaveKey);

            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // Draw inspector for each filter

            for (int i = 0; i < Filters.arraySize; i++)
            {
                SerializedProperty currentf = Filters.GetArrayElementAtIndex(i);

                GUILayout.BeginHorizontal();

                currentf.isExpanded = EditorGUILayout.Foldout(currentf.isExpanded, new GUIContent(ObjectNames.NicifyVariableName(currentf.objectReferenceValue.GetType().Name)));

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Remove", EditorStyles.miniButton))
                {
                    DestroyImmediate(currentf.objectReferenceValue, true);
                    AssetDatabase.SaveAssets();
                    Filters.DeleteArrayElementAtIndex(i);
                    Filters.DeleteArrayElementAtIndex(i);
                    serializedObject.ApplyModifiedProperties();
                    continue;
                }

                GUILayout.EndHorizontal();

                if (currentf.isExpanded)
                {
                    Editor m_editor = CreateEditor(currentf.objectReferenceValue);

                    GUILayout.Space(5);

                    m_editor.OnInspectorGUI();
                }

                MoonGUILayout.Separator();
            }

            GUILayout.Space(5);

            // add buttun filter

            if (GUILayout.Button("Add Filter", GUILayout.Height(20)))
            {
                GenericMenu Menu = new GenericMenu();

                // Gets all aviable filters via reflection

                List <System.Type> m_types = MoonReflection.GetAllDerivedTypes(typeof(SensorFilter)).ToList();

                for (int i = 0; i < m_types.Count; i++)
                {
                    System.Type currt = m_types[i];

                    if (currt != null)
                    {
                        Menu.AddItem(new GUIContent(currt.Name), false, new GenericMenu.MenuFunction(() =>
                        {
                            int index           = Filters.arraySize;
                            SensorFilter filter = CreateInstance(currt) as SensorFilter;
                            filter.hideFlags    = HideFlags.HideInHierarchy | HideFlags.HideInInspector;

                            AssetDatabase.AddObjectToAsset(filter, target);

                            AssetDatabase.SaveAssets();

                            Filters.InsertArrayElementAtIndex(index);

                            SerializedProperty curr = Filters.GetArrayElementAtIndex(index);

                            curr.objectReferenceValue = filter;

                            serializedObject.ApplyModifiedProperties();
                        }));
                    }
                }

                Menu.ShowAsContext();
            }
            serializedObject.ApplyModifiedProperties();
        }
コード例 #4
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.Space();

            if (!EditorApplication.isPlaying)
            {
                MemoryList.DoLayoutList();
                EditorGUILayout.Space();
            }
            else
            {
                Hashtable hash = memoryfield.GetValue(target) as Hashtable;

                EditorGUILayout.BeginVertical(GUI.skin.box);

                MoonGUILayout.CenterLabel("Memory");
                EditorGUILayout.Space();

                if (hash != null && hash.Values.Count > 0)
                {
                    object[] Labels = new object[hash.Keys.Count];

                    hash.Keys.CopyTo(Labels, 0);

                    for (int i = 0; i < Labels.Length; i++)
                    {
                        Rect h = EditorGUILayout.BeginHorizontal();

                        if (Labels[i] == null)
                        {
                            continue;
                        }


                        GUILayout.Label(Labels[i].ToString() + ":", GUILayout.Width(EditorStyles.label.CalcSize(
                                                                                        new GUIContent(Labels[i].ToString() + ":")).x));

                        object val = hash[Labels[i]];

                        if (val != null)
                        {
                            if (val.GetType() == typeof(Color))
                            {
                                Color oldcolor = GUI.color;
                                GUI.color = Color.white;

                                Rect r = GUILayoutUtility.GetRect(h.width - 5, 15);
                                EditorGUI.DrawRect(r, (Color)val);

                                GUI.color = oldcolor;
                            }
                            else
                            {
                                GUILayout.Label(val.ToString());
                            }
                        }
                        else
                        {
                            GUILayout.Label("null");
                        }

                        EditorGUILayout.EndHorizontal();
                    }

                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.LabelField("No memory elements found !");
                }

                EditorGUILayout.EndVertical();

                Repaint();
            }
            serializedObject.ApplyModifiedProperties();
        }
コード例 #5
0
ファイル: NodeInspector.cs プロジェクト: pedro15/MoonBehavior
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(tooltipPosition);

            EditorGUILayout.PropertyField(Tooltip);

            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
            }

            MoonGUILayout.Separator();

            if (TaskInfo != null)
            {
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(TaskInfo.Name, new GUIStyle(EditorStyles.label)
                {
                    fontStyle = FontStyle.Bold
                });

                GUILayout.FlexibleSpace();

                if (Nodedoc != null)
                {
                    if (GUILayout.Button(new GUIContent("?", "Open documentation"), EditorStyles.miniButton))
                    {
                        Application.OpenURL(Nodedoc.URL);
                    }
                }

                EditorGUILayout.EndHorizontal();

                if (!string.IsNullOrEmpty(TaskInfo.Description))
                {
                    EditorGUILayout.HelpBox(TaskInfo.Description, MessageType.Info);
                }
            }

            if (TaskInspector != null)
            {
                if (!EditorApplication.isPlaying)
                {
                    // Draw task inspector
                    TaskInspector.OnInspectorGUI();
                }
                else if (n != null)
                {
                    GUILayout.BeginVertical("Debug mode", GUI.skin.box, GUILayout.ExpandWidth(true));

                    GUILayout.Space(15);

                    if (!n.Task)
                    {
                        return;
                    }


                    FieldInfo[] fields = n.Task.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

                    PropertyInfo[] props = n.Task.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

                    for (int i = 0; i < fields.Length; i++)
                    {
                        FieldInfo currentField = fields[i];

                        if (!ValidName(currentField.Name))
                        {
                            continue;
                        }

                        object[] atrs = currentField.GetCustomAttributes(typeof(HideOnDebugAttribute), true);

                        if (atrs != null && atrs.Length > 0)
                        {
                            continue;
                        }

                        object currentValue = currentField.GetValue(n.Task);

                        if (currentValue != null)
                        {
                            GUILayout.Label(ObjectNames.NicifyVariableName(currentField.Name) + ": " + currentValue.ToString());
                        }
                        else
                        {
                            GUILayout.Label(ObjectNames.NicifyVariableName(currentField.Name) + ": null");
                        }
                    }

                    for (int i = 0; i < props.Length; i++)
                    {
                        PropertyInfo currentProp  = props[i];
                        object       currentValue = currentProp.GetValue(n.Task, null);

                        if (!ValidName(currentProp.Name))
                        {
                            continue;
                        }

                        object[] atrs = currentProp.GetCustomAttributes(typeof(HideOnDebugAttribute), true);

                        if (atrs != null && atrs.Length > 0)
                        {
                            continue;
                        }

                        if (currentValue != null)
                        {
                            GUILayout.Label(ObjectNames.NicifyVariableName(currentProp.Name) + ": " + currentValue.ToString());
                        }
                        else
                        {
                            GUILayout.Label(ObjectNames.NicifyVariableName(currentProp.Name) + ": null");
                        }
                    }

                    GUILayout.EndVertical();

                    Repaint();
                }
            }
        }
コード例 #6
0
ファイル: TaskInspector.cs プロジェクト: pedro15/MoonBehavior
 public override void OnInspectorGUI()
 {
     MoonGUILayout.DrawDefaultInspectorNoScript(serializedObject);
 }