コード例 #1
0
        public static Obj CopyPastObjectButtons(Obj obj, GUIStyle style)
        {
            using (Disposables.HorizontalScope(style))
                CopyPastObjectButtons(obj);

            return(obj);
        }
コード例 #2
0
        //TODO: add Un Parent Button

        private void DrawChildObject(Object obj, int index)
        {
            using (Disposables.HorizontalScope()) {
                FoCsGUI.Layout.Label($"[{index}] {obj.GetType().Name.SplitCamelCase()}", GUILayout.Width(Screen.width / 4f));

                using (var changeCheckScope = Disposables.ChangeCheck()) {
                    using (Disposables.IndentSet(0))
                        obj.name = EditorGUILayout.DelayedTextField(obj.name);

                    if (changeCheckScope.changed)
                    {
                        EditorUtility.SetDirty(target);
                        AssetDatabase.ImportAsset(AssetPath(target));
                    }
                }

                var deleteEvent = FoCsGUI.Layout.Button(new GUIContent("X"), FoCsGUI.Styles.CrossCircle, GUILayout.Width(FoCsGUI.Styles.CrossCircle.Style.fixedWidth));

                if (deleteEvent)
                {
                    if (EditorUtility.DisplayDialog("Delete Child", $"Delete {obj.name}", "Yes Delete", "No Cancel"))
                    {
                        DestroyImmediate(obj, true);
                        EditorUtility.SetDirty(target);
                        AssetDatabase.ImportAsset(AssetPath(target));
                        Repaint();
                        repaintCalled = true;

                        return;
                    }
                }
            }

            DoPadding(1, false);
        }
コード例 #3
0
        private static void DrawField(KeyValue data)
        {
            using (Disposables.HorizontalScope(GUI.skin.box)) {
                FoCsGUI.Layout.LabelField(data.Key, GUILayout.Width(LABEL_WIDTH));

                using (Disposables.HorizontalScope()) {
                    DrawData(data.Value);
                    var tempData = data.Value.previousData;

                    for (var i = 0; i < 5; i++)
                    {
                        if (tempData == null)
                        {
                            break;
                        }

                        DrawData(tempData);
                        tempData = tempData.previousData;
                    }

                    if (tempData != null)
                    {
                        tempData.previousData = null;
                    }
                }
            }
        }
コード例 #4
0
        private void DrawTop()
        {
            if (TitleBarScrollable)
            {
                using (Disposables.VerticalScope()) {
                    using (var scrollViewScope = Disposables.ScrollViewScope(scrollPos, true, GUILayout.ExpandWidth(true), GUILayout.Height(33))) {
                        scrollPos = scrollViewScope.scrollPosition;

                        using (Disposables.HorizontalScope(EditorStyles.toolbar, GUILayout.ExpandWidth(true)))
                            DrawHeaderGUI();
                    }

                    using (Disposables.VerticalScope(GUILayout.ExpandHeight(true)))
                        DrawActiveTab();
                }
            }
            else
            {
                using (Disposables.VerticalScope()) {
                    using (Disposables.HorizontalScope(EditorStyles.toolbar, GUILayout.ExpandWidth(true)))
                        DrawHeaderGUI();

                    using (Disposables.VerticalScope(GUILayout.ExpandHeight(true)))
                        DrawActiveTab();
                }
            }
        }
コード例 #5
0
        private void DrawFilePathGUI()
        {
            using (Disposables.HorizontalScope())
                GUILayout.Label("Save Path", EditorStyles.boldLabel);

            EditorGUILayout.TextField(Owner.path, GUILayout.ExpandWidth(true));
            PathButtons();
        }
コード例 #6
0
        private void DrawMenuTabs()
        {
            FoCsGUI.Layout.LabelField("Categories of Scriptable Objects that can be added", FoCsGUI.Styles.Unity.BoldLabel);
            var width    = (Screen.width / 200) + 1;
            var nameList = typeDictionary.Keys.ToList();

            if (!nameList.InRange(ActiveTab))
            {
                ActiveTab = 0;
            }

            for (var i = 0; i < nameList.Count; i += width)
            {
                if (!nameList.InRange(i))
                {
                    break;
                }

                using (Disposables.HorizontalScope(FoCsGUI.Styles.Toolbar)) {
                    for (var j = 0; j < width; j += 1)
                    {
                        var index = i + j;

                        if (!nameList.InRange(index))
                        {
                            break;
                        }

                        var key = nameList[index];

                        if (ActiveTab == index)
                        {
                            ActiveTabName = key;
                        }

                        using (var cc = Disposables.ChangeCheck()) {
                            var @event = FoCsGUI.Layout.Toggle(key.ToggleName.SplitCamelCase(), ActiveTab == index, FoCsGUI.Styles.Unity.ToolbarButton);

                            if (cc.changed && @event)
                            {
                                if (ActiveTab == index)
                                {
                                    continue;
                                }

                                ActiveTab     = index;
                                ActiveTabName = key;
                                Repaint();
                                repaintCalled = true;

                                return;
                            }
                        }
                    }
                }
            }
        }
コード例 #7
0
        public static SerializedObject CopyPastObjectButtons(SerializedObject obj, GUIStyle style)
        {
            if (CopyPasteUtility.GetCopyMode(obj.targetObject) != (CopyPasteUtility.CopyMode.Unknown | CopyPasteUtility.CopyMode.None))
            {
                using (Disposables.HorizontalScope(style))
                    CopyPastObjectButtons(obj.targetObject);
            }

            return(obj);
        }
コード例 #8
0
        public override void DrawTab(FoCsWindow <ScreenCapWindow> owner)
        {
            Owner = owner as ScreenCapWindow;

            using (Disposables.HorizontalScope()) {
                using (Disposables.VerticalScope()) {
                    DrawVariables();

                    using (Disposables.HorizontalScope())
                        DrawTakeImageGUI();
                }
            }
        }
コード例 #9
0
        private void PathButtons()
        {
            using (Disposables.HorizontalScope()) {
                if (GUILayout.Button("Browse"))
                {
                    Owner.path = EditorUtility.SaveFolderPanel("Path to Save Images", Owner.path, Application.dataPath);
                }

                if (GUILayout.Button("Default", GUILayout.Width(120)))
                {
                    Owner.path = Owner.defaultPath;
                }
            }
        }
コード例 #10
0
        protected override void OnGUI()
        {
            FoCsGUI.Layout.Label(Heading);

            using (Disposables.HorizontalScope()) {
                using (var cc = Disposables.ChangeCheck()) {
                    versionNumber = FoCsGUI.Layout.DelayedTextField(versionNumber);

                    if (cc.changed)
                    {
                        BundleVersion.stringValue = versionNumber;
                        SerializedObject.ApplyModifiedProperties();
                    }
                }
            }
        }
コード例 #11
0
            private void DrawFooter()
            {
                using (Disposables.VerticalScope()) {
                    if (FoCsGUI.Layout.Button("Force save"))
                    {
                        foreach (var serializedObject in Assets)
                        {
                            EditorUtility.SetDirty(serializedObject.targetObject);
                        }
                    }

                    using (Disposables.HorizontalScope(GUI.skin.box)) {
                        EditorGUILayout
                        .HelpBox("Warning, This window has not been tested for all the settings being validated.\nIt is still recommended to use the Unity settings windows.",
                                 MessageType.Warning);
                    }
                }
            }
コード例 #12
0
        protected override void OnGUI()
        {
            if (currentArguments == null)
            {
                return;
            }

            EditorGUILayout.LabelField(currentArguments.Title);
            GUI.SetNextControlName(GUI_SELECTION_LABEL);
            currentArguments.Data = EditorGUILayout.TextField(GUIContent.none, currentArguments.Data);

            if (!notSelectedLabel)
            {
                EditorGUI.FocusTextInControl(GUI_SELECTION_LABEL);
                notSelectedLabel = true;
            }

            using (Disposables.HorizontalScope()) {
                if (FoCsGUI.Layout.Button(currentArguments.SubmitMessage))
                {
                    currentArguments.OnSubmit.Trigger(currentArguments);
                    Close();
                    EndWindows();
                }

                if (FoCsGUI.Layout.Button(currentArguments.CancelMessage))
                {
                    currentArguments.OnCancel.Trigger(currentArguments);
                    Close();
                    EndWindows();
                }
            }

            if (!currentArguments.HasAnotherButton)
            {
                return;
            }

            if (FoCsGUI.Layout.Button(currentArguments.SubmitAnotherMessage))
            {
                currentArguments.OnSubmitAnother.Trigger(currentArguments);
            }
        }
コード例 #13
0
        protected override void OnGUI()
        {
            if (ObjectsToEditors.IsNullOrEmpty())
            {
                ObjectsToEditors = new Dictionary <Object, UEditor>();
            }

            if (Object.IsNullOrEmpty())
            {
                Object = new List <Object>();
            }

            using (var scroll = Disposables.ScrollViewScope(scrollPos, true, FoCsGUI.LayoutOptions.Expand())) {
                scrollPos = scroll.scrollPosition;

                using (Disposables.HorizontalScope()) {
                    foreach (var o in Object)
                    {
                        if (!ObjectsToEditors.ContainsKey(o))
                        {
                            GenerateEditor(o);
                        }

                        using (Disposables.VerticalScope(FoCsGUI.LayoutOptions.Width(500)))
                            ObjectsToEditors[o].OnInspectorGUI();
                    }
                }
            }

            using (var cc = Disposables.ChangeCheck()) {
                var obj = FoCsGUI.Layout.ObjectField <Object>(null, Label, true);

                if (cc.changed)
                {
                    if (obj != null)
                    {
                        Object.AddWithDuplicateCheck(obj);
                        GenerateEditor(obj);
                    }
                }
            }
        }
コード例 #14
0
        private void DrawChildrenGUI()
        {
            using (Disposables.Indent()) {
                var assets = AssetDatabase.LoadAllAssetsAtPath(AssetPath());

                if (assets.Length <= 1)
                {
                    return;
                }

                using (Disposables.HorizontalScope(FoCsGUI.Styles.Toolbar))
                    showChildrenSettings = FoCsGUI.Layout.Foldout(showChildrenSettings, $"Children [{assets.Length - 1}]");

                if (!showChildrenSettings)
                {
                    return;
                }

                using (Disposables.VerticalScope(GUI.skin.box)) {
                    for (var i = 0; i < assets.Length; i++)
                    {
                        var obj = assets[i];

                        if (!obj)
                        {
                            continue;
                        }

                        if (AssetDatabase.IsSubAsset(obj))
                        {
                            DrawChildObject(obj, i);
                        }

                        if (repaintCalled)
                        {
                            return;
                        }
                    }
                }
            }
        }
コード例 #15
0
        public static Vector3 DrawVector3(GUIContent label, Vector3 vec, Vector3 defaultValue, Obj objectIAmOn, out bool GUIChanged)
        {
            using (Disposables.IndentSet(1)) {
                using (Disposables.HorizontalScope()) {
                    using (var cc = Disposables.ChangeCheck()) {
                        vec        = EditorGUILayout.Vector3Field(label, vec);
                        GUIChanged = cc.changed;
                    }

                    var cachedGuiColor = GUI.color;

                    using (Disposables.HorizontalScope(EditorStyles.toolbar)) {
                        var resetBtn = FoCsGUI.Layout.Button(ResetContent, EditorStyles.toolbarButton, GUILayout.Width(25));
                        var copyBtn  = FoCsGUI.Layout.Button(CopyContent, EditorStyles.toolbarButton, GUILayout.Width(25));
                        var pasteBtn = FoCsGUI.Layout.Button(PasteContent, EditorStyles.toolbarButton, GUILayout.Width(25));

                        if (resetBtn)
                        {
                            Undo.RecordObject(objectIAmOn, "Vector 3 Reset");
                            vec        = defaultValue;
                            GUIChanged = true;
                        }
                        else if (copyBtn)
                        {
                            CopyPasteUtility.EditorCopy(vec);
                        }
                        else if (pasteBtn)
                        {
                            Undo.RecordObject(objectIAmOn, "Vector 3 Paste");
                            vec        = CopyPasteUtility.Paste <Vector3>();
                            GUIChanged = true;
                        }

                        GUI.color = cachedGuiColor;
                    }
                }
            }

            return(vec);
        }
コード例 #16
0
        private void DrawAddTypeButton(List <Type> types)
        {
            FoCsGUI.Layout.LabelField("Categories of Scriptable Objects that can be added", FoCsGUI.Styles.Unity.BoldLabel);
            var width = (Screen.width / 250) + 1;

            for (var i = 0; i < types.Count; i += width)
            {
                using (Disposables.HorizontalScope(FoCsGUI.Styles.Toolbar)) {
                    for (var j = 0; j < width; j += 1)
                    {
                        var index = i + j;

                        if (!types.InRange(index))
                        {
                            break;
                        }

                        DrawAddTypeButton(types[index]);
                    }
                }
            }
        }
コード例 #17
0
        protected override void DoExtraDraw()
        {
            using (Disposables.HorizontalScope()) {
                if (GUILayout.Button("Add Object Name ID"))
                {
                    var btn = (FoCsButton)serializedObject.targetObject;

                    if (!btn.Button.name.Contains("_btn"))
                    {
                        btn.Button.name += "_btn";
                    }

                    btn.TextGO.name = btn.Button.name.Replace("_btn", "") + "_text";
                }

                if (GUILayout.Button("Change Button Text to Button GO Name"))
                {
                    var btn = (FoCsButton)serializedObject.targetObject;
                    btn.Text = btn.Button.name.Replace("_btn", "");
                }
            }
        }
コード例 #18
0
            public override void DrawTab(FoCsWindow <AdvancedUnitySettingsWindow> owner)
            {
                //if(storage == null)
                //	storage = new UnityReorderableListStorage(owner);

                using (Disposables.HorizontalScope(GUI.skin.box))
                    EditorGUILayout.LabelField(TabName);

                using (Disposables.HorizontalScope()) {
                    DrawSpace(LEFT_BORDER * 0.5f);
                    Search = FoCsGUI.Layout.TextField(SearchGuiContent, Search);
                }

                using (Disposables.LabelAddWidth(EXTRA_LABEL_WIDTH)) {
                    using (Disposables.SetIndent(1)) {
                        //if(handlerControllers.IsNullOrEmpty())
                        //{
                        //	handlerControllers = new HandlerController[Assets.Length];
                        //
                        //	for(var i = 0; i < handlerControllers.Length; i++)
                        //		handlerControllers[i] = new HandlerController();
                        //}

                        for (var i = 0; i < Assets.Length; i++)
                        {
                            var asset = Assets[i];
                            //var handlerController = handlerControllers[i];
                            asset.Update();

                            //handlerController.VerifyIPropertyLayoutHandlerArrayNoObject(storage);
                            //handlerController.VerifyHandlingDictionary(asset);

                            using (Disposables.HorizontalScope()) {
                                DrawSpace(LEFT_BORDER);

                                using (var scrollViewScope = Disposables.ScrollViewScope(vector2, true)) {
                                    vector2 = scrollViewScope.scrollPosition;

                                    using (var changeCheckScope = Disposables.ChangeCheck()) {
                                        foreach (var property in asset.Properties())
                                        {
                                            if (Search.IsNullOrEmpty())
                                            {
                                                FoCsGUI.Layout.PropertyField(property);
                                            }
                                            else if (property.name.ToLower().Contains(Search.ToLower()))
                                            {
                                                FoCsGUI.Layout.PropertyField(property);
                                            }
                                        }

                                        if (changeCheckScope.changed)
                                        {
                                            asset.ApplyModifiedProperties();
                                        }
                                    }
                                }

                                DrawSpace(RIGHT_BORDER);
                            }
                        }
                    }
                }

                DrawFooter();
            }
コード例 #19
0
 protected override void DoExtraDraw()
 {
     using (Disposables.HorizontalScope(GUI.skin.box))
         FoCsGUI.Layout.LabelField($"Has reference: {Target.HasReference}");
 }
コード例 #20
0
        protected override void DoExtraDraw() {
            using (Disposables.HorizontalScope(GUI.skin.box))
                FoCsGUI.Layout.LabelField($"List has {Target.Count} entries.");

            FoCsGUI.Layout.WarningBox("Run Time Lists cause errors in Unity's serialize system.");
        }