示例#1
0
        public override void OnInspectorGUI()
        {
            GUILayoutExt.DrawComponentHeader(this.serializedObject, "EXT", () => {
                GUILayout.Label("WindowSystem Internal module.\nWorking with resources.", GUILayout.Height(36f));
            }, new Color(0.4f, 0.2f, 0.7f, 1f));

            var target = this.target as WindowSystemResources;

            var allObjects = target.GetAllObjects();

            GUILayoutExt.Box(2f, 2f, () => {
                GUILayout.Label("Resources: " + target.GetAllocatedCount());
                foreach (var item in allObjects)
                {
                    //EditorGUILayout.ObjectField("Handler", item.Key as Object, typeof(Object), allowSceneObjects: true);
                    EditorGUILayout.LabelField("Handler", item.Key.ToString() + " (Loaded " + item.Value.Count.ToString() + ")");

                    ++EditorGUI.indentLevel;
                    foreach (var resItem in item.Value)
                    {
                        EditorGUILayout.LabelField(resItem.resourceId.ToString());
                        if (resItem.resource is Object)
                        {
                            EditorGUILayout.ObjectField((Object)resItem.resource, typeof(Object), allowSceneObjects: true);
                        }
                        else
                        {
                            EditorGUILayout.LabelField(resItem.resource.ToString());
                        }
                    }
                    --EditorGUI.indentLevel;
                }
            });
        }
        public override void OnInspectorGUI()
        {
            var target = (Tweener)this.target;

            foreach (var tween in target.tweens)
            {
                GUILayoutExt.Box(2f, 2f, () => {
                    var data = (Tweener.ITweenInternal)tween;
                    EditorGUILayout.ObjectField("Tag", data.GetTag() as Object, typeof(Object), allowSceneObjects: true);
                    if (data.GetDelay() > 0f)
                    {
                        EditorGUILayout.LabelField("Delay", data.GetDelay().ToString("mm:ss"));
                    }
                    EditorGUILayout.Slider(new GUIContent("Timer"), data.GetTimer(), 0f, 1f);
                });
            }
        }
        public override void OnInspectorGUI()
        {
            this.serializedObject.Update();

            GUILayoutExt.DrawComponentHeader(this.serializedObject, "L", () => {
                GUILayoutExt.DrawComponentHeaderItem("State", GUILayoutExt.GetPropertyToString(this.objectState));
            }, new Color(1f, 0.6f, 0f, 0.4f));

            GUILayout.Space(5f);

            var scroll = this.tabScrollPosition;

            this.selectedTab = GUILayoutExt.DrawTabs(
                this.selectedTab,
                ref scroll,
                new GUITab("Basic", () => {
                GUILayoutExt.DrawHeader("Main");
                EditorGUILayout.PropertyField(this.hiddenByDefault);
                EditorGUILayout.PropertyField(this.animationParameters);
                EditorGUILayout.PropertyField(this.subObjects);

                GUILayoutExt.DrawHeader("Performance Options");
                EditorGUILayout.PropertyField(this.createPool);
            }),
                new GUITab("Advanced", () => {
                GUILayoutExt.DrawHeader("Render Behaviour");
                EditorGUILayout.PropertyField(this.renderBehaviourOnHidden);

                GUILayoutExt.DrawHeader("Animation");
                EditorGUILayout.PropertyField(this.animationParameters);

                GUILayoutExt.DrawHeader("Graph");
                EditorGUILayout.PropertyField(this.allowRegisterInRoot);
                EditorGUILayout.PropertyField(this.autoRegisterSubObjects);
                EditorGUILayout.PropertyField(this.hiddenByDefault);
                EditorGUILayout.PropertyField(this.subObjects);

                GUILayoutExt.DrawHeader("Performance Options");
                EditorGUILayout.PropertyField(this.createPool);
            })
                );
            this.tabScrollPosition = scroll;

            GUILayout.Space(10f);

            EditorGUILayout.PropertyField(this.useSafeZone);
            if (this.useSafeZone.boolValue == true)
            {
                GUILayoutExt.Box(2f, 2f, () => {
                    EditorGUILayout.PropertyField(this.safeZone);
                    if (this.safeZone.objectReferenceValue == null && this.targets.Length == 1)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Generate", GUILayout.Width(80f), GUILayout.Height(30f)) == true)
                        {
                            var obj = this.target as Component;
                            if (PrefabUtility.IsPartOfAnyPrefab(obj) == true)
                            {
                                var path = AssetDatabase.GetAssetPath(obj.gameObject);
                                using (var edit = new EditPrefabAssetScope(path)) {
                                    EditorHelpers.AddSafeZone(edit.prefabRoot.transform);
                                }
                            }
                            else
                            {
                                var root = obj.gameObject;
                                EditorHelpers.AddSafeZone(root.transform);
                            }
                        }
                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();
                    }
                });
            }

            GUILayout.Space(10f);

            var iter = this.serializedObject.GetIterator();

            iter.NextVisible(true);
            do
            {
                if (EditorHelpers.IsFieldOfTypeBeneath(this.serializedObject.targetObject.GetType(), typeof(WindowLayout), iter.propertyPath) == true)
                {
                    EditorGUILayout.PropertyField(iter);
                }
            } while (iter.NextVisible(false) == true);

            this.serializedObject.ApplyModifiedProperties();
        }
示例#4
0
        public override void OnInspectorGUI()
        {
            if (this.fixedFontStyle == null || this.font == null)
            {
                this.fixedFontStyle = new GUIStyle(GUI.skin.label);
                var fontName = Application.platform == RuntimePlatform.WindowsEditor ? "Consolas" : "Courier";

                this.CleanupFont();

                this.font = Font.CreateDynamicFontFromOSFont(fontName, DataConfigGeneratorSettingsEditor.FONT_SIZE);
                this.fixedFontStyle.normal   = EditorStyles.label.normal;
                this.fixedFontStyle.wordWrap = true;
                this.fixedFontStyle.richText = true;
                this.fixedFontStyle.font     = this.font;
                this.fixedFontStyle.fontSize = DataConfigGeneratorSettingsEditor.FONT_SIZE;
            }

            if (this.versionStyle == null)
            {
                this.versionStyle           = new GUIStyle(EditorStyles.miniBoldLabel);
                this.versionStyle.alignment = TextAnchor.MiddleRight;
            }


            this.serializedObject.Update();

            GUILayoutExt.Box(10f, 10f, () => {
                if (this.list == null)
                {
                    var items                    = this.paths;
                    const float offset           = 4f;
                    const float padding          = 4f;
                    this.list                    = new UnityEditorInternal.ReorderableList(this.serializedObject, items, true, false, true, true);
                    this.list.drawHeaderCallback = (rect) => {
                        GUI.Label(rect, "Google Sheets");
                    };
                    this.list.onAddCallback = (list) => {
                        items.arraySize = items.arraySize + 1;
                        var prop        = items.GetArrayElementAtIndex(items.arraySize - 1);
                        prop.FindPropertyRelative("directory").objectReferenceValue = null;
                        prop.FindPropertyRelative("version").intValue               = -1;
                        prop.FindPropertyRelative("caption").stringValue            = string.Empty;
                        prop.FindPropertyRelative("path").stringValue               = string.Empty;
                        prop.FindPropertyRelative("behaviour").objectReferenceValue = null;
                        prop.FindPropertyRelative("visitedFiles").stringValue       = string.Empty;
                    };
                    this.list.elementHeightCallback = index => {
                        var prop = items.GetArrayElementAtIndex(index);
                        return(EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("directory")) + padding + offset * 2f + padding + padding + EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("caption")) + EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("path")) + EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("behaviour")));
                    };
                    this.list.drawElementCallback = (rect, index, active, focused) => {
                        var prop = items.GetArrayElementAtIndex(index);

                        var directoryRect    = new Rect(rect);
                        directoryRect.y     += offset;
                        directoryRect.height = EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("directory"));
                        var captionRect      = new Rect(rect);
                        captionRect.y        = directoryRect.yMax + padding;
                        captionRect.height   = EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("caption"));
                        var pathRect         = new Rect(rect);
                        pathRect.y           = captionRect.yMax + padding;
                        pathRect.height      = EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("path"));
                        var behaviourRect    = new Rect(rect);
                        behaviourRect.y      = pathRect.yMax + padding;
                        behaviourRect.height = EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("behaviour"));
                        var versionRect      = new Rect(pathRect);
                        versionRect.height   = EditorGUIUtility.singleLineHeight;

                        EditorGUI.PropertyField(directoryRect, prop.FindPropertyRelative("directory"));
                        var obj = prop.FindPropertyRelative("directory").objectReferenceValue;
                        if (obj != null)
                        {
                            var path = AssetDatabase.GetAssetPath(obj);
                            if (System.IO.Directory.Exists(path) == false)
                            {
                                prop.FindPropertyRelative("directory").objectReferenceValue = null;
                            }
                        }
                        EditorGUI.PropertyField(captionRect, prop.FindPropertyRelative("caption"));
                        EditorGUI.PropertyField(pathRect, prop.FindPropertyRelative("path"));
                        EditorGUI.PropertyField(behaviourRect, prop.FindPropertyRelative("behaviour"));
                        EditorGUI.LabelField(versionRect, $"Version: {prop.FindPropertyRelative("version").intValue}", this.versionStyle);
                    };
                }

                this.list.DoLayoutList();

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                EditorGUI.BeginDisabledGroup(this.inProgress);
                if (GUILayout.Button("Update All", GUILayout.Width(120f), GUILayout.Height(30f)) == true)
                {
                    DataConfigGeneratorSettingsEditor.logs.Clear();
                    EditorCoroutines.StartCoroutine(this.LoadAll(this.paths, forceUpdate: false));
                }
                EditorGUILayout.Space(4f);
                if (GUILayout.Button("Force Update All", GUILayout.Width(120f), GUILayout.Height(30f)) == true)
                {
                    DataConfigGeneratorSettingsEditor.logs.Clear();
                    EditorCoroutines.StartCoroutine(this.LoadAll(this.paths, forceUpdate: true));
                }
                EditorGUI.EndDisabledGroup();
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            });

            GUILayoutExt.Box(10f, 10f, () => {
                this.logsResult.Clear();
                foreach (var item in DataConfigGeneratorSettingsEditor.logs)
                {
                    if (item.logType == LogItem.LogItemType.System)
                    {
                        this.logsResult.Append($"<color=#77c>{item.text}</color>");
                    }
                    else if (item.logType == LogItem.LogItemType.Error)
                    {
                        this.logsResult.Append($"<color=#c77>{item.text}</color>");
                    }
                    else if (item.logType == LogItem.LogItemType.Warning)
                    {
                        this.logsResult.Append($"<color=#cc7>{item.text}</color>");
                    }
                    else
                    {
                        this.logsResult.Append(item.text);
                    }

                    this.logsResult.Append("\n");
                }

                this.logPosition = this.ScrollableSelectableLabel(this.logPosition, this.logsResult.ToString(), this.fixedFontStyle);
                //var rect = GUILayoutUtility.GetLastRect();
                //GUILayout.TextArea(this.logsResult.ToString(), this.fixedFontStyle, GUILayout.ExpandWidth(false), GUILayout.Width(rect.width));
            });

            this.serializedObject.ApplyModifiedProperties();

            this.Repaint();
        }