Exemplo n.º 1
0
        /// <summary>
        /// Similar to "DrawDefaultInspector", except this is the Advanced one.
        /// </summary>
        protected void DrawAdvancedInspector()
        {
            if (rebuild)
            {
                fields.Clear();
                RefreshFields();
                rebuild = false;
            }

            AdvancedInspectorControl.Inspect(this, fields, false, rebuild);

            if (Changed)
            {
                foreach (object instance in Instances)
                {
                    if (instance is UnityEngine.Object)
                    {
                        EditorUtility.SetDirty((UnityEngine.Object)instance);
                    }

                    IDataChanged data = instance as IDataChanged;
                    if (data != null)
                    {
                        data.DataChanged();
                    }

                    Invoke("OnValidate", instance);
                }
            }

            for (int i = 0; i < fields.Count; i++)
            {
                fields[i].ClearCache();
            }
        }
        /// <summary>
        /// IControl implementation
        /// </summary>
        public bool Draw(Rect region)
        {
            GUILayout.BeginArea(region);

            bool redraw = false;

            if (Instances != null)
            {
                EditorGUILayout.BeginVertical();
                scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

                redraw = AdvancedInspectorControl.Inspect(this, Fields, false, false, expandable, separator);

                if (GUI.changed)
                {
                    foreach (object instance in Instances)
                    {
                        if (instance is UnityEngine.Object)
                        {
                            EditorUtility.SetDirty(instance as UnityEngine.Object);
                        }

                        IDataChanged data = instance as IDataChanged;
                        if (data != null)
                        {
                            data.DataChanged();
                        }
                    }
                }

                EditorGUILayout.EndScrollView();

                GUILayout.FlexibleSpace();

                DrawProviderInfo();

                EditorGUILayout.EndVertical();
            }

            GUILayout.EndArea();

            return(redraw);
        }