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

            var target = this.target as WindowSystemPools;

            UnityEditor.UI.Windows.GUILayoutExt.DrawHeader("Registered prefabs");
            foreach (var item in target.registeredPrefabs)
            {
                GUILayout.Label(item.ToString());
            }

            UnityEditor.UI.Windows.GUILayoutExt.DrawHeader("Instances on scene");
            foreach (var item in target.instanceOnSceneToPrefab)
            {
                UnityEditor.UI.Windows.GUILayoutExt.Box(2f, 2f, () => {
                    GUILayout.Label("Prefab: " + item.Value);
                    EditorGUILayout.ObjectField("Object", item.Key, typeof(Object), allowSceneObjects: true);
                });
            }

            UnityEditor.UI.Windows.GUILayoutExt.DrawHeader("Instances in pool");
            foreach (var item in target.prefabToPooledInstances)
            {
                UnityEditor.UI.Windows.GUILayoutExt.Box(2f, 2f, () => {
                    GUILayout.Label("Prefab: " + item.Key);
                    foreach (var comp in item.Value)
                    {
                        EditorGUILayout.ObjectField(comp, typeof(Object), true);
                    }
                });
            }
        }
コード例 #2
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;
                }
            });
        }
 private void DrawCanvas()
 {
     if (this.objectCanvas.objectReferenceValue != null)
     {
         GUILayoutExt.DrawHeader("Canvas Options");
         EditorGUILayout.PropertyField(this.canvasSortingOrderDelta, new GUIContent("Canvas Order Delta"));
     }
 }
コード例 #4
0
        public override void OnInspectorGUI()
        {
            this.serializedObject.Update();

            GUILayoutExt.DrawComponentHeader(this.serializedObject, "M", () => {
                GUILayoutExt.DrawComponentHeaderItem("State", GUILayoutExt.GetPropertyToString(this.objectState));
            }, new Color(1f, 0.6f, 1f, 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);

            var iter = this.serializedObject.GetIterator();

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

            this.serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            this.serializedObject.Update();

            GUILayoutExt.DrawComponentHeader(this.serializedObject, "S", () => {
                GUILayoutExt.DrawComponentHeaderItem("State", GUILayoutExt.GetPropertyToString(this.objectState));
                GUILayoutExt.DrawComponentHeaderItem("Focus", GUILayoutExt.GetPropertyToString(this.focusState));

                GUILayout.FlexibleSpace();
            }, new Color(0f, 0.6f, 0f, 0.4f));

            GUILayout.Space(5f);

            var scroll = this.tabScrollPosition;

            this.selectedTab = GUILayoutExt.DrawTabs(
                this.selectedTab,
                ref scroll,
                new GUITab("Preferences", () => {
                GUILayoutExt.DrawProperty(this.preferences);
                EditorGUILayout.PropertyField(this.createPool);
            }),
                new GUITab("Modules (" + this.listModules.count.ToString() + ")", () => {
                this.listModules.DoLayoutList();
            }),
                new GUITab("Layouts", () => {
                EditorGUILayout.PropertyField(this.layouts);
            }),
                new GUITab("Audio", () => {
                GUILayoutExt.DrawHeader("Events");
                var enterChildren = true;
                var prop          = this.audioEvents.Copy();
                var depth         = prop.depth + 1;
                while (prop.NextVisible(enterChildren) == true && prop.depth >= depth)
                {
                    EditorGUILayout.PropertyField(prop, true);
                    enterChildren = false;
                }
            })
                );
            this.tabScrollPosition = scroll;

            GUILayout.Space(10f);

            var iter = this.serializedObject.GetIterator();

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

            this.serializedObject.ApplyModifiedProperties();
        }
コード例 #6
0
        public static bool DrawButton(Rect contentRect, Layout hMode, Layout vMode)
        {
            const float padding = 4f;
            const float size    = 40f;

            var inner = contentRect;

            inner.x      += padding;
            inner.width  -= padding * 2f;
            inner.y      += padding;
            inner.height -= padding * 2f;

            var style = new GUIStyle(EditorStyles.miniButton);

            style.stretchHeight = true;
            style.fixedHeight   = 0f;
            style.normal.scaledBackgrounds[0]   = null;
            style.onNormal.scaledBackgrounds[0] = Texture2D.whiteTexture;
            var oldColor = GUI.color;

            GUI.color = new Color(1f, 1f, 1f, contentRect.Contains(Event.current.mousePosition) ? 0.3f : 0f);
            if (GUI.Button(contentRect, string.Empty, style) == true)
            {
                return(true);
            }
            GUI.color = oldColor;

            GUILayoutExt.DrawBoxNotFilled(contentRect, 1f, new Color(1f, 1f, 1f, 0.3f), padding);
            GUILayoutExt.DrawBoxNotFilled(contentRect, 1f, new Color(1f, 1f, 1f, 0.5f), padding * 3f);

            var vLine = inner;

            vLine.y     += (size - padding * 2f) * kPivotsForModes[(int)vMode] - 0.5f;
            vLine.height = 1f;
            vLine.x     += 1f;
            vLine.width -= 2f;
            GUILayoutExt.DrawRect(vLine, new Color(0.7f, 0.3f, 0.3f, 1));

            var hLine = inner;

            hLine.x      += (size - padding * 2f) * kPivotsForModes[(int)hMode] - 0.5f;
            hLine.width   = 1f;
            hLine.y      += 1f;
            hLine.height -= 2f;
            GUILayoutExt.DrawRect(hLine, new Color(0.7f, 0.3f, 0.3f, 1));

            var pivot = new Vector2(
                Mathf.Lerp(inner.xMin, inner.xMax, kPivotsForModes[(int)hMode]),
                Mathf.Lerp(inner.yMin, inner.yMax, kPivotsForModes[(int)vMode])
                );

            GUILayoutExt.DrawRect(new Rect(pivot.x - 1f, pivot.y - 1f, 3f, 3f), new Color(0.8f, 0.6f, 0.0f, 1));

            return(false);
        }
コード例 #7
0
        public override void OnFlowWindowGUI(FD.FlowWindow window)
        {
            if (Social.settings == null)
            {
                return;
            }

            var socialFlag = (window.flags & Social.settings.uniqueTag) == Social.settings.uniqueTag;

            if (socialFlag == true)
            {
                var settings = Social.settings;
                if (settings == null)
                {
                    return;
                }

                var data             = settings.data.Get(window);
                var isActiveSelected = settings.IsPlatformActive(data.settings);

                var oldColor = GUI.color;
                GUI.color = isActiveSelected ? Color.white : Color.grey;
                var result = GUILayoutExt.LargeButton(data.settings ? data.settings.GetPlatformName() : "None", 60f, 150f);
                GUI.color = oldColor;
                var rect = GUILayoutUtility.GetLastRect();
                rect.y += rect.height;

                if (result == true)
                {
                    var menu = new GenericMenu();
                    menu.AddItem(new GUIContent("None"), data.settings == null, () => {
                        data.settings = null;
                    });

                    foreach (var platform in settings.activePlatforms)
                    {
                        if (platform.active == true)
                        {
                            var item = platform.settings;
                            menu.AddItem(new GUIContent(platform.GetPlatformName()), data.settings == platform.settings, () => {
                                data.settings = item;
                            });
                        }
                        else
                        {
                            menu.AddDisabledItem(new GUIContent(platform.GetPlatformName()));
                        }
                    }

                    menu.DropDown(rect);
                }
            }
        }
コード例 #8
0
        public void OnEnable()
        {
            try {
                #pragma warning disable
                var _ = this.serializedObject;
                #pragma warning restore
            } catch (System.Exception) {
                return;
            }

            this.createPool = this.serializedObject.FindProperty("createPool");

            this.objectState = this.serializedObject.FindProperty("objectState");
            this.focusState  = this.serializedObject.FindProperty("focusState");

            this.preferences = this.serializedObject.FindProperty("preferences");
            this.modules     = this.serializedObject.FindProperty("modules");
            this.layouts     = this.serializedObject.FindProperty("layouts");

            var moduleItems = this.modules.FindPropertyRelative("modules");
            this.listModules = new UnityEditorInternal.ReorderableList(this.serializedObject, moduleItems, false, false, true, true);
            const float elementHeight = 64f;
            this.listModules.headerHeight         = 1f;
            this.listModules.elementHeight        = elementHeight;
            this.listModules.drawElementCallback += (rect, index, active, focus) => {
                var item      = moduleItems.GetArrayElementAtIndex(index);
                var prevValue = item.FindPropertyRelative("module").FindPropertyRelative("guid");
                rect.y     += 2f;
                rect.height = 18f;
                EditorGUI.BeginChangeCheck();
                GUILayoutExt.DrawProperty(rect, item, 20f);
                GUILayoutExt.DrawRect(new Rect(rect.x, rect.y + elementHeight - 3f, rect.width, 1f), new Color(1f, 1f, 1f, 0.1f));
                if (EditorGUI.EndChangeCheck() == true)
                {
                    var newValue = item.FindPropertyRelative("module").FindPropertyRelative("guid");
                    if (prevValue != newValue && string.IsNullOrEmpty(newValue.stringValue) == false)
                    {
                        var guid      = newValue.stringValue;
                        var assetPath = AssetDatabase.GUIDToAssetPath(guid);
                        var obj       = AssetDatabase.LoadAssetAtPath <WindowModule>(assetPath);

                        var module = obj;
                        item.FindPropertyRelative("order").intValue = module.defaultOrder;
                    }
                }
                //EditorGUI.PropertyField(rect, item);
            };

            EditorHelpers.SetFirstSibling(this.targets);
        }
コード例 #9
0
        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);
                });
            }
        }
コード例 #10
0
        public override void OnGUI(Rect rect)
        {
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return)
            {
                this.editorWindow.Close();
            }

            const float offset = 10f;
            const float size   = 40f;

            for (int x = 0; x < 3; ++x)
            {
                for (int y = 0; y < 3; ++y)
                {
                    if (this.drawMiddle == false && x == 1 && y == 1)
                    {
                        continue;
                    }

                    var hMode = (WindowSystemSidePropertyDrawer.Layout)x;
                    var vMode = (WindowSystemSidePropertyDrawer.Layout)y;

                    var buttonRect = rect;
                    buttonRect.x      = offset + size * x;
                    buttonRect.y      = offset + size * y;
                    buttonRect.width  = size;
                    buttonRect.height = size;
                    if (WindowSystemSidePropertyDrawer.DrawButton(buttonRect, hMode, vMode) == true)
                    {
                        if (this.callback != null)
                        {
                            this.callback.Invoke(hMode, vMode);
                        }
                        this.editorWindow.Close();
                    }

                    if (hMode == this.selectedX && vMode == this.selectedY)
                    {
                        GUILayoutExt.DrawBoxNotFilled(buttonRect, 1f, Color.white);
                    }
                }
            }
        }
コード例 #11
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var attr = (SearchAssetsByTypePopupAttribute)this.attribute;

            var target = (string.IsNullOrEmpty(attr.innerField) == true ? property : property.FindPropertyRelative(attr.innerField));

            EditorGUI.LabelField(position, label);
            position.x     += EditorGUIUtility.labelWidth;
            position.width -= EditorGUIUtility.labelWidth;
            if (GUILayoutExt.DrawDropdown(position, new GUIContent(target.objectReferenceValue != null ? EditorHelpers.StringToCaption(target.objectReferenceValue.name) : attr.noneOption), FocusType.Passive, target.objectReferenceValue) == true)
            {
                var rect   = position;
                var vector = GUIUtility.GUIToScreenPoint(new Vector2(rect.x, rect.y));
                rect.x = vector.x;
                rect.y = vector.y;

                var popup = new Popup()
                {
                    title = attr.menuName, autoClose = true, screenRect = new Rect(rect.x, rect.y + rect.height, rect.width, 200f)
                };
                var objects = AssetDatabase.FindAssets("t:" + (attr.filterType != null ? attr.filterType.Name : "Object"), attr.filterDir == null ? null : new [] { attr.filterDir });
                if (string.IsNullOrEmpty(attr.noneOption) == false)
                {
                    popup.Item(attr.noneOption, null, searchable: false, action: (item) => {
                        property.serializedObject.Update();
                        target.objectReferenceValue = null;
                        property.serializedObject.ApplyModifiedProperties();
                    }, order: -1);
                }

                for (int i = 0; i < objects.Length; ++i)
                {
                    var path  = AssetDatabase.GUIDToAssetPath(objects[i]);
                    var asset = AssetDatabase.LoadAssetAtPath <Object>(path);
                    popup.Item(EditorHelpers.StringToCaption(asset.name), () => {
                        property.serializedObject.Update();
                        target.objectReferenceValue = asset;
                        property.serializedObject.ApplyModifiedProperties();
                    });
                }
                popup.Show();
            }
        }
コード例 #12
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var offset = new Vector2(position.x, position.y);

            //GUI.BeginGroup(position);
            {
                var width  = 30f;
                var margin = 5f;

                //property.serializedObject.Update();

                EditorGUI.PropertyField(new Rect(offset.x, offset.y, position.width - width - margin, position.height), property, label, true);
                GUILayoutExt.DrawComponentChooser(new Rect(position.width - width + offset.x, offset.y, width, position.height), (property.serializedObject.targetObject as WindowComponent).gameObject, property.objectReferenceValue as WindowComponent, (component) => {
                    property.objectReferenceValue = component;
                    property.serializedObject.ApplyModifiedProperties();
                });

                //property.serializedObject.ApplyModifiedProperties();
            }
            //GUI.EndGroup();
        }
コード例 #13
0
        public override void OnFlowSettingsGUI()
        {
            GUILayout.Label(FlowAddon.MODULE_INSTALLED, EditorStyles.centeredGreyMiniLabel);

            GUILayout.Label("Functions", EditorStyles.boldLabel);

            var data = FlowSystem.GetData();

            if (data == null)
            {
                return;
            }

            this.functions.Clear();
            foreach (var window in data.windows)
            {
                if (window.IsFunction() == true &&
                    window.IsContainer() == true)
                {
                    this.functions.Add(window);
                }
            }

            if (this.functions.Count == 0)
            {
                var style = new GUIStyle(GUI.skin.label);
                style.wordWrap = true;
                GUILayout.Label("No functions ware found in the current project. Add new one by clicking on `Create->Functions` menu.", style);
            }
            else
            {
                foreach (var function in this.functions)
                {
                    if (GUILayoutExt.LargeButton(function.title, 20f, FlowSystemEditorWindow.SETTINGS_WIDTH) == true)
                    {
                        this.flowEditor.SetCenterTo(function);
                    }
                }
            }
        }
コード例 #14
0
        public static void OnDrawSettingsGUI(FlowSystemEditorWindow flowEditor)
        {
            var flowAddons = CoreUtilities.GetAddons <FlowAddon>((name, item) => item.name = name);

            if (flowAddons.Count == 0)
            {
                GUILayout.Label("No Modules Has Been Installed.");
            }
            else
            {
                foreach (var addon in flowAddons)
                {
                                        #if DEBUGBUILD
                    Profiler.BeginSample("[ GUI ] Addon " + addon.name);
                                        #endif

                    addon.flowEditor = flowEditor;
                    Flow.DrawModuleSettingsGUI(addon, addon.GetName(), addon.GetSettingsMenu(null), () => { addon.OnFlowSettingsGUI(); });

                                        #if DEBUGBUILD
                    Profiler.EndSample();
                                        #endif
                }
            }

            CustomGUI.Splitter();

            GUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();

                if (GUILayoutExt.LargeButton("Install Modules...", 40f, 200f) == true)
                {
                    Application.OpenURL(VersionInfo.DOWNLOAD_LINK);
                }

                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();
        }
コード例 #15
0
        /// <summary>
        ///   Edits the specified context.
        /// </summary>
        /// <param name="context">Editor context to work with.</param>
        public void Edit(IValueEditorContext context)
        {
            if (!ReflectionUtils.IsEnum(context.Type))
            {
                throw new ArgumentException(string.Format("Type '{0}' is no enum type.", context.Type), "context");
            }

            // Get enum value.
            Array enumValues = Enum.GetValues(context.Type);
            int   selectedItem;
            Enum  value;

            if (context.Value != null)
            {
                value        = (Enum)context.Value;
                selectedItem = Array.IndexOf(enumValues, value);
            }
            else
            {
                // Take first value of enum type.
                value        = (Enum)enumValues.GetValue(0);
                selectedItem = 0;
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label(context.Name);
            bool showList;

            this.showPopupList.TryGetValue(context.Key, out showList);
            int newSelectedItem = GUILayoutExt.Popup(selectedItem, Enum.GetNames(context.Type), ref showList);

            this.showPopupList[context.Key] = showList;
            GUILayout.EndHorizontal();

            if (newSelectedItem != selectedItem)
            {
                context.Value = enumValues.GetValue(newSelectedItem);
            }
        }
コード例 #16
0
        public static void DrawModuleSettingsGUI(IWindowFlowAddon addon, string caption, GenericMenu settingsMenu, System.Action onGUI)
        {
            CustomGUI.Splitter(new Color(0.7f, 0.7f, 0.7f, 0.2f));

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(caption.ToSentenceCase().UppercaseWords(), EditorStyles.boldLabel);

                if (settingsMenu != null)
                {
                    var settingsStyle = new GUIStyle("PaneOptions");
                    if (GUILayout.Button(string.Empty, settingsStyle) == true)
                    {
                        settingsMenu.ShowAsContext();
                    }
                }
            }
            GUILayout.EndHorizontal();

            CustomGUI.Splitter(new Color(0.7f, 0.7f, 0.7f, 0.2f));

            GUILayout.BeginVertical(FlowSystemEditorWindow.defaultSkin.box);
            {
                if (addon != null && addon.InstallationNeeded() == true)
                {
                    if (GUILayoutExt.LargeButton("Install", 40f, 200f) == true)
                    {
                        addon.Install();
                    }
                }
                else
                {
                    onGUI();
                }
            }
            GUILayout.EndVertical();
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var aspectFromProp = property.FindPropertyRelative("aspectFrom");
            var aspectToProp   = property.FindPropertyRelative("aspectTo");
            var aspectFrom     = aspectFromProp.vector2Value;
            var aspectTo       = aspectToProp.vector2Value;

            var offset      = EditorGUI.indentLevel * 24f;
            var defPosition = position;
            var aspectRect  = new Rect(position.x + offset, position.y, EditorGUIUtility.labelWidth, position.height);

            var fillColor   = new Color(0.5f, 0.3f, 0.3f, 0.2f);
            var borderColor = fillColor;

            borderColor.a = 0.5f;

            position.x     += EditorGUIUtility.labelWidth;
            position.width -= EditorGUIUtility.labelWidth;

            GUILayoutExt.DrawRect(position, fillColor);
            GUILayoutExt.DrawBoxNotFilled(position, 1f, borderColor);

            var padding = 4f;
            var size    = position.height - padding * 2f;
            var rect    = new Rect(position.x + position.width * 0.5f - size * 0.5f, position.y + padding, size, size);

            GUILayoutExt.DrawRect(rect, fillColor);

            var fromRect = new Rect(0f, 0f, aspectFrom.x, aspectFrom.y);
            var toRect   = new Rect(0f, 0f, aspectTo.x, aspectTo.y);

            fromRect = EditorHelpers.FitRect(fromRect, rect);
            toRect   = EditorHelpers.FitRect(toRect, rect);
            GUILayoutExt.DrawBoxNotFilled(fromRect, 2f, new Color(0.4f, 0.4f, 1f, 0.6f));
            GUILayoutExt.DrawBoxNotFilled(toRect, 2f, new Color(1f, 0.4f, 1f, 0.6f));

            {
                GUILayout.BeginArea(aspectRect);
                //GUILayoutExt.Box(4f, 4f, () => {

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(defPosition.x + 10f);

                    GUILayout.BeginVertical();
                    {
                        GUILayout.Label("From");
                        GUILayout.BeginHorizontal();
                        aspectFrom.x = EditorGUILayout.FloatField(aspectFrom.x);
                        GUILayout.Label(":", GUILayout.Width(10f));
                        aspectFrom.y = EditorGUILayout.FloatField(aspectFrom.y);
                        aspectFromProp.vector2Value = aspectFrom;
                        GUILayout.EndHorizontal();

                        //}, GUIStyle.none);
                        //GUILayoutExt.Box(4f, 4f, () => {

                        GUILayout.Label("To");
                        GUILayout.BeginHorizontal();
                        aspectTo.x = EditorGUILayout.FloatField(aspectTo.x);
                        GUILayout.Label(":", GUILayout.Width(10f));
                        aspectTo.y = EditorGUILayout.FloatField(aspectTo.y);
                        aspectToProp.vector2Value = aspectTo;
                        GUILayout.EndHorizontal();
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();

                //}, GUIStyle.none);
                GUILayout.EndArea();
            }
        }
コード例 #18
0
        public static SerializedProperty OnItemDraw(LayoutWindowType window, List <SerializedProperty> items, List <UnityEngine.UI.Windows.Types.Layout.Component> components, bool draw, bool withParameters, Rect rect, SerializedProperty item, out float elementHeight)
        {
            if (LayoutSettingsEditor.componentParametersSearched == null ||
                LayoutSettingsEditor.componentParametersSearched.Count != components.Count)
            {
                LayoutSettingsEditor.componentParametersSearched = new List <bool>();
                for (int i = 0; i < components.Count; ++i)
                {
                    LayoutSettingsEditor.componentParametersSearched.Add(false);
                }
            }

            var startY       = rect.y + 2f;
            var offset       = 2f;
            var heightOffset = 20f;

            elementHeight = 0f;
            rect.y        = startY;

            var index = items.IndexOf(item);

            if (index < 0 || index >= items.Count)
            {
                return(item);
            }
            if (item == null)
            {
                return(null);
            }

            var descr        = item.FindPropertyRelative("description");
            var tag          = item.FindPropertyRelative("tag");
            var component    = item.FindPropertyRelative("component");
            var sortingOrder = item.FindPropertyRelative("sortingOrder");

            if (descr == null ||
                tag == null ||
                component == null ||
                sortingOrder == null)
            {
                return(item);
            }

            var parameters = item.FindPropertyRelative("componentParameters");
            var componentParametersEditor = components[index].componentParametersEditor;

            if (rect.Contains(Event.current.mousePosition) == true)
            {
                //WindowLayoutElement.waitForComponentConnectionElementTemp = window.GetCurrentLayout().layout.GetRootByTag((LayoutTag)tag.enumValueIndex);
                LayoutSettingsEditor.selectedTagIndex = tag.enumValueIndex;
            }

            if (LayoutSettingsEditor.selectedTagIndex == tag.enumValueIndex)
            {
                var _offset = 4f;
                var newRect = new Rect(rect.x - _offset, rect.y - _offset, rect.width + _offset * 2f, rect.height + _offset);

                LayoutSettingsEditor.selectedTagRect = newRect;

                var oldColor = GUI.color;
                GUI.color = new Color(0f, 1f, 0f, 0.2f);
                GUI.Box(newRect, string.Empty, EditorStyles.textArea);
                GUI.Box(newRect, string.Empty, EditorStyles.popup);
                GUI.color = oldColor;
            }

            /*if (active == true && focused == true) {
             *
             *      //var window = (property.serializedObject.targetObject as LayoutWindowType);
             *      WindowLayoutElement.waitForComponentConnectionElementTemp = window.layout.layout.GetRootByTag((LayoutTag)tag.enumValueIndex);
             *      WindowLayoutElement.waitForComponentConnectionTemp = true;
             *
             * } else {
             *
             *      if (active == true) {
             *
             *              WindowLayoutElement.waitForComponentConnectionElementTemp = null;
             *              WindowLayoutElement.waitForComponentConnectionTemp = false;
             *
             *      }
             *
             * }*/

            var title  = "Description";
            var height = EditorGUI.GetPropertyHeight(descr, new GUIContent(title)) + offset;

            rect.height = height - offset;
            if (draw == true)
            {
                EditorGUI.LabelField(rect, descr.stringValue, EditorStyles.boldLabel);
                EditorGUI.LabelField(rect, tag.enumNames[tag.enumValueIndex], ME.Utilities.CacheStyle("WindowLayoutProperty.Styles.tag", "tag", (name) => {
                    var style       = new GUIStyle(EditorStyles.boldLabel);
                    style.alignment = TextAnchor.MiddleRight;
                    return(style);
                }));
            }

            title       = "Component";
            rect.y     += height;
            height      = EditorGUI.GetPropertyHeight(component, new GUIContent(title)) + offset;
            rect.height = height - offset;

            {
                var oldComponent = component.objectReferenceValue;

                var nRect       = rect;
                var buttonWidth = 30f;
                nRect.width -= buttonWidth;
                if (draw == true)
                {
                    EditorGUI.PropertyField(nRect, component, new GUIContent(title), true);
                }

                //Debug.Log(oldComponent + " == " + component.objectReferenceValue + " :: " + (oldComponent == component.objectReferenceValue));
                var newComponent = component.objectReferenceValue;
                if (oldComponent != newComponent)
                {
                    //Debug.Log("NEW COMP: " + newComponent);
                    parameters.objectReferenceValue = components[index].OnComponentChanged(window, newComponent as WindowComponent);
                    //Debug.Log("NEW COMP: " + parameters.objectReferenceValue);
                    components[index].componentParametersEditor = null;
                    item.serializedObject.ApplyModifiedPropertiesWithoutUndo();

                    UnityEditor.EditorUtility.SetDirty(window);
                }

                if (newComponent == null && components[index].componentResource.id != 0)
                {
                    components[index].OnComponentChanged(window, null);
                    components[index].componentParametersEditor = null;
                    item.serializedObject.ApplyModifiedPropertiesWithoutUndo();

                    UnityEditor.EditorUtility.SetDirty(window);
                }

                nRect.x    += nRect.width;
                nRect.width = buttonWidth;
                if (draw == true)
                {
                    var i = index;
                    GUILayoutExt.DrawComponentChooser(nRect, window.gameObject, components[i].component, (elem) => {
                        if (component.objectReferenceValue != elem)
                        {
                            component.objectReferenceValue = elem;
                            var c = component.objectReferenceValue;
                            parameters.objectReferenceValue         = components[i].OnComponentChanged(window, c as WindowComponent);
                            components[i].componentParametersEditor = null;
                            item.serializedObject.ApplyModifiedPropertiesWithoutUndo();

                            UnityEditor.EditorUtility.SetDirty(window);
                        }
                    });
                }
            }

            title       = "Sorting Order";
            rect.y     += height;
            height      = EditorGUI.GetPropertyHeight(sortingOrder, new GUIContent(title)) + offset;
            rect.height = height - offset;
            if (draw == true)
            {
                var oldValue = sortingOrder.intValue;
                EditorGUI.PropertyField(rect, sortingOrder, new GUIContent(title), true);
                if (sortingOrder.intValue < 0)
                {
                    sortingOrder.intValue = 0;
                }
                if (oldValue != sortingOrder.intValue)
                {
                    item.serializedObject.ApplyModifiedPropertiesWithoutUndo();
                    UnityEditor.EditorUtility.SetDirty(window);
                }
            }

            if (parameters.objectReferenceValue == null && LayoutSettingsEditor.componentParametersSearched[index] == false)
            {
                components[index].OnComponentChanged(window, components[index].component);
                LayoutSettingsEditor.componentParametersSearched[index] = true;

                UnityEditor.EditorUtility.SetDirty(window);
            }

            if (withParameters == true)
            {
                var editor = componentParametersEditor;
                if (editor == null && parameters.objectReferenceValue != null)
                {
                    var e = Editor.CreateEditor(parameters.objectReferenceValue) as IParametersEditor;
                    components[index].componentParametersEditor = componentParametersEditor = e;
                }

                if (editor != null)
                {
                    title   = "Parameters";
                    rect.y += height;
                    var _height = height = 16f;
                    rect.height = height - offset;
                    var editorFoldout = item.FindPropertyRelative("editorParametersFoldout");
                    if (draw == true)
                    {
                        ++EditorGUI.indentLevel;
                        var newValue = EditorGUI.Foldout(rect, editorFoldout.boolValue, new GUIContent(title));
                        if (newValue != editorFoldout.boolValue)
                        {
                            editorFoldout.boolValue = newValue;
                            editorFoldout.serializedObject.ApplyModifiedProperties();
                        }
                        --EditorGUI.indentLevel;
                    }

                    if (editorFoldout.boolValue == true)
                    {
                        rect.y += height;
                        height  = 0f;

                        if (draw == true)
                        {
                            ++EditorGUI.indentLevel;
                            editor.OnParametersGUI(rect);
                            --EditorGUI.indentLevel;

                            //parameters.objectReferenceValue = editor.target;
                            //editor.serializedObject.ApplyModifiedPropertiesWithoutUndo();
                        }

                        height      = editor.GetHeight() + offset;
                        rect.y     += height - _height;
                        rect.height = height - offset;
                    }
                }
            }

            elementHeight = (rect.y - startY) + heightOffset;

            return(item);
        }
コード例 #19
0
        public void DrawProjectSelector()
        {
            var darkLabel = ME.Utilities.CacheStyle("FlowEditor.DataSelection.Styles", "DarkLabel", (name) => {
                var style       = new GUIStyle(FlowSystemEditorWindow.defaultSkin.FindStyle(name));
                style.alignment = TextAnchor.MiddleLeft;
                return(style);
            });

            var headerStyle = new GUIStyle("LODLevelNotifyText");

            headerStyle.normal.textColor = EditorGUIUtility.isProSkin == true ? Color.white : Color.black;
            headerStyle.fontSize         = 18;
            headerStyle.alignment        = TextAnchor.MiddleCenter;

            GUILayoutExt.LabelWithShadow(string.Format("UI.Windows Flow Extension v{0}", VersionInfo.BUNDLE_VERSION), headerStyle);

            GUILayout.Space(10f);

            GUILayout.Label("Open one of your projects:", darkLabel);

            var backStyle = new GUIStyle("sv_iconselector_labelselection");

            var skin = GUI.skin;

            GUI.skin = FlowSystemEditorWindow.defaultSkin;
            this.dataSelectionScroll = GUILayout.BeginScrollView(this.dataSelectionScroll, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, backStyle);
            {
                GUI.skin = skin;

                this.scannedData = EditorUtilities.GetAssetsOfType <FlowData>(useCache: false);

                if (this.scannedData.Length == 0)
                {
                    var center = new GUIStyle(darkLabel);
                    center.fixedWidth    = 0f;
                    center.fixedHeight   = 0f;
                    center.stretchWidth  = true;
                    center.stretchHeight = true;
                    center.alignment     = TextAnchor.MiddleCenter;
                    center.wordWrap      = true;

                    GUILayout.Label("No projects were found. Create a new one by Right-Click on any folder in Project View and choose `Create->UI.Windows->Flow->Graph` option.", center);
                }
                else
                {
                    var buttonStyle = new GUIStyle("flow node 1 on");
                    buttonStyle.alignment        = TextAnchor.MiddleLeft;
                    buttonStyle.padding          = new RectOffset(15, 15, 15, 15);
                    buttonStyle.margin           = new RectOffset(2, 2, 2, 2);
                    buttonStyle.overflow         = new RectOffset();
                    buttonStyle.contentOffset    = Vector2.zero;
                    buttonStyle.fixedWidth       = 0f;
                    buttonStyle.fixedHeight      = 0f;
                    buttonStyle.stretchWidth     = true;
                    buttonStyle.stretchHeight    = false;
                    buttonStyle.normal.textColor = Color.white;
                    buttonStyle.fontSize         = 12;
                    buttonStyle.richText         = true;

                    var buttonStyleSelected = new GUIStyle(buttonStyle);
                    buttonStyle.normal.background = null;
                    buttonStyle.normal.textColor  = Color.black;

                    this.scannedData = this.scannedData.OrderByDescending((data) => (data != null ? data.lastModifiedUnix : 0)).ToArray();

                    foreach (var data in this.scannedData)
                    {
                        if (data == null)
                        {
                            continue;
                        }

                        var isSelected = (this.cachedData == data);

                        var title = data.name + "\n";
                        title += string.Format("<color={1}><size=10>Modified: {0}</size></color>\n", data.lastModified, isSelected == true ? "#ccc" : "#999");
                        title += string.Format("<color={1}><size=10>Version: {0}</size></color>", data.version, isSelected == true ? "#ccc" : "#999");

                        if (GUILayout.Button(title, isSelected ? buttonStyleSelected : buttonStyle) == true)
                        {
                            this.cachedData = data;
                        }
                    }
                }

                GUILayout.FlexibleSpace();
            }
            GUILayout.EndScrollView();

            GUILayout.Space(10f);

            GUILayout.Label("Or select the project file:", darkLabel);

            this.cachedData = GUILayoutExt.ObjectField <FlowData>(this.cachedData, false, FlowSystemEditorWindow.defaultSkin.FindStyle("ObjectField"));

            CustomGUI.Splitter();

            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Create Project...", FlowSystemEditorWindow.defaultSkin.button, GUILayout.Width(150f), GUILayout.Height(40f)) == true)
                {
                    this.state = State.NewProject;
                }

                GUILayout.FlexibleSpace();

                var oldState = GUI.enabled;
                GUI.enabled = oldState && this.cachedData != null;

                if (this.cachedData != null && this.cachedData.version < VersionInfo.BUNDLE_VERSION)
                {
                    // Need to upgrade

                    if (GUILayout.Button("Upgrade to " + VersionInfo.BUNDLE_VERSION, FlowSystemEditorWindow.defaultSkin.button, GUILayout.Width(150f), GUILayout.Height(40f)) == true)
                    {
                        FlowUpdater.Run(this.cachedData);
                    }
                }
                else if (this.cachedData != null && this.cachedData.version > VersionInfo.BUNDLE_VERSION)
                {
                    var info = string.Format(
                        "Selected Project has `{0}` version while UI.Windows System has `{1}` version number. Click here to download a new version.",
                        this.cachedData.version,
                        VersionInfo.BUNDLE_VERSION
                        );

                    if (GUILayout.Button(new GUIContent(info, new GUIStyle("CN EntryWarn").normal.background), EditorStyles.helpBox, GUILayout.Height(40f)) == true)
                    {
                        Application.OpenURL(VersionInfo.DOWNLOAD_LINK);
                    }
                }
                else
                {
                    if (GUILayout.Button("Open", FlowSystemEditorWindow.defaultSkin.button, GUILayout.Width(100f), GUILayout.Height(40f)) == true)
                    {
                        FlowSystem.SetData(this.cachedData);
                    }
                }

                GUI.enabled = oldState;
            }
            GUILayout.EndHorizontal();
        }
コード例 #20
0
        public static void DrawLayout(int selectedIndexAspect, int selectedIndexInner, int selectedType, System.Action <int, int, int> onSet, ref Vector2 tabsScrollPosition, WindowLayout windowLayout, Rect r, UnityEngine.UI.Windows.WindowTypes.LayoutWindowType drawComponents)
        {
            var offset = 20f;
            var aspect = 4f / 3f;

            DeviceInfo.OrientationData orienData  = default;
            DeviceInfo.ScreenData      screenData = default;
            if (Selection.objects.Length == 1)
            {
                if (WindowLayoutUtilities.loadedDevices.Count == 0)
                {
                    var devices             = new List <DeviceInfo>();
                    var deviceDirectoryPath = System.IO.Path.GetFullPath(System.IO.Path.Combine("Packages", "com.unity.device-simulator", ".DeviceDefinitions"));
                    if (UnityEngine.Windows.Directory.Exists(deviceDirectoryPath) == true)
                    {
                        var deviceDirectory   = new System.IO.DirectoryInfo(deviceDirectoryPath);
                        var deviceDefinitions = deviceDirectory.GetFiles("*.device.json");
                        foreach (var deviceDefinition in deviceDefinitions)
                        {
                            string deviceFileText;
                            using (System.IO.StreamReader sr = deviceDefinition.OpenText()) {
                                deviceFileText = sr.ReadToEnd();
                            }

                            var deviceInfo = JsonUtility.FromJson <DeviceInfo>(deviceFileText);
                            devices.Add(deviceInfo);
                        }
                    }

                    WindowLayoutUtilities.loadedDevices = devices;
                }

                GUILayout.BeginHorizontal();

                var selectedName = "Default Aspects";
                if (selectedType == 1)
                {
                    var dInfo = WindowLayoutUtilities.loadedDevices[selectedIndexAspect];
                    selectedName = dInfo.friendlyName;
                }

                if (WindowLayoutUtilities.loadedDevices.Count > 0)
                {
                    if (GUILayout.Button(selectedName, EditorStyles.toolbarDropDown) == true)
                    {
                        var popup = new Popup(title: "Devices", size: new Vector2(200f, 250f));
                        popup.autoClose  = true;
                        popup.autoHeight = false;
                        popup.Item("Default Aspects", () => { onSet.Invoke(0, 0, 0); }, order: -1);

                        for (var i = 0; i < WindowLayoutUtilities.loadedDevices.Count; ++i)
                        {
                            var idx        = i;
                            var deviceInfo = WindowLayoutUtilities.loadedDevices[i];
                            var screens    = deviceInfo.Screens ?? deviceInfo.screens;
                            if (screens != null)
                            {
                                popup.Item(deviceInfo.friendlyName, () => { onSet.Invoke(1, idx, 0); }, order: idx);
                            }
                        }

                        popup.Show();
                    }
                }

                if (selectedType == 0)
                {
                    var items = new Item[] {
                        new Item()
                        {
                            name = "4:3", value = 4f / 3f
                        },
                        new Item()
                        {
                            name = "16:9", value = 16f / 9f
                        },
                        new Item()
                        {
                            name = "16:10", value = 16f / 10f
                        },
                        new Item()
                        {
                            name = "5:4", value = 5f / 4f
                        },
                        new Item()
                        {
                            name = "2:1", value = 2f / 1f
                        },

                        new Item()
                        {
                            name = "3:4", value = 3f / 4f
                        },
                        new Item()
                        {
                            name = "9:16", value = 9f / 16f
                        },
                        new Item()
                        {
                            name = "10:16", value = 10f / 16f
                        },
                        new Item()
                        {
                            name = "4:5", value = 4f / 5f
                        },
                        new Item()
                        {
                            name = "1:2", value = 1f / 2f
                        },
                    };

                    var tabs = items.Select(x => new GUITab(x.name, null)).ToArray();
                    selectedIndexAspect = GUILayoutExt.DrawTabs(selectedIndexAspect, ref tabsScrollPosition, tabs);
                    aspect = items[selectedIndexAspect].value;
                }
                else if (selectedType == 1)
                {
                    var deviceInfo = WindowLayoutUtilities.loadedDevices[selectedIndexAspect];
                    var screens    = deviceInfo.Screens ?? deviceInfo.screens;
                    var items      = new Item[4];
                    for (int i = 0; i < screens.Length; ++i)
                    {
                        var oris = screens[i].orientations;
                        for (int j = 0; j < oris.Length; ++j)
                        {
                            if (oris[j].orientation == ScreenOrientation.LandscapeRight)
                            {
                                var hData = screens[i];
                                var w     = hData.width;
                                hData.width  = hData.height;
                                hData.height = w;

                                items[0] = new Item()
                                {
                                    name       = "Landscape Right",
                                    value      = hData.width / (float)hData.height,
                                    data       = oris[j],
                                    screenData = hData
                                };
                            }
                            else if (oris[j].orientation == ScreenOrientation.Landscape ||
                                     oris[j].orientation == ScreenOrientation.LandscapeLeft)
                            {
                                var hData = screens[i];
                                var w     = hData.width;
                                hData.width  = hData.height;
                                hData.height = w;

                                items[1] = new Item()
                                {
                                    name       = "Landscape Left",
                                    value      = hData.width / (float)hData.height,
                                    data       = oris[j],
                                    screenData = hData
                                };
                            }
                            else if (oris[j].orientation == ScreenOrientation.Portrait)
                            {
                                items[2] = new Item()
                                {
                                    name       = "Portrait Up",
                                    value      = screens[i].width / (float)screens[i].height,
                                    data       = oris[j],
                                    screenData = screens[i]
                                };
                            }
                            else if (oris[j].orientation == ScreenOrientation.PortraitUpsideDown)
                            {
                                items[3] = new Item()
                                {
                                    name       = "Portrait Down",
                                    value      = screens[i].width / (float)screens[i].height,
                                    data       = oris[j],
                                    screenData = screens[i]
                                };
                            }
                        }
                    }

                    var tabs = items.Select(x => new GUITab(x.name, null)).ToArray();
                    selectedIndexInner = GUILayoutExt.DrawTabs(selectedIndexInner, ref tabsScrollPosition, tabs);
                    aspect             = items[selectedIndexInner].value;
                    orienData          = items[selectedIndexInner].data;
                    screenData         = items[selectedIndexInner].screenData;
                }

                GUILayout.EndHorizontal();
            }
            else
            {
                offset = 0f;
            }

            var used = new HashSet <WindowLayout>();

            WindowLayoutUtilities.DrawLayout(aspect, windowLayout, r, offset, used, screenData, orienData, drawComponents);

            onSet.Invoke(selectedType, selectedIndexAspect, selectedIndexInner);
        }
コード例 #21
0
        public static bool DrawLayout(float aspect, WindowLayout windowLayout, Rect r, float offset = 20f, HashSet <WindowLayout> used = null, DeviceInfo.ScreenData screenData = default, DeviceInfo.OrientationData orientationData = default, UnityEngine.UI.Windows.WindowTypes.LayoutWindowType drawComponents = null)
        {
            if (used.Contains(windowLayout) == true)
            {
                return(false);
            }
            used.Add(windowLayout);

            var rSource = r;

            var rectOffset = r;

            if (offset > 0f)
            {
                rectOffset.x      += offset;
                rectOffset.y      += offset;
                rectOffset.height -= offset * 2f;
                rectOffset.width  -= offset * 2f;

                var tWidth = rectOffset.height * aspect;
                if (tWidth > rectOffset.width)
                {
                    rectOffset.y     += rectOffset.height * 0.5f;
                    rectOffset.height = rectOffset.width / aspect;
                    rectOffset.y     -= rectOffset.height * 0.5f;
                }
                else
                {
                    rectOffset.x    += rectOffset.width * 0.5f;
                    rectOffset.width = rectOffset.height * aspect;
                    rectOffset.x    -= rectOffset.width * 0.5f;
                }
            }
            else
            {
                GUILayoutExt.DrawRect(rectOffset, new Color(0f, 0f, 0f, 0.4f));
            }

            GUILayoutExt.DrawRect(rectOffset, new Color(0f, 0f, 0f, 0.2f));
            GUILayoutExt.DrawBoxNotFilled(rectOffset, 1f, new Color(0.7f, 0.7f, 0.3f, 0.5f));

            GUI.BeginClip(r);

            var resolution = windowLayout.canvasScaler.referenceResolution;

            /*windowLayout.rectTransform.anchoredPosition = new Vector2(r.x, r.y);
             * windowLayout.rectTransform.sizeDelta = new Vector2(r.width, r.height);
             * windowLayout.rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
             * windowLayout.rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
             * windowLayout.rectTransform.pivot = new Vector2(0.5f, 0.5f);
             * windowLayout.rectTransform.localRotation = Quaternion.identity;
             * windowLayout.rectTransform.localScale = Vector3.one;*/

            r = rectOffset;

            {
                if (r.width > 0f && r.height > 0f)
                {
                    Vector2 screenSize = new Vector2(r.width, r.height);

                    var   sizeDelta   = Vector2.zero;
                    float scaleFactor = 0;
                    switch (windowLayout.canvasScaler.screenMatchMode)
                    {
                    case UnityEngine.UI.CanvasScaler.ScreenMatchMode.MatchWidthOrHeight: {
                        const float kLogBase = 2;
                        // We take the log of the relative width and height before taking the average.
                        // Then we transform it back in the original space.
                        // the reason to transform in and out of logarithmic space is to have better behavior.
                        // If one axis has twice resolution and the other has half, it should even out if widthOrHeight value is at 0.5.
                        // In normal space the average would be (0.5 + 2) / 2 = 1.25
                        // In logarithmic space the average is (-1 + 1) / 2 = 0
                        float logWidth           = Mathf.Log(screenSize.x / windowLayout.canvasScaler.referenceResolution.x, kLogBase);
                        float logHeight          = Mathf.Log(screenSize.y / windowLayout.canvasScaler.referenceResolution.y, kLogBase);
                        float logWeightedAverage = Mathf.Lerp(logWidth, logHeight, windowLayout.canvasScaler.matchWidthOrHeight);
                        scaleFactor = Mathf.Pow(kLogBase, logWeightedAverage);
                        break;
                    }

                    case UnityEngine.UI.CanvasScaler.ScreenMatchMode.Expand: {
                        scaleFactor = Mathf.Min(screenSize.x / windowLayout.canvasScaler.referenceResolution.x, screenSize.y / windowLayout.canvasScaler.referenceResolution.y);
                        break;
                    }

                    case UnityEngine.UI.CanvasScaler.ScreenMatchMode.Shrink: {
                        scaleFactor = Mathf.Max(screenSize.x / windowLayout.canvasScaler.referenceResolution.x, screenSize.y / windowLayout.canvasScaler.referenceResolution.y);
                        break;
                    }
                    }

                    if (scaleFactor > 0f)
                    {
                        sizeDelta = new Vector2(screenSize.x / scaleFactor, screenSize.y / scaleFactor);
                        windowLayout.rectTransform.sizeDelta  = sizeDelta;
                        windowLayout.rectTransform.pivot      = new Vector2(0.5f, 0.5f);
                        windowLayout.rectTransform.localScale = Vector3.one;
                        resolution = windowLayout.rectTransform.sizeDelta;
                    }
                }
            }

            var labelStyle = new GUIStyle(EditorStyles.label);

            labelStyle.alignment = TextAnchor.LowerLeft;

            var isHighlighted    = false;
            var highlightedIndex = -1;
            var highlightedRect  = Rect.zero;

            for (int i = 0; i < windowLayout.layoutElements.Length; ++i)
            {
                var element = windowLayout.layoutElements[i];
                if (element == null)
                {
                    windowLayout.ValidateEditor();
                    return(false);
                }

                var rect = WindowLayoutUtilities.GetRect(windowLayout.rectTransform, element.rectTransform, r, resolution, offset > 0f);
                if (rect.Contains(Event.current.mousePosition) == true)
                {
                    if (highlightedIndex >= 0 && highlightedRect.width * highlightedRect.height < rect.width * rect.height)
                    {
                        continue;
                    }

                    highlightedIndex = i;
                    highlightedRect  = rect;
                    isHighlighted    = true;
                }
            }

            var hasInnerHighlight = false;

            for (int i = 0; i < windowLayout.layoutElements.Length; ++i)
            {
                var element = windowLayout.layoutElements[i];
                var rect    = WindowLayoutUtilities.GetRect(windowLayout.rectTransform, element.rectTransform, r, resolution, offset > 0f);

                using (new GUILayoutExt.GUIColorUsing(highlightedIndex < 0 || i == highlightedIndex ? Color.white : new Color(1f, 1f, 1f, 0.6f))) {
                    if (drawComponents != null)
                    {
                        drawComponents.layouts.GetActive().GetLayoutComponentItemByTagId(element.tagId, windowLayout, out var componentItem);
                        var comp = componentItem.component.GetEditorRef <WindowComponent>();
                        if (comp != null)
                        {
                            WindowLayoutUtilities.DrawComponent(rect, comp, componentItem.localTag);
                        }

                        WindowSystemSidePropertyDrawer.DrawLayoutMode(rect, element.rectTransform);
                    }
                    else
                    {
                        WindowSystemSidePropertyDrawer.DrawLayoutMode(rect, element.rectTransform);
                    }
                }

                if (element.innerLayout != null)
                {
                    hasInnerHighlight = WindowLayoutUtilities.DrawLayout(aspect, element.innerLayout, rect, offset: 0f, used: used, drawComponents: drawComponents);
                    //WindowLayoutUtilities.DrawLayoutElements(highlightedIndex, rect, resolution, element.innerLayout, used);
                }
            }

            if (highlightedIndex >= 0 && hasInnerHighlight == false)
            {
                var element = windowLayout.layoutElements[highlightedIndex];
                var rect    = highlightedRect;

                var padding = 6f;
                var color   = new Color(1f, 1f, 0f, 0.5f);
                var content = new GUIContent(element.name);
                GUI.Label(new Rect(padding, 0f, rSource.width, rSource.height - padding), content, labelStyle);
                var labelWidth = labelStyle.CalcSize(content).x + 10f;
                GUILayoutExt.DrawRect(new Rect(padding, rSource.height - 1f - padding, labelWidth, 1f), color);
                var p1 = new Vector3(labelWidth + padding, rSource.height - 1f - padding);
                var p2 = new Vector3(rect.x, rect.y);
                Handles.color = color;
                Handles.DrawLine(p1, p2);

                GUILayoutExt.DrawBoxNotFilled(rect, 1f, new Color(1f, 1f, 1f, 0.2f));
            }

            GUI.EndClip();

            if (offset > 0f)
            {
                if (orientationData.cutouts != null)
                {
                    var safeArea = new Rect(orientationData.safeArea);
                    safeArea = WindowLayoutUtilities.GetRectYSwapScaled(safeArea, new Vector2(screenData.width, screenData.height), r, rectOffset);
                    GUILayoutExt.DrawBoxNotFilled(safeArea, 1f, Color.magenta);

                    foreach (var rSafe in orientationData.cutouts)
                    {
                        var rSafeRect = WindowLayoutUtilities.GetRectYSwapScaled(rSafe, new Vector2(screenData.width, screenData.height), r, rectOffset);
                        GUI.BeginClip(rSafeRect);

                        if (rSafeRect.width < rSafeRect.height)
                        {
                            for (float step = -rSafeRect.height; step < rSafeRect.height; step += 5f)
                            {
                                var v1 = new Vector3(0f, step);
                                var v2 = new Vector3(rSafeRect.width, step + rSafeRect.width);
                                Handles.color = Color.yellow;
                                Handles.DrawAAPolyLine(2f, v1, v2);
                            }
                        }
                        else
                        {
                            for (float step = -rSafeRect.width; step < rSafeRect.width; step += 5f)
                            {
                                var v1 = new Vector3(step, 0f);
                                var v2 = new Vector3(step + rSafeRect.height, rSafeRect.height);
                                Handles.color = Color.yellow;
                                Handles.DrawAAPolyLine(2f, v1, v2);
                            }
                        }

                        GUI.EndClip();
                        GUILayoutExt.DrawBoxNotFilled(rSafeRect, 1f, Color.yellow);
                    }
                }
            }

            return(isHighlighted);
        }
コード例 #22
0
        public static void DrawList(ref ReorderableList reorderableList, string label, ClipType clipType)
        {
            if (reorderableList == null)
            {
                var objectField = ME.Utilities.CacheStyle("UI.Windows.ObjectFieldSmall", "ObjectFieldSmall", (name) => FlowSystemEditorWindow.defaultSkin.FindStyle(name));
                var textField   = ME.Utilities.CacheStyle("UI.Windows.TextFieldSmall", "TextFieldSmall", (name) => FlowSystemEditorWindow.defaultSkin.FindStyle(name));

                var audioSources = FlowSystem.GetAudioItems(clipType);
                if (audioSources != null)
                {
                    var sources = FlowSystem.GetAudioItems(clipType);

                    reorderableList = new ReorderableList(audioSources, typeof(UnityEngine.UI.Windows.Audio.Data.State), true, true, true, true);

                    reorderableList.onAddCallback += (list) => {
                        FlowSystem.AddAudioItem(clipType, new UnityEngine.UI.Windows.Audio.Data.State());
                        FlowSystem.SetDirty();
                    };
                    reorderableList.onRemoveCallback += (list) => {
                        var index = list.index;
                        if (index < 0 || index >= sources.Count)
                        {
                            return;
                        }

                        FlowSystem.RemoveAudioItem(clipType, (list.list[index] as UnityEngine.UI.Windows.Audio.Data.State).key);
                        FlowSystem.SetDirty();
                    };
                    reorderableList.drawHeaderCallback += (rect) => {
                        const float widthNumber   = 20f;
                        const float widthCategory = 70f;

                        rect.x += 14f;

                        var labelRect = new Rect(rect);
                        labelRect.width = widthNumber;

                        GUI.Label(labelRect, "#");

                        var categoryRect = new Rect(rect);
                        categoryRect.x    += widthNumber;
                        categoryRect.width = widthCategory;

                        GUI.Label(categoryRect, "Category");

                        rect.x     += widthNumber + widthCategory;
                        rect.width -= widthNumber + widthCategory;

                        GUI.Label(rect, label);
                    };
                    reorderableList.drawElementCallback += (rect, index, active, focused) => {
                        const float widthNumber   = 20f;
                        const float widthCategory = 70f;

                        if (index < 0 || index >= sources.Count)
                        {
                            return;
                        }

                        var item = sources[index];

                        var labelRect = new Rect(rect);
                        labelRect.width = widthNumber;

                        GUI.Label(labelRect, item.key.ToString(), EditorStyles.miniLabel);

                        var categoryRect = new Rect(rect);
                        categoryRect.x    += widthNumber;
                        categoryRect.width = widthCategory;

                        item.category = EditorGUI.TextField(categoryRect, item.category, textField);

                        rect.x     += widthNumber + widthCategory;
                        rect.width -= widthNumber + widthCategory;

                        var clip = GUILayoutExt.ObjectField <AudioClip>(rect, item.clip, false, objectField);
                        if (clip != item.clip)
                        {
                            item.clip = clip;
                            FlowSystem.SetDirty();
                        }
                    };
                }
            }

            if (reorderableList != null)
            {
                reorderableList.DoLayoutList();
            }
        }
コード例 #23
0
        public override void OnGUI()
        {
            if (Layout.styles == null)
            {
                Layout.styles = new Styles();
            }

            if (this.opened == true)
            {
                const float settingsWidth = 320f;
                const float listHeight    = 200f;
                const float padding       = 5f;
                const float closeSize     = 30f;
                const float scrollWidth   = 16f;

                var rect            = new Rect(0f, -OFFSET, Screen.width, Screen.height - OFFSET).PixelPerfect();
                var rectContent     = new Rect(rect.x + MARGIN + settingsWidth + padding, rect.y + MARGIN, rect.width - MARGIN * 2f - padding - settingsWidth, rect.height - MARGIN * 2f - FlowSystemEditorWindow.TOOLBAR_HEIGHT).PixelPerfect();
                var rectList        = new Rect(MARGIN, rect.y + MARGIN, settingsWidth, listHeight - padding).PixelPerfect();
                var rectSettings    = new Rect(MARGIN, rect.y + MARGIN + listHeight, settingsWidth, rect.height - MARGIN * 2f - FlowSystemEditorWindow.TOOLBAR_HEIGHT - listHeight).PixelPerfect();
                var rectCloseButton = new Rect(rectContent.x + rectContent.width, rectContent.y - closeSize * 0.5f, closeSize, closeSize).PixelPerfect();

                GUI.Box(new Rect(rect.x + MARGIN, rect.y + MARGIN, rect.width - MARGIN * 2f, rect.height - MARGIN * 2f - FlowSystemEditorWindow.TOOLBAR_HEIGHT).PixelPerfect(), string.Empty, Layout.styles.layoutBack);
                GUI.Box(rect, string.Empty, Layout.styles.backLock);
                GUI.Box(new Rect(0f, 0f, Screen.width, Screen.height).PixelPerfect(), string.Empty, Layout.styles.dropShadow);
                GUI.Box(rectList, string.Empty, Layout.styles.content);
                GUI.Box(rectSettings, string.Empty, Layout.styles.content);
                GUI.Box(rectContent, string.Empty, Layout.styles.contentScreen);

                GUI.BeginGroup(rectSettings);
                {
                    if (this.component != null)
                    {
                        const float offsetTop = 50f;

                        var viewRect   = new Rect(0f, 0f, rectSettings.width, 0f).PixelPerfect();
                        var scrollView = new Rect(0f, 0f + offsetTop, rectSettings.width, rectSettings.height - offsetTop).PixelPerfect();

                        System.Action <WindowComponent> onChange = (WindowComponent component) => {
                            //Debug.Log(component + "!=" + this.component.component);
                            if (component != this.component.component)
                            {
                                this.component.componentParametersEditor = null;
                                this.component.componentParameters       = this.component.OnComponentChanged(this.screen, component);

                                if (this.component.componentParameters != null)
                                {
                                    var e = Editor.CreateEditor(this.component.componentParameters) as IParametersEditor;
                                    this.component.componentParametersEditor = e;
                                }

                                UnityEditor.EditorUtility.SetDirty(this.screen);
                            }
                        };

                        var c = EditorGUI.ObjectField(new Rect(5f, 5f, viewRect.width - 40f - 5f * 2f, 16f).PixelPerfect(), this.component.component, typeof(WindowComponent), allowSceneObjects: false) as WindowComponent;
                        if (c != this.component.component)
                        {
                            onChange(c);
                        }

                        var nRect = new Rect(viewRect.width - 40f, 5f, 40f - 5f, 16f).PixelPerfect();
                        GUILayoutExt.DrawComponentChooser(nRect, this.screen.gameObject, this.component.component, (component) => {
                            onChange(component);
                        });

                        if (this.component.component != null)
                        {
                            var editor = this.component.componentParametersEditor;

                            nRect.x     = 5f;
                            nRect.width = viewRect.width - 5f * 2f;
                            nRect.y    += nRect.height + 5f;
                            this.component.sortingOrder = EditorGUI.IntField(nRect, new GUIContent("Sorting Order"), this.component.sortingOrder);

                            if (editor != null)
                            {
                                var h = Mathf.Max(scrollView.height, (editor == null) ? 0f : editor.GetHeight());
                                viewRect = new Rect(scrollView.x, scrollView.y, viewRect.width - scrollWidth, h).PixelPerfect();

                                var oldSkin = GUI.skin;
                                GUI.skin = FlowSystemEditorWindow.defaultSkin;
                                this.settingsScrollPosition = GUI.BeginScrollView(scrollView, this.settingsScrollPosition, viewRect, false, true);
                                GUI.skin = oldSkin;
                                {
                                    if (editor != null)
                                    {
                                        EditorGUIUtility.labelWidth = 100f;
                                        //++EditorGUI.indentLevel;
                                        editor.OnParametersGUI(viewRect);
                                        //--EditorGUI.indentLevel;
                                        EditorGUIUtilityExt.LookLikeControls();
                                    }
                                }
                                GUI.EndScrollView();
                            }
                            else
                            {
                                GUI.Label(new Rect(0f, 0f, rectSettings.width - scrollWidth, rectSettings.height).PixelPerfect(), "Selected component have no parameters", EditorStyles.centeredGreyMiniLabel);
                            }
                        }
                    }
                    else
                    {
                        GUI.Label(new Rect(0f, 0f, rectSettings.width - scrollWidth, rectSettings.height).PixelPerfect(), "Select an Element", EditorStyles.centeredGreyMiniLabel);
                    }
                }
                GUI.EndGroup();

                GUI.BeginGroup(rectList);
                {
                    const float itemHeight = 30f;

                    this.highlighted.Clear();

                    var viewRect = new Rect(0f, 0f, rectList.width - scrollWidth, 0f).PixelPerfect();
                    this.allListHeight = 0f;
                    for (int i = 0; i < this.props.Count; ++i)
                    {
                        var root = this.screen.layout.layout.GetRootByTag(this.screen.layout.components[i].tag);
                        if (root.showInComponentsList == false)
                        {
                            continue;
                        }

                        if (this.screen.layout.components[i].component == null)
                        {
                            this.highlighted.Add(root);
                        }

                        this.allListHeight += itemHeight;
                    }

                    viewRect.height = Mathf.Max(rectList.height, this.allListHeight);

                    var oldSkin = GUI.skin;
                    GUI.skin = FlowSystemEditorWindow.defaultSkin;
                    this.listScrollPosition = GUI.BeginScrollView(new Rect(0f, 0f, rectList.width, rectList.height).PixelPerfect(), this.listScrollPosition, viewRect, false, true);
                    GUI.skin = oldSkin;
                    {
                        GUI.BeginGroup(viewRect);
                        {
                            var h = 0f;
                            this.hovered = null;
                            for (int i = 0; i < this.props.Count; ++i)
                            {
                                var root = this.screen.layout.layout.GetRootByTag(this.screen.layout.components[i].tag);
                                if (root.showInComponentsList == false)
                                {
                                    continue;
                                }

                                var r = new Rect(0f, h, viewRect.width, itemHeight).PixelPerfect();
                                h += r.height;

                                var isSelected = (this.element == root);
                                if (isSelected == true)
                                {
                                    GUI.Label(r, this.screen.layout.components[i].description, Layout.styles.listButtonSelected);
                                }
                                else
                                {
                                    //r.width -= scrollWidth;
                                    if (GUI.Button(r, this.screen.layout.components[i].description, Layout.styles.listButton) == true)
                                    {
                                        this.component = this.screen.layout.components.FirstOrDefault(c => c.tag == root.tag);
                                        this.element   = root;
                                    }

                                    var inRect = rectList.Contains(Event.current.mousePosition - this.listScrollPosition + Vector2.up * 40f);
                                    if (GUI.enabled == true)
                                    {
                                        EditorGUIUtility.AddCursorRect(r, MouseCursor.Link);
                                    }
                                    if (r.Contains(Event.current.mousePosition) == true && inRect == true)
                                    {
                                        this.hovered = this.screen.layout.components[i];
                                    }
                                    //r.width += scrollWidth;
                                }

                                //r.width -= scrollWidth;
                                GUI.Label(r, this.screen.layout.components[i].tag.ToString(), Layout.styles.listTag);
                            }
                        }
                        GUI.EndGroup();
                    }
                    GUI.EndScrollView();
                }
                GUI.EndGroup();

                var selected = (this.hovered != null) ? this.screen.layout.layout.GetRootByTag(this.hovered.tag) : this.element;
                this.editor.OnPreviewGUI(Color.white, rectContent, Layout.styles.content, selected: selected, onSelection: (element) => {
                    this.component = this.screen.layout.components.FirstOrDefault(c => c.tag == element.tag);
                    this.element   = element;
                }, highlighted: this.highlighted);

                if (GUI.Button(rectCloseButton, string.Empty, Layout.styles.closeButton) == true)
                {
                    this.flowEditor.SetEnabled();
                    this.opened = false;
                }
            }
        }
コード例 #24
0
        public override void OnFlowWindowGUI(FlowWindow window)
        {
            var data = FlowSystem.GetData();

            if (data == null)
            {
                return;
            }

            var flag = (window.IsFunction() == true &&
                        window.IsSmall() == true &&
                        window.IsContainer() == false);

            if (flag == true)
            {
                var alreadyConnectedFunctionIds = new List <int>();

                // Find caller window
                var windowFrom = data.windows.FirstOrDefault((item) => item.HasAttach(window.id));
                if (windowFrom != null)
                {
                    var attaches = windowFrom.GetAttachedWindows();
                    foreach (var attachWindow in attaches)
                    {
                        if (attachWindow.IsFunction() == true)
                        {
                            alreadyConnectedFunctionIds.Add(attachWindow.GetFunctionId());
                        }
                    }
                }

                foreach (var win in data.windows)
                {
                    if (win.IsFunction() == true &&
                        win.IsContainer() == true)
                    {
                        var count = alreadyConnectedFunctionIds.Count((e) => e == win.id);
                        if ((window.GetFunctionId() == win.id && count == 1) || count == 0)
                        {
                        }
                        else
                        {
                            if (win.id == window.functionId)
                            {
                                window.functionId = 0;
                            }
                            alreadyConnectedFunctionIds.Remove(win.id);
                        }
                    }
                }

                var functionId        = window.GetFunctionId();
                var functionContainer = functionId == 0 ? null : data.GetWindow(functionId);
                var isActiveSelected  = true;

                var oldColor = GUI.color;
                GUI.color = isActiveSelected ? Color.white : Color.grey;
                var result = GUILayoutExt.LargeButton(functionContainer != null ? functionContainer.title : "None", GUILayout.MaxHeight(60f), GUILayout.MaxWidth(150f));
                GUI.color = oldColor;
                var rect = GUILayoutUtility.GetLastRect();
                rect.y += rect.height;

                if (result == true)
                {
                    var menu = new GenericMenu();
                    menu.AddItem(new GUIContent("None"), window.functionId == 0, () => {
                        window.functionId = 0;
                    });

                    if (windowFrom != null)
                    {
                        alreadyConnectedFunctionIds.Clear();
                        var attaches = windowFrom.GetAttachedWindows();
                        foreach (var attachWindow in attaches)
                        {
                            if (attachWindow.IsFunction() == true)
                            {
                                alreadyConnectedFunctionIds.Add(attachWindow.GetFunctionId());
                            }
                        }
                    }
                    foreach (var win in data.windows)
                    {
                        if (win.IsFunction() == true &&
                            win.IsContainer() == true)
                        {
                            var count = alreadyConnectedFunctionIds.Count((e) => e == win.id);
                            if ((window.GetFunctionId() == win.id && count == 1) || count == 0)
                            {
                                var id = win.id;
                                menu.AddItem(new GUIContent(win.title), win.id == window.functionId, () => {
                                    window.functionId = id;
                                });
                            }
                            else
                            {
                                if (win.id == window.functionId)
                                {
                                    window.functionId = 0;
                                }

                                alreadyConnectedFunctionIds.Remove(win.id);
                                menu.AddDisabledItem(new GUIContent(win.title));
                            }
                        }
                    }

                    menu.DropDown(rect);
                }
            }
        }
コード例 #25
0
        internal static void DrawLayoutMode(Rect position, Layout hMode, Layout vMode, Vector2 pivot, bool doPivot, bool doPosition)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            GUILayoutExt.DrawRect(position, new Color(1f, 1f, 1f, 0.02f));

            Color oldColor = GUI.color;

            // Make parent size the largest possible square, but enforce it's an uneven number.
            int parentWidth = (int)Mathf.Min(position.width, position.height);

            if (parentWidth % 2 == 0)
            {
                parentWidth--;
            }

            int selfWidth = parentWidth / 2;

            if (selfWidth % 2 == 0)
            {
                selfWidth++;
            }

            Vector2 parentSize = new Vector2(position.width, position.height);               //parentWidth * Vector2.one;
            Vector2 selfSize   = new Vector2(position.width * 0.5f, position.height * 0.5f); //selfWidth * Vector2.one;
            Vector2 padding    = (position.size - parentSize) / 2;

            padding.x = Mathf.Floor(padding.x);
            padding.y = Mathf.Floor(padding.y);
            Vector2 padding2 = (position.size - selfSize) / 2;

            padding2.x = Mathf.Floor(padding2.x);
            padding2.y = Mathf.Floor(padding2.y);

            Rect outer = new Rect(position.x + padding.x, position.y + padding.y, parentSize.x, parentSize.y);
            Rect inner = new Rect(position.x + padding2.x, position.y + padding2.y, selfSize.x, selfSize.y);

            if (doPosition)
            {
                for (int axis = 0; axis < 2; axis++)
                {
                    var mode = (axis == 0 ? hMode : vMode);

                    if (mode == Layout.Min)
                    {
                        Vector2 center = inner.center;
                        center[axis] += outer.min[axis] - inner.min[axis];
                        inner.center  = center;
                    }
                    if (mode == Layout.Middle)
                    {
                        // TODO
                    }
                    if (mode == Layout.Max)
                    {
                        Vector2 center = inner.center;
                        center[axis] += outer.max[axis] - inner.max[axis];
                        inner.center  = center;
                    }
                    if (mode == Layout.Stretch)
                    {
                        Vector2 innerMin = inner.min;
                        Vector2 innerMax = inner.max;
                        innerMin[axis] = outer.min[axis];
                        innerMax[axis] = outer.max[axis];
                        inner.min      = innerMin;
                        inner.max      = innerMax;
                    }
                }
            }

            Rect    anchor = new Rect();
            Vector2 min    = Vector2.zero;
            Vector2 max    = Vector2.zero;

            for (int axis = 0; axis < 2; axis++)
            {
                var mode = (axis == 0 ? hMode : vMode);

                if (mode == Layout.Min)
                {
                    min[axis] = outer.min[axis] + 0.5f;
                    max[axis] = outer.min[axis] + 0.5f;
                }
                if (mode == Layout.Middle)
                {
                    min[axis] = outer.center[axis];
                    max[axis] = outer.center[axis];
                }
                if (mode == Layout.Max)
                {
                    min[axis] = outer.max[axis] - 0.5f;
                    max[axis] = outer.max[axis] - 0.5f;
                }
                if (mode == Layout.Stretch)
                {
                    min[axis] = outer.min[axis] + 0.5f;
                    max[axis] = outer.max[axis] - 0.5f;
                }
            }
            anchor.min = min;
            anchor.max = max;

            // Draw parent rect
            if (Event.current.type == EventType.Repaint)
            {
                GUI.color = s_Styles.parentColor * oldColor;
                s_Styles.frame.Draw(outer, false, false, false, false);
            }

            // Draw anchor lines
            if (hMode != Layout.Undefined && hMode != Layout.Stretch)
            {
                GUI.color = s_Styles.simpleAnchorColor * oldColor;
                GUI.DrawTexture(new Rect(anchor.xMin - 0.5f, outer.y + 1, 1, outer.height - 2), EditorGUIUtility.whiteTexture);
                GUI.DrawTexture(new Rect(anchor.xMax - 0.5f, outer.y + 1, 1, outer.height - 2), EditorGUIUtility.whiteTexture);
            }
            if (vMode != Layout.Undefined && vMode != Layout.Stretch)
            {
                GUI.color = s_Styles.simpleAnchorColor * oldColor;
                GUI.DrawTexture(new Rect(outer.x + 1, anchor.yMin - 0.5f, outer.width - 2, 1), EditorGUIUtility.whiteTexture);
                GUI.DrawTexture(new Rect(outer.x + 1, anchor.yMax - 0.5f, outer.width - 2, 1), EditorGUIUtility.whiteTexture);
            }

            // Draw stretch mode arrows
            if (hMode == Layout.Stretch)
            {
                GUI.color = s_Styles.stretchAnchorColor * oldColor;
                DrawArrow(new Rect(inner.x + 1, inner.center.y - 0.5f, inner.width - 2, 1));
            }
            if (vMode == Layout.Stretch)
            {
                GUI.color = s_Styles.stretchAnchorColor * oldColor;
                DrawArrow(new Rect(inner.center.x - 0.5f, inner.y + 1, 1, inner.height - 2));
            }

            // Draw self rect
            if (Event.current.type == EventType.Repaint)
            {
                GUI.color = s_Styles.selfColor * oldColor;
                s_Styles.frame.Draw(inner, false, false, false, false);
            }

            // Draw pivot
            if (doPivot && hMode != Layout.Undefined && vMode != Layout.Undefined)
            {
                Vector2 pivotInner = new Vector2(
                    Mathf.Lerp(inner.xMin + 0.5f, inner.xMax - 0.5f, pivot.x),
                    Mathf.Lerp(inner.yMax + 0.5f, inner.yMin - 0.5f, pivot.y)
                    );

                GUI.color = s_Styles.pivotColor * oldColor;
                GUI.DrawTexture(new Rect(pivotInner.x - 2.5f, pivotInner.y - 1.5f, 5, 3), EditorGUIUtility.whiteTexture);
                GUI.DrawTexture(new Rect(pivotInner.x - 1.5f, pivotInner.y - 2.5f, 3, 5), EditorGUIUtility.whiteTexture);
            }

            // Draw anchor corners
            if (hMode != Layout.Undefined && vMode != Layout.Undefined)
            {
                GUI.color = s_Styles.anchorCornerColor * oldColor;
                GUI.DrawTexture(new Rect(anchor.xMin - 1.5f, anchor.yMin - 1.5f, 2, 2), EditorGUIUtility.whiteTexture);
                GUI.DrawTexture(new Rect(anchor.xMax - 0.5f, anchor.yMin - 1.5f, 2, 2), EditorGUIUtility.whiteTexture);
                GUI.DrawTexture(new Rect(anchor.xMin - 1.5f, anchor.yMax - 0.5f, 2, 2), EditorGUIUtility.whiteTexture);
                GUI.DrawTexture(new Rect(anchor.xMax - 0.5f, anchor.yMax - 0.5f, 2, 2), EditorGUIUtility.whiteTexture);
            }

            GUI.color = oldColor;
        }
コード例 #26
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();
        }
コード例 #27
0
        public override void OnFlowWindowGUI(FD.FlowWindow window)
        {
            var data = FlowSystem.GetData();

            if (data == null)
            {
                return;
            }

            if (data.modeLayer == ModeLayer.Audio)
            {
                if (window.IsContainer() == true ||
                    window.IsSmall() == true ||
                    window.IsShowDefault() == true)
                {
                    return;
                }

                var screen = window.GetScreen();
                if (screen != null)
                {
                    GUILayout.BeginHorizontal();
                    {
                        var playType = (int)screen.audio.playType;
                        playType = GUILayoutExt.Popup(playType, new string[2] {
                            "Keep Current", "Replace"
                        }, FlowSystemEditorWindow.defaultSkin.label, GUILayout.Width(EditorGUIUtility.labelWidth));
                        screen.audio.playType = (UnityEngine.UI.Windows.Audio.Window.PlayType)playType;

                        var rect = GUILayoutUtility.GetLastRect();

                        /*var newId = */ AudioPopupEditor.Draw(new Rect(rect.x + rect.width, rect.y, window.rect.width - EditorGUIUtility.labelWidth - 10f, rect.height), screen.audio.id, (result) => {
                            screen.audio.id    = result;
                            window.audioEditor = null;
                        }, screen.audio.clipType, screen.audio.flowData.audio, null);

                        /*if (newId != screen.audio.id) {
                         *
                         *      screen.audio.id = newId;
                         *      window.audioEditor = null;
                         *
                         * }*/
                    }
                    GUILayout.EndHorizontal();

                    var state = data.audio.GetState(screen.audio.clipType, screen.audio.id);
                    if (state != null && state.clip != null)
                    {
                        GUILayout.BeginVertical();
                        {
                            GUILayout.Box(string.Empty, FlowSystemEditorWindow.styles.layoutBoxStyle, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
                            var rect = GUILayoutUtility.GetLastRect();

                            if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition) == true)
                            {
                                window.audioEditor = null;
                            }

                            if (window.audioEditor == null)
                            {
                                EditorPrefs.SetBool("AutoPlayAudio", false);
                                window.audioEditor = Editor.CreateEditor(state.clip);
                                //System.Type.GetType("AudioUtil").InvokeMember("StopClip", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public, null, null, new object[] { state.clip });
                            }

                            if (Event.current.type != EventType.MouseDrag && Event.current.type != EventType.DragPerform)
                            {
                                window.audioEditor.OnPreviewGUI(rect, EditorStyles.helpBox);
                                GUILayout.BeginHorizontal();
                                window.audioEditor.OnPreviewSettings();
                                GUILayout.EndHorizontal();
                            }
                        }
                        GUILayout.EndVertical();
                    }
                }
            }
        }
コード例 #28
0
        public virtual void OnEnable()
        {
            try {
                #pragma warning disable
                var _ = this.serializedObject;
                #pragma warning restore
            } catch (System.Exception) {
                return;
            }

            this.createPool = this.serializedObject.FindProperty("createPool");

            this.objectState             = this.serializedObject.FindProperty("objectState");
            this.animationParameters     = this.serializedObject.FindProperty("animationParameters");
            this.renderBehaviourOnHidden = this.serializedObject.FindProperty("renderBehaviourOnHidden");

            this.subObjects       = this.serializedObject.FindProperty("subObjects");
            this.componentModules = this.serializedObject.FindProperty("componentModules");

            this.allowRegisterInRoot    = this.serializedObject.FindProperty("allowRegisterInRoot");
            this.autoRegisterSubObjects = this.serializedObject.FindProperty("autoRegisterSubObjects");
            this.hiddenByDefault        = this.serializedObject.FindProperty("hiddenByDefault");

            if (this.listModules == null)
            {
                var componentsProp = this.componentModules.FindPropertyRelative("modules");
                //if (componentsProp.arraySize != 0) {

                this.serializedObject.Update();
                this.componentModules.FindPropertyRelative("windowComponent").objectReferenceValue = this.componentModules.serializedObject.targetObject;
                this.serializedObject.ApplyModifiedProperties();
                this.listModules = new UnityEditorInternal.ReorderableList(componentsProp.serializedObject, componentsProp, true, true, true, true);
                this.listModules.elementHeight = 40f;
                this.listModules.onAddCallback = (rList) => {
                    if (rList.serializedProperty != null)
                    {
                        ++rList.serializedProperty.arraySize;
                        rList.index = rList.serializedProperty.arraySize - 1;
                        var idx  = rList.index;
                        var prop = componentsProp.GetArrayElementAtIndex(idx);
                        prop.objectReferenceValue = null;
                    }
                };
                this.listModules.onRemoveCallback = (rList) => {
                    var idx  = this.listModules.index;
                    var prop = componentsProp.GetArrayElementAtIndex(idx);
                    if (prop.objectReferenceValue != null)
                    {
                        Object.DestroyImmediate(prop.objectReferenceValue, true);
                    }
                    componentsProp.DeleteArrayElementAtIndex(idx);
                };
                this.listModules.drawElementBackgroundCallback = (rect, index, active, focused) => {
                    if (focused == true || active == true)
                    {
                        GUILayoutExt.DrawRect(rect, new Color(0.1f, 0.4f, 0.7f, 1f));
                    }
                    else
                    {
                        GUILayoutExt.DrawRect(rect, new Color(1f, 1f, 1f, index % 2 == 0 ? 0.05f : 0f));
                    }
                };
                this.listModules.elementHeightCallback = (index) => {
                    var prop = componentsProp.GetArrayElementAtIndex(index);
                    if (prop.objectReferenceValue != null)
                    {
                        var height   = 0f;
                        var so       = new SerializedObject(prop.objectReferenceValue);
                        var iterator = so.GetIterator();
                        iterator.NextVisible(true);

                        while (true)
                        {
                            if (EditorHelpers.IsFieldOfTypeBeneath(prop.objectReferenceValue.GetType(), typeof(WindowComponentModule), iterator.propertyPath) == true)
                            {
                                height += EditorGUI.GetPropertyHeight(iterator, new GUIContent(iterator.displayName), false);
                            }

                            if (!iterator.NextVisible(iterator.isExpanded))
                            {
                                break;
                            }
                        }

                        return(40f + height);
                    }

                    return(40f);
                };
                this.listModules.drawElementCallback = (rect, index, active, focused) => {
                    var padding = 10f;
                    rect.x     += padding;
                    rect.y     += padding;
                    rect.width -= padding * 2f;
                    rect.height = 18f;
                    EditorGUI.PropertyField(rect, componentsProp.GetArrayElementAtIndex(index), new GUIContent("Module"));
                    rect.y += 18f;
                    rect.y += padding;

                    var prop = componentsProp.GetArrayElementAtIndex(index);
                    if (prop.objectReferenceValue != null)
                    {
                        var so = new SerializedObject(prop.objectReferenceValue);
                        so.Update();

                        so.FindProperty("windowComponent").objectReferenceValue = this.serializedObject.targetObject;

                        var iterator = so.GetIterator();
                        iterator.NextVisible(true);

                        EditorGUI.indentLevel += 1;
                        int indent = EditorGUI.indentLevel;
                        while (true)
                        {
                            if (EditorHelpers.IsFieldOfTypeBeneath(prop.objectReferenceValue.GetType(), typeof(WindowComponentModule), iterator.propertyPath) == true)
                            {
                                rect.height = EditorGUI.GetPropertyHeight(iterator, new GUIContent(iterator.displayName), false);

                                //totalHeight += rect.height;
                                EditorGUI.indentLevel = indent + iterator.depth;
                                EditorGUI.PropertyField(rect, iterator);
                                rect.y += rect.height;
                            }

                            if (!iterator.NextVisible(iterator.isExpanded))
                            {
                                break;
                            }
                        }

                        EditorGUI.indentLevel  = indent;
                        EditorGUI.indentLevel -= 1;

                        /*
                         * var iter = so.GetIterator();
                         * while (iter.NextVisible(true) == true) {
                         *
                         *  if (iter.hasVisibleChildren == true) {
                         *
                         *      iter.isExpanded = EditorGUI.Foldout(rect, iter.isExpanded, iter.displayName);
                         *
                         *      if (iter.isExpanded == false) continue;
                         *
                         *  }
                         *
                         *  if (EditorHelpers.IsFieldOfTypeBeneath(prop.objectReferenceValue.GetType(), typeof(WindowComponentModule), iter.propertyPath) == true) {
                         *
                         *      rect.height = EditorGUI.GetPropertyHeight(iter);
                         *      EditorGUI.PropertyField(rect, iter);
                         *      rect.y += rect.height;
                         *
                         *  }
                         *
                         * }*/

                        so.ApplyModifiedProperties();
                    }
                };
                this.listModules.drawHeaderCallback = (rect) => { GUI.Label(rect, "Modules"); };

                //}
            }

            EditorHelpers.SetFirstSibling(this.targets);
        }
コード例 #29
0
        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();
        }
コード例 #30
0
        public void DrawProjectSelector()
        {
            var darkLabel = ME.Utilities.CacheStyle("FlowEditor.DataSelection.Styles", "DarkLabel", (name) => {
                var style       = new GUIStyle(FlowSystemEditorWindow.defaultSkin.FindStyle(name));
                style.alignment = TextAnchor.MiddleLeft;
                return(style);
            });

            var headerStyle = new GUIStyle("LODLevelNotifyText");

            headerStyle.normal.textColor = EditorGUIUtility.isProSkin == true ? Color.white : Color.black;
            headerStyle.fontSize         = 18;
            headerStyle.alignment        = TextAnchor.MiddleCenter;

            GUILayoutExt.LabelWithShadow("UI.Windows Flow Extension v" + VersionInfo.BUNDLE_VERSION, headerStyle);

            GUILayout.Space(10f);

            GUILayout.Label("Open one of your projects:", darkLabel);

            var backStyle = new GUIStyle("sv_iconselector_labelselection");

            var skin = GUI.skin;

            GUI.skin = FlowSystemEditorWindow.defaultSkin;
            this.dataSelectionScroll = GUILayout.BeginScrollView(this.dataSelectionScroll, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, backStyle);
            {
                GUI.skin = skin;

                this.scannedData = EditorUtilities.GetAssetsOfType <FlowData>();

                if (this.scannedData.Length == 0)
                {
                    var center = new GUIStyle(darkLabel);
                    center.fixedWidth    = 0f;
                    center.fixedHeight   = 0f;
                    center.stretchWidth  = true;
                    center.stretchHeight = true;
                    center.alignment     = TextAnchor.MiddleCenter;
                    center.wordWrap      = true;

                    GUILayout.Label("No projects was found. Create a new one by Right-Click on any folder in Project View and choosing Create->UI.Windows->Flow->Graph option.", center);
                }
                else
                {
                    var buttonStyle = new GUIStyle("U2D.createRect");
                    buttonStyle.padding          = new RectOffset(15, 15, 15, 15);
                    buttonStyle.margin           = new RectOffset(2, 2, 2, 2);
                    buttonStyle.fixedWidth       = 0f;
                    buttonStyle.fixedHeight      = 0f;
                    buttonStyle.stretchWidth     = true;
                    buttonStyle.stretchHeight    = false;
                    buttonStyle.normal.textColor = Color.black;
                    buttonStyle.fontSize         = 12;
                    buttonStyle.richText         = true;

                    var buttonStyleSelected = new GUIStyle(buttonStyle);

                    buttonStyle.normal.background = null;

                    this.scannedData = this.scannedData.OrderByDescending((data) => (data != null ? data.lastModified : string.Empty)).ToArray();

                    foreach (var data in this.scannedData)
                    {
                        if (data == null)
                        {
                            continue;
                        }

                        var title = data.name + "\n";
                        title += "<color=#777><size=10>Modified: " + data.lastModified + "</size></color>\n";
                        title += "<color=#888><size=10>Version: " + data.version + "</size></color>";

                        if (GUILayout.Button(title, this.cachedData == data ? buttonStyleSelected : buttonStyle) == true)
                        {
                            this.cachedData = data;
                        }
                    }
                }

                GUILayout.FlexibleSpace();
            }
            GUILayout.EndScrollView();

            GUILayout.Space(10f);

            GUILayout.Label("Or select the project file:", darkLabel);

            this.cachedData = GUILayoutExt.ObjectField <FlowData>(this.cachedData, false, FlowSystemEditorWindow.defaultSkin.FindStyle("ObjectField"));

            CustomGUI.Splitter();

            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Create Project...", FlowSystemEditorWindow.defaultSkin.button, GUILayout.Width(150f), GUILayout.Height(40f)) == true)
                {
                    this.state = State.NewProject;
                }

                GUILayout.FlexibleSpace();

                var oldState = GUI.enabled;
                GUI.enabled = oldState && this.cachedData != null;

                if (this.cachedData != null && this.cachedData.version < VersionInfo.BUNDLE_VERSION)
                {
                    // Need to upgrade

                    if (GUILayout.Button("Upgrade to " + VersionInfo.BUNDLE_VERSION, FlowSystemEditorWindow.defaultSkin.button, GUILayout.Width(150f), GUILayout.Height(40f)) == true)
                    {
                        UnityEditor.EditorUtility.DisplayProgressBar("Upgrading", string.Format("Migrating from {0} to {1}", this.cachedData.version, VersionInfo.BUNDLE_VERSION), 0f);
                        var type = this.cachedData.GetType();

                        while (this.cachedData.version < VersionInfo.BUNDLE_VERSION)
                        {
                            var nextVersion = this.cachedData.version + 1;

                            // Try to find upgrade method
                            var methodName = "UpgradeTo" + nextVersion.ToSmallWithoutTypeString();
                            var methodInfo = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public);
                            if (methodInfo != null)
                            {
                                methodInfo.Invoke(this.cachedData, null);

                                Debug.Log("[UPGRADE] Invoked: `" + methodName + "`, version " + nextVersion);
                            }
                            else
                            {
                                Debug.Log("[UPGRADE] Method `" + methodName + "` was not found: version " + nextVersion + " skipped");
                            }

                            UnityEditor.EditorUtility.DisplayProgressBar("Upgrading", string.Format("Migrating from {0} to {1}", this.cachedData.version, nextVersion), 0.5f);

                            this.cachedData.version = nextVersion;
                            UnityEditor.EditorUtility.SetDirty(this.cachedData);
                        }

                        UnityEditor.EditorUtility.DisplayProgressBar("Upgrading", string.Format("Migrating from {0} to {1}", this.cachedData.version, VersionInfo.BUNDLE_VERSION), 1f);
                        UnityEditor.EditorUtility.ClearProgressBar();
                    }
                }
                else if (this.cachedData != null && this.cachedData.version > VersionInfo.BUNDLE_VERSION)
                {
                    EditorGUILayout.HelpBox(string.Format("Selected Project has {0} version while UI.Windows System has {1} version number. Please, download a new version.", this.cachedData.version, VersionInfo.BUNDLE_VERSION), MessageType.Warning);
                    if (GUILayout.Button("Download", FlowSystemEditorWindow.defaultSkin.button, GUILayout.Width(100f), GUILayout.Height(40f)) == true)
                    {
                        Application.OpenURL(VersionInfo.DOWNLOAD_LINK);
                    }
                }
                else
                {
                    if (GUILayout.Button("Open", FlowSystemEditorWindow.defaultSkin.button, GUILayout.Width(100f), GUILayout.Height(40f)) == true)
                    {
                        FlowSystem.SetData(this.cachedData);
                    }
                }

                GUI.enabled = oldState;
            }
            GUILayout.EndHorizontal();
        }