コード例 #1
0
        public void DoGUI(HierarchyFrameDataView frameDataView)
        {
            using (m_DoGUIMarker.Auto())
            {
                InitIfNeeded();

                var collectingSamples = ProfilerDriver.enabled && (ProfilerDriver.profileEditor || EditorApplication.isPlaying);
                var isSearchAllowed   = string.IsNullOrEmpty(treeView.searchString) || !(collectingSamples && ProfilerDriver.deepProfiling);

                var isDataAvailable = frameDataView != null && frameDataView.valid;

                var showDetailedView = isDataAvailable && m_DetailedViewType != DetailedViewType.None;
                if (showDetailedView)
                {
                    SplitterGUILayout.BeginHorizontalSplit(m_DetailedViewSpliterState);
                }

                // Hierarchy view area
                GUILayout.BeginVertical();

                DrawToolbar(frameDataView, showDetailedView);

                if (!isDataAvailable)
                {
                    GUILayout.Label(BaseStyles.noData, BaseStyles.label);
                }
                else if (!isSearchAllowed)
                {
                    GUILayout.Label(BaseStyles.disabledSearchText, BaseStyles.label);
                }
                else
                {
                    var rect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.ExpandHeight(true));
                    m_TreeView.SetFrameDataView(frameDataView);
                    m_TreeView.OnGUI(rect);
                }

                GUILayout.EndVertical();

                if (showDetailedView)
                {
                    GUILayout.BeginVertical();

                    // Detailed view area
                    EditorGUILayout.BeginHorizontal(BaseStyles.toolbar);

                    DrawDetailedViewPopup();
                    GUILayout.FlexibleSpace();

                    DrawOptionsMenuPopup();
                    EditorGUILayout.EndHorizontal();

                    switch (m_DetailedViewType)
                    {
                    case DetailedViewType.Objects:
                        detailedObjectsView.DoGUI(BaseStyles.header, frameDataView, m_TreeView.GetSelection());
                        break;

                    case DetailedViewType.CallersAndCallees:
                        detailedCallsView.DoGUI(BaseStyles.header, frameDataView, m_TreeView.GetSelection());
                        break;
                    }

                    GUILayout.EndVertical();

                    SplitterGUILayout.EndHorizontalSplit();
                }

                HandleKeyboardEvents();
            }
        }
コード例 #2
0
        static public bool ArrayEditor(string label, SerializedProperty arrayProp, string footer = null, int?fixedSize = null)
        {
            bool changed = false;

            if (fixedSize.HasValue)
            {
                arrayProp.arraySize = fixedSize.Value;
                changed             = true;
            }

            EditorGUILayout.BeginVertical("box");

            EditorGUILayout.BeginHorizontal();
            if (!string.IsNullOrEmpty(label))
            {
                EditorGUILayout.LabelField(label);
            }
            // Button... Force it to the right
            EditorGUILayout.Space();
            if (!fixedSize.HasValue)
            {
                if (GUI.enabled && GUILayout.Button(" + ", GUILayout.ExpandWidth(false)))
                {
                    ++arrayProp.arraySize;
                    changed = true;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            int count = arrayProp.arraySize;

            if (count > 0)
            {
                EditorGUILayout.BeginVertical();
                EditorGUI.BeginChangeCheck();

                int remove  = -1;
                int shift   = -1;
                int shiftTo = -1;

                int from, to;
                GetArrayPageFromTo(arrayProp.GetHashCode(), count, out from, out to);

                for (int i = from; i <= to; i++)
                {
                    EditorGUILayout.BeginHorizontal("box");

                    // Index...  Shift up or down?
                    EditorGUILayout.LabelField(string.Format("[{0}]", i), GUILayout.Width(36f));
                    ArrayShiftButtons(i, count, ref shift, ref shiftTo);

                    // Show the element
                    if (EditorGUILayout.PropertyField(arrayProp.GetArrayElementAtIndex(i), GUIContent.none, true, GUILayout.ExpandWidth(true)))
                    {
                        changed = true;
                    }

                    if (!fixedSize.HasValue)
                    {
                        // Add a remove button to the right
                        if (GUI.enabled && GUILayout.Button("×", GUILayout.ExpandWidth(false)))
                        {
                            remove = i;
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }

                // Carry out element remove operation
                if (remove >= 0)
                {
                    if (remove < count - 1)
                    {
                        arrayProp.DeleteArrayElementAtIndex(remove);
                    }
                    else
                    {
                        --arrayProp.arraySize;
                    }
                    --count;
                    changed = true;
                }
                if (shift >= 0)
                {
                    arrayProp.MoveArrayElement(shift, shiftTo);
                }

                if (EditorGUI.EndChangeCheck())
                {
                    changed = true;
                }
                EditorGUILayout.EndVertical();
            }
            ArrayPageButtons(arrayProp.GetHashCode(), count);

            // Footer below list
            EditorGUILayout.BeginHorizontal();
            // Help message?
            if (!string.IsNullOrEmpty(footer))
            {
                EditorGUILayout.LabelField(footer, Footnote);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            return(changed);
        }
コード例 #3
0
    void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();

        capacityText = EditorGUILayout.TextField("Panel数量", capacityText);
        if (GUILayout.Button("确定(注:Panel名字无需带有'Panel'字样)"))
        {
            if (!int.TryParse(capacityText, out capacity))
            {
                return;
            }

            if (nameList.Count == 0)
            {
                for (int i = 0; i < capacity; i++)
                {
                    nameList.Add("");
                }
            }
            else if (nameList.Count < capacity)
            {
                for (int i = nameList.Count; i < capacity; i++)
                {
                    nameList.Add("");
                }
            }
            else if (nameList.Count > capacity)
            {
                for (int i = nameList.Count; i > capacity; i--)
                {
                    nameList.RemoveAt(i - 1);
                }
            }
        }

        EditorGUILayout.EndHorizontal();

        if (capacity > 0)
        {
            for (int i = 0; i < capacity; i++)
            {
                nameList[i] = EditorGUILayout.TextField(i + ".Panel名字:", nameList[i]);
            }
        }


        EditorGUILayout.LabelField("------------------------------------------------------------------");
        EditorGUILayout.LabelField("下面的设置将修改:");
        EditorGUILayout.LabelField("1.define.lua" + " 路径为: " + defineLuaPath);
        EditorGUILayout.LabelField("2.CtrlManager.lua" + " 路径为: " + ctrlManagerLuaPath);
        EditorGUILayout.LabelField("3.Game.lua" + " 路径为: " + gameLuaPath);
        if (GUILayout.Button("修改define.lua 与 CtrlManager.lua"))
        {
            //修改define.lua
            string content = File.ReadAllText(defineLuaPath);//Debug.Log(content);
            for (int i = 0; i < capacity; i++)
            {
                int a = content.IndexOf('}', content.IndexOf("CtrlNames"));
                content = content.Insert(a, "\t" + nameList[i] + " = \"" + nameList[i] + "Ctrl" + "\",\r\n");
                int b = content.IndexOf('}', content.IndexOf("PanelNames"));
                content = content.Insert(b, "\t" + "\"" + nameList[i] + "Panel" + "\",\r\n");
            }
            File.WriteAllText(defineLuaPath, content);

            //修改CtrlManager.lua
            string content2 = File.ReadAllText(ctrlManagerLuaPath);//Debug.Log(content);
            for (int i = 0; i < capacity; i++)
            {
                int a = content2.IndexOf("CtrlManager");
                content2 = content2.Insert(a - 1, "require \"Controller/" + nameList[i] + "Ctrl\"\r\n");
                int b = content2.IndexOf("return");
                content2 = content2.Insert(b, "ctrlList[CtrlNames." + nameList[i] + "] = " + nameList[i] + "Ctrl.New();\r\n\t");
            }
            File.WriteAllText(ctrlManagerLuaPath, content2);

            Debug.Log("修改完毕!");
        }

        EditorGUILayout.BeginHorizontal();
        startupPanel = EditorGUILayout.TextField("将Panel名字为:", startupPanel);
        if (GUILayout.Button("设置为启动Panel(修改Game.lua)"))
        {
            //修改Game.lua
            string content3 = File.ReadAllText(gameLuaPath);
            int    a        = content3.IndexOf("Game");
            content3 = content3.Insert(a, "require \"Controller/" + startupPanel + "Ctrl\"\r\n");
            int b = content3.IndexOf("local ctrl = CtrlManager.GetCtrl(CtrlNames.") + "local ctrl = CtrlManager.GetCtrl(CtrlNames.".Length;
            int c = content3.IndexOf(')', b);

            content3 = content3.Remove(b, c - b);
            content3 = content3.Insert(b, startupPanel);
            File.WriteAllText(gameLuaPath, content3);

            Debug.Log(startupPanel);
        }
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.LabelField("------------------------------------------------------------------");
        EditorGUILayout.LabelField("lua模板的位置(如不同请修改):");
        EditorGUILayout.LabelField("XXXPanel.lua" + " 路径为: " + panelLuaPath);
        EditorGUILayout.LabelField("XXXCtrl.lua" + " 路径为: " + ctrlLuaPath);
        if (GUILayout.Button("生成lua文件"))
        {
            for (int i = 0; i < capacity; i++)
            {
                string a = targetPanelLuaPath + nameList[i] + "Panel.lua";
                string b = targetCtrlLuaPath + nameList[i] + "Ctrl.lua";

                if (File.Exists(a))
                {
                    File.Delete(a);
                }
                if (File.Exists(b))
                {
                    File.Delete(b);
                }

                FileUtil.CopyFileOrDirectory(panelLuaPath, a);
                FileUtil.CopyFileOrDirectory(ctrlLuaPath, b);

                string contentA = File.ReadAllText(a);
                contentA = contentA.Replace("#SCRIPTNAME#", nameList[i] + "Panel");
                File.WriteAllText(a, contentA);

                string contentB = File.ReadAllText(b);
                contentB = contentB.Replace("#SCRIPTNAME#", nameList[i] + "Ctrl");
                File.WriteAllText(b, contentB);
            }
            AssetDatabase.Refresh();
        }

        if (GUILayout.Button("创建Panel资源文件夹"))
        {
            for (int i = 0; i < capacity; i++)
            {
                Directory.CreateDirectory(resourceBuildPath + nameList[i]);
            }
            AssetDatabase.Refresh();
        }
    }
コード例 #4
0
        private void CreateMenusGUI()
        {
            foreach (AC.Menu _menu in menus)
            {
                if (_menu == null)
                {
                    menus.Remove(_menu);
                    CleanUpAsset();
                    return;
                }

                EditorGUILayout.BeginHorizontal();

                string buttonLabel = _menu.title;
                if (buttonLabel == "")
                {
                    buttonLabel = "(Untitled)";
                }
                if (GUILayout.Toggle(_menu.isEditing, buttonLabel, "Button"))
                {
                    if (selectedMenu != _menu)
                    {
                        DeactivateAllMenus();
                        ActivateMenu(_menu);
                    }
                }

                if (GUILayout.Button(icon, GUILayout.Width(20f), GUILayout.Height(15f)))
                {
                    SideMenu(_menu);
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Create new menu"))
            {
                Undo.RecordObject(this, "Add menu");

                Menu newMenu = (Menu)CreateInstance <Menu>();
                newMenu.Declare(GetIDArray());
                menus.Add(newMenu);

                DeactivateAllMenus();
                ActivateMenu(newMenu);

                newMenu.hideFlags = HideFlags.HideInHierarchy;
                AssetDatabase.AddObjectToAsset(newMenu, this);
                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newMenu));
                AssetDatabase.SaveAssets();
                CleanUpAsset();
            }
            if (MenuManager.copiedMenu == null)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button("Paste menu"))
            {
                PasteMenu();
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();
        }
コード例 #5
0
        //void OnEnable()
        //{
        //}

        public override void OnInspectorGUI()
        {
            PunLauncher punLauncher = (PunLauncher)target;

            if (punLauncher.humanMaxNumber != punLauncher.humanPositions.Length || punLauncher.humanMaxNumber != punLauncher.humanEulerAngles.Length)
            {
                Undo.RecordObject(target, "Update Human Spawn Info");
                Array.Resize(ref punLauncher.humanPositions, punLauncher.humanMaxNumber);
                Array.Resize(ref punLauncher.humanEulerAngles, punLauncher.humanMaxNumber);
            }

            if (punLauncher.robotMaxNumber != punLauncher.robotPositions.Length || punLauncher.robotMaxNumber != punLauncher.robotEulerAngles.Length)
            {
                Undo.RecordObject(target, "Update Robot Spawn Info");
                Array.Resize(ref punLauncher.robotPositions, punLauncher.robotMaxNumber);
                Array.Resize(ref punLauncher.robotEulerAngles, punLauncher.robotMaxNumber);
            }

            base.OnInspectorGUI();

            GUILayout.Space(10);

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

                if (GUILayout.Button("Update Photon View", GUILayout.Width(200), GUILayout.Height(40)))
                {
                    Undo.RecordObject(target, "Update Photon View");

                    // Remove photon scripts
                    RemoveScripts <PhotonTransformView>();
                    RemoveScripts <LocalTransformView>();
                    RemoveScripts <PhotonRigidbodyView>();
                    RemoveScripts <PhotonView>();
                    RemoveScripts <PunOwnerChangerForObject>();

                    // Add photon scripts
                    List <GameObject> roomObjects = new List <GameObject>();

                    foreach (GameObject sourceOfSyncTarget in punLauncher.rootsOfSyncTarget)
                    {
                        Rigidbody[] syncTargetRigidbodies = sourceOfSyncTarget.GetComponentsInChildren <Rigidbody>();

                        foreach (Rigidbody syncTargetRigidbody in syncTargetRigidbodies)
                        {
                            roomObjects.Add(syncTargetRigidbody.gameObject);
                        }
                    }

                    punLauncher.SetRoomObjects(roomObjects);

                    foreach (GameObject roomObject in roomObjects)
                    {
                        PhotonView photonView = Undo.AddComponent <PhotonView>(roomObject);
                        photonView.OwnershipTransfer  = OwnershipOption.Takeover;
                        photonView.Synchronization    = ViewSynchronization.ReliableDeltaCompressed;
                        photonView.ObservedComponents = new List <Component>();

//						PhotonTransformView photonTransformView = Undo.AddComponent<PhotonTransformView>(roomObject);
                        LocalTransformView localTransformView = Undo.AddComponent <LocalTransformView>(roomObject);
//						PhotonRigidbodyView photonRigidbodyView = Undo.AddComponent<PhotonRigidbodyView>(roomObject);

//						photonView.ObservedComponents.Add(photonTransformView);
                        photonView.ObservedComponents.Add(localTransformView);
//						photonView.ObservedComponents.Add(photonRigidbodyView);

                        Undo.AddComponent <PunOwnerChangerForObject>(roomObject);
                    }
                }

                GUILayout.FlexibleSpace();
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10);
        }
コード例 #6
0
ファイル: TessellationOpHelper.cs プロジェクト: yening520/slg
        //private int m_orderIndex = 1000;

        public void Draw(UndoParentNode owner, GUIStyle toolbarstyle, Material mat, bool connectedInput)
        {
            Color cachedColor = GUI.color;

            GUI.color = new Color(cachedColor.r, cachedColor.g, cachedColor.b, 0.5f);
            EditorGUILayout.BeginHorizontal(toolbarstyle);
            GUI.color = cachedColor;
            EditorGUI.BeginChangeCheck();
            m_parentSurface.ContainerGraph.ParentWindow.ExpandedTesselation = GUILayout.Toggle(m_parentSurface.ContainerGraph.ParentWindow.ExpandedTesselation, " Tessellation", UIUtils.MenuItemToggleStyle, GUILayout.ExpandWidth(true));
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetBool("ExpandedTesselation", m_parentSurface.ContainerGraph.ParentWindow.ExpandedTesselation);
            }

            EditorGUI.BeginChangeCheck();
            m_enabled = owner.EditorGUILayoutToggle(string.Empty, m_enabled, UIUtils.MenuItemEnableStyle, GUILayout.Width(16));
            if (EditorGUI.EndChangeCheck())
            {
                if (m_enabled)
                {
                    UpdateToMaterial(mat, !connectedInput);
                }

                UIUtils.RequestSave();
            }

            EditorGUILayout.EndHorizontal();

            m_enabled = m_enabled || connectedInput;

            if (m_parentSurface.ContainerGraph.ParentWindow.ExpandedTesselation)
            {
                cachedColor = GUI.color;
                GUI.color   = new Color(cachedColor.r, cachedColor.g, cachedColor.b, (EditorGUIUtility.isProSkin ? 0.5f : 0.25f));
                EditorGUILayout.BeginVertical(UIUtils.MenuItemBackgroundStyle);
                GUI.color = cachedColor;

                EditorGUILayout.Separator();
                EditorGUI.BeginDisabledGroup(!m_enabled);

                EditorGUI.indentLevel += 1;

                m_phongEnabled = owner.EditorGUILayoutToggle(PhongEnableContent, m_phongEnabled);
                if (m_phongEnabled)
                {
                    EditorGUI.indentLevel += 1;
                    EditorGUI.BeginChangeCheck();
                    m_phongStrength = owner.EditorGUILayoutSlider(PhongStrengthContent, m_phongStrength, 0.0f, 1.0f);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(PhongStrengthUniformName))
                        {
                            mat.SetFloat(PhongStrengthUniformName, m_phongStrength);
                        }
                    }

                    EditorGUI.indentLevel -= 1;
                }

                bool guiEnabled = GUI.enabled;
                GUI.enabled = !connectedInput && m_enabled;

                m_tessType = owner.EditorGUILayoutIntPopup(TesselationTypeStr, m_tessType, TesselationTypeLabels, TesselationTypeValues);

                switch (m_tessType)
                {
                case 0:
                {
                    EditorGUI.BeginChangeCheck();
                    m_tessFactor = owner.EditorGUILayoutSlider(TessFactorContent, m_tessFactor, 1, 32);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(TessUniformName))
                        {
                            mat.SetFloat(TessUniformName, m_tessFactor);
                        }
                    }

                    EditorGUI.BeginChangeCheck();
                    m_tessMinDistance = owner.EditorGUILayoutFloatField(TessMinDistanceContent, m_tessMinDistance);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(TessMinUniformName))
                        {
                            mat.SetFloat(TessMinUniformName, m_tessMinDistance);
                        }
                    }

                    EditorGUI.BeginChangeCheck();
                    m_tessMaxDistance = owner.EditorGUILayoutFloatField(TessMaxDistanceContent, m_tessMaxDistance);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(TessMaxUniformName))
                        {
                            mat.SetFloat(TessMaxUniformName, m_tessMaxDistance);
                        }
                    }
                }
                break;

                case 1:
                {
                    EditorGUI.BeginChangeCheck();
                    m_tessFactor = owner.EditorGUILayoutSlider(TessFactorContent, m_tessFactor, 1, 32);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(TessUniformName))
                        {
                            mat.SetFloat(TessUniformName, m_tessFactor);
                        }
                    }
                }
                break;

                case 2:
                {
                    EditorGUI.BeginChangeCheck();
                    m_tessFactor = owner.EditorGUILayoutSlider(EdgeLengthContent, m_tessFactor, 2, 50);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(EdgeLengthTessUniformName))
                        {
                            mat.SetFloat(EdgeLengthTessUniformName, m_tessFactor);
                        }
                    }
                }
                break;

                case 3:
                {
                    EditorGUI.BeginChangeCheck();
                    m_tessFactor = owner.EditorGUILayoutSlider(EdgeLengthContent, m_tessFactor, 2, 50);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(EdgeLengthTessUniformName))
                        {
                            mat.SetFloat(EdgeLengthTessUniformName, m_tessFactor);
                        }
                    }

                    EditorGUI.BeginChangeCheck();
                    m_tessMaxDistance = owner.EditorGUILayoutFloatField(EdgeLengthTessMaxDisplacementContent, m_tessMaxDistance);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(TessMinUniformName))
                        {
                            mat.SetFloat(TessMinUniformName, m_tessMaxDistance);
                        }
                    }
                }
                break;
                }
                GUI.enabled            = guiEnabled;
                EditorGUI.indentLevel -= 1;
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.Separator();
                EditorGUILayout.EndVertical();
            }
        }
コード例 #7
0
    public override void OnInspectorGUI()
    {
        GameObjectPreLoadAsset script = target as GameObjectPreLoadAsset;

        EditorGUILayout.LabelField("对象池预加载对象");
        EditorGUILayout.LabelField("数量:" + script.size);
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("+"))
        {
            Undo.RegisterCompleteObjectUndo(script, "GameObjectPreLoadAsset");
            script.size += 1;
        }
        if (GUILayout.Button("-"))
        {
            Undo.RegisterCompleteObjectUndo(script, "GameObjectPreLoadAsset");
            if (script.size > 0)
            {
                script.size -= 1;
            }
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("预制体");
        EditorGUILayout.LabelField("数量");
        EditorGUILayout.EndHorizontal();

        if (script.preLoadAssetList == null)
        {
            script.preLoadAssetList = new List <GameObjectPreLoadAssetStruct>();
        }
        int i = 0;

        for (i = 0; i < script.size; i++)
        {
            if (i >= script.preLoadAssetList.Count)
            {
                GameObjectPreLoadAssetStruct preloadAsset = new GameObjectPreLoadAssetStruct();
                preloadAsset.preLoadNum = 1;
                script.preLoadAssetList.Add(preloadAsset);
            }
            EditorGUILayout.BeginHorizontal();
            script.preLoadAssetList[i].prefab     = EditorGUILayout.ObjectField(script.preLoadAssetList[i].prefab, typeof(GameObject), true) as GameObject;
            script.preLoadAssetList[i].preLoadNum = EditorGUILayout.IntField(script.preLoadAssetList[i].preLoadNum);
            if (script.preLoadAssetList[i].preLoadNum < 0)
            {
                script.preLoadAssetList[i].preLoadNum = 0;
            }
            if (GUILayout.Button("X"))
            {
                Undo.RegisterCompleteObjectUndo(script, "GameObjectPreLoadAsset");
                script.size -= 1;
                script.preLoadAssetList.RemoveAt(i);
            }
            EditorGUILayout.EndHorizontal();
        }

        if (script.preLoadAssetList.Count > 0)
        {
            script.preLoadAssetList.RemoveRange(i, script.preLoadAssetList.Count - i);
        }


        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
コード例 #8
0
    public override void OnInspectorGUI()
    {
        GUIStyle title = FlareEditorHelper.TitleStyle();

        FlareEditorHelper.DrawGuiDivider();

        EditorGUILayout.LabelField("Pro Flare Batch :", title);

        GUILayout.Space(10f);

        _ProFlareBatch = target as ProFlareBatch;
        // base.DrawDefaultInspector();

        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.LabelField("Mode", GUILayout.MaxWidth(100));

        ProFlareBatch.Mode _mode = (ProFlareBatch.Mode)EditorGUILayout.EnumPopup(_ProFlareBatch.mode);

        if (_mode != _ProFlareBatch.mode)
        {
            _ProFlareBatch.mode = _mode;

            switch (_mode)
            {
            case (ProFlareBatch.Mode.Standard): {
                _ProFlareBatch.SingleCamera_Mode = false;
                _ProFlareBatch.VR_Mode           = false;
            } break;

            case (ProFlareBatch.Mode.SingleCamera): {
                _ProFlareBatch.SingleCamera_Mode = true;
                _ProFlareBatch.VR_Mode           = false;
            } break;

            case (ProFlareBatch.Mode.VR): {
                _ProFlareBatch.SingleCamera_Mode = false;
                _ProFlareBatch.VR_Mode           = true;
            } break;
            }

            Updated = true;
        }


        EditorGUILayout.EndHorizontal();

        ProFlareAtlas _atlas = EditorGUILayout.ObjectField("Flare Atlas", _ProFlareBatch._atlas, typeof(ProFlareAtlas), false) as ProFlareAtlas;

        if (!_ProFlareBatch._atlas)
        {
            EditorGUILayout.HelpBox("Assign a Flare Atlas.", MessageType.Error, false);
        }


        Camera _camera = EditorGUILayout.ObjectField("Game Camera", _ProFlareBatch.GameCamera, typeof(Camera), true) as Camera;

        if (_camera != _ProFlareBatch.GameCamera)
        {
            Updated = true;

            _ProFlareBatch.GameCamera = _camera;

            if (_ProFlareBatch.GameCamera)
            {
                _ProFlareBatch.GameCameraTrans = _camera.transform;
            }
        }

        if (_ProFlareBatch.GameCamera == null)
        {
            EditorGUILayout.HelpBox("Assign Game Camera.", MessageType.Warning, false);
        }

        _ProFlareBatch.FlareCamera = EditorGUILayout.ObjectField("Flare Camera", _ProFlareBatch.FlareCamera, typeof(Camera), true) as Camera;

        Texture2D temp2D = null;

        if (_atlas != _ProFlareBatch._atlas)
        {
            if (_atlas == null)
            {
                _ProFlareBatch._atlas = null;
            }
            else
            if (_atlas.texture != null)
            {
                if (_ProFlareBatch.VR_Mode)
                {
                    _ProFlareBatch.name = "ProFlareBatch_VR (" + _atlas.gameObject.name + ")";
                }
                else
                {
                    _ProFlareBatch.name = "ProFlareBatch (" + _atlas.gameObject.name + ")";
                }

                _ProFlareBatch._atlas = _atlas;

                _ProFlareBatch.ForceRefresh();

                Updated = true;

                _ProFlareBatch.mat.mainTexture = _ProFlareBatch._atlas.texture;

                _ProFlareBatch.dirty = true;

                ProFlare[] flares = GameObject.FindObjectsOfType(typeof(ProFlare)) as ProFlare[];

                foreach (ProFlare flare in flares)
                {
                    flare.ReInitialise();
                }
            }
            else
            {
                Debug.LogError("ProFlares - Atlas missing texture, Atlas not assigned.");
            }
        }

        if (_ProFlareBatch.mode == ProFlareBatch.Mode.VR)
        {
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("VR Flare Depth");

            _ProFlareBatch.VR_Depth = EditorGUILayout.Slider(_ProFlareBatch.VR_Depth, 0f, 1f);

            EditorGUILayout.EndHorizontal();
        }

        if (_ProFlareBatch._atlas)
        {
            if (_ProFlareBatch.mat)
            {
                if (Application.isPlaying || (_ProFlareBatch.mat.mainTexture == null))
                {
                    if (_atlas.texture != null)
                    {
                        _ProFlareBatch.mat.mainTexture = _atlas.texture;
                    }
                }
            }


            FlareEditorHelper.DrawGuiDivider();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Connected Flares :", title);
            if (GUILayout.Button("Force Refresh", GUILayout.MaxWidth(120)))
            {
                _ProFlareBatch.ForceRefresh();

                ProFlare[] flares = GameObject.FindObjectsOfType(typeof(ProFlare)) as ProFlare[];

                foreach (ProFlare flare in flares)
                {
                    flare.ReInitialise();
                }

                Updated = true;
            }
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(9f);
            if (_ProFlareBatch.Flares.Count != _ProFlareBatch.FlareOcclusionData.Length)
            {
            }

            if (_ProFlareBatch.Flares.Count < 1)
            {
                EditorGUILayout.LabelField("No Connected flares");
            }
            else
            {
                EditorGUILayout.LabelField(_ProFlareBatch.Flares.Count.ToString() + " Flares Connected");

                if (_ProFlareBatch.Flares.Count < 10)
                {
                    _ProFlareBatch.showAllConnectedFlares = EditorGUILayout.Toggle("Show All Connected Flares", _ProFlareBatch.showAllConnectedFlares);
                }
                for (int i = 0; i < _ProFlareBatch.Flares.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();

                    if (_ProFlareBatch.FlareOcclusionData[i] == null)
                    {
                        continue;
                    }

                    if (!_ProFlareBatch.FlareOcclusionData[i].occluded)
                    {
                        EditorGUILayout.LabelField((i + 1).ToString() + " - " + _ProFlareBatch.Flares[i].gameObject.name + " - " + _ProFlareBatch.FlareOcclusionData[i]._CullingState.ToString());
                    }
                    else
                    {
                        EditorGUILayout.LabelField((i + 1).ToString() + " - " + _ProFlareBatch.Flares[i].gameObject.name + " - " + _ProFlareBatch.FlareOcclusionData[i]._CullingState.ToString() + " - " + occluded);
                    }

                    if (GUILayout.Button("Select", GUILayout.Width(60)))
                    {
                        Selection.activeGameObject = _ProFlareBatch.Flares[i].gameObject;
                    }


                    EditorGUILayout.EndHorizontal();
                    if (i > 10)
                    {
                        if (!_ProFlareBatch.showAllConnectedFlares)
                        {
                            break;
                        }
                    }
                }
            }

            FlareEditorHelper.DrawGuiDivider();
            EditorGUILayout.LabelField("Settings :", title);
            GUILayout.Space(9f);
            _ProFlareBatch.zPos = EditorGUILayout.FloatField("Z Position", _ProFlareBatch.zPos);
            FlareEditorHelper.DrawGuiDivider();
            EditorGUILayout.LabelField("Optimizations :", title);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Use Flare Culling");
            _ProFlareBatch.useCulling = EditorGUILayout.Toggle(_ProFlareBatch.useCulling);
            GUI.enabled = _ProFlareBatch.useCulling;
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Cull Flares After Seconds ");
            _ProFlareBatch.cullFlaresAfterTime = EditorGUILayout.IntField(_ProFlareBatch.cullFlaresAfterTime);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Cull Flares when can cull # Flares ");
            _ProFlareBatch.cullFlaresAfterCount = EditorGUILayout.IntField(_ProFlareBatch.cullFlaresAfterCount);
            EditorGUILayout.EndHorizontal();

            GUI.enabled = true;
            GUILayout.Space(8f);
            EditorGUILayout.BeginVertical("box");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Use Brightness Culling");
            _ProFlareBatch.useBrightnessThreshold = EditorGUILayout.Toggle(_ProFlareBatch.useBrightnessThreshold);
            EditorGUILayout.EndHorizontal();
            GUI.enabled = _ProFlareBatch.useBrightnessThreshold;
            _ProFlareBatch.BrightnessThreshold = Mathf.Clamp(EditorGUILayout.IntField("   Minimum Brightness", _ProFlareBatch.BrightnessThreshold), 0, 255);
            GUI.enabled = true;

            EditorGUILayout.EndVertical();


            if (Application.isPlaying)
            {
                GUI.enabled = false;
            }
            else
            {
                GUI.enabled = true;
            }

            FlareEditorHelper.DrawGuiDivider();

            EditorGUILayout.LabelField("Debug :", title);
            GUILayout.Space(8f);

            EditorGUILayout.BeginVertical("box");
            EditorGUILayout.LabelField("Flare Count : " + _ProFlareBatch.Flares.Count);
            EditorGUILayout.LabelField("Flare Elements : " + _ProFlareBatch.FlareElements.Count);
            //if(_ProFlareBatch.meshFilter){
            //	EditorGUILayout.LabelField("Triangle Count : " + (_ProFlareBatch.meshFilter.sharedMesh.triangles.Length/3).ToString());
            //	EditorGUILayout.LabelField("Vertex Count : " + _ProFlareBatch.meshFilter.sharedMesh.vertexCount.ToString());
            //}
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("Show Overdraw", GUILayout.MaxWidth(160));
            //_ProFlareBatch.useBrightnessThreshold = EditorGUILayout.Toggle(_ProFlareBatch.useBrightnessThreshold);
            bool overdraw = EditorGUILayout.Toggle(_ProFlareBatch.overdrawDebug);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();



            if (overdraw != _ProFlareBatch.overdrawDebug)
            {
                _ProFlareBatch.overdrawDebug = overdraw;

                if (overdraw)
                {
                    temp2D           = new Texture2D(1, 16);
                    temp2D.name      = "[Generated] Debug";
                    temp2D.hideFlags = HideFlags.DontSave;

                    for (int i = 0; i < 16; ++i)
                    {
                        temp2D.SetPixel(0, i, Color.white);
                    }

                    _ProFlareBatch.mat.mainTexture = temp2D;
                }
                else
                {
                    if (_atlas.texture != null)
                    {
                        _ProFlareBatch.mat.mainTexture = _atlas.texture;
                    }

                    if (temp2D != null)
                    {
                        Destroy(temp2D);
                    }
                }
            }
            FlareEditorHelper.DrawGuiDivider();

            if (GUI.changed || Updated)
            {
                Updated = false;
                EditorUtility.SetDirty(target);
            }
        }
    }
コード例 #9
0
        protected virtual void PrintFoldedAssertionLine(AssertionComponent assertionComponent)
        {
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.BeginVertical(GUILayout.MaxWidth(300));
            EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(300));
            PrintPath(assertionComponent.Action.go,
                      assertionComponent.Action.thisPropertyPath);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUILayout.MaxWidth(250));
            var labelStr  = assertionComponent.Action.GetType().Name;
            var labelStr2 = assertionComponent.Action.GetConfigurationDescription();

            if (labelStr2 != "")
            {
                labelStr += "( " + labelStr2 + ")";
            }
            EditorGUILayout.LabelField(labelStr);
            EditorGUILayout.EndVertical();

            if (assertionComponent.Action is ComparerBase)
            {
                var comparer = assertionComponent.Action as ComparerBase;

                var otherStrVal = "(no value selected)";
                EditorGUILayout.BeginVertical();
                EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(300));
                switch (comparer.compareToType)
                {
                case ComparerBase.CompareToType.CompareToObject:
                    if (comparer.other != null)
                    {
                        PrintPath(comparer.other,
                                  comparer.otherPropertyPath);
                    }
                    else
                    {
                        EditorGUILayout.LabelField(otherStrVal,
                                                   Styles.redLabel);
                    }
                    break;

                case ComparerBase.CompareToType.CompareToConstantValue:
                    otherStrVal = comparer.ConstValue.ToString();
                    EditorGUILayout.LabelField(otherStrVal);
                    break;

                case ComparerBase.CompareToType.CompareToNull:
                    otherStrVal = "null";
                    EditorGUILayout.LabelField(otherStrVal);
                    break;
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();
            }
            else
            {
                EditorGUILayout.LabelField("");
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
        }
コード例 #10
0
        public override void OnInspectorGUI()
        {
            this.Repaint();

#if !URP
            EditorGUILayout.HelpBox("The Universal Render Pipeline v" + AssetInfo.MIN_URP_VERSION + " is not installed", MessageType.Error);
#else
            serializedObject.Update();
            windParams = Shader.GetGlobalVector("_GlobalWindParams");

            EditorGUI.BeginChangeCheck();

            StylizedGrassGUI.ParameterGroup.DrawHeader(new GUIContent("Settings"));

            using (new EditorGUILayout.VerticalScope(StylizedGrassGUI.ParameterGroup.Section))
            {
                EditorGUILayout.PropertyField(renderExtends);
                EditorGUILayout.HelpBox("Resolution: " + StylizedGrassRenderer.CalculateResolution(renderExtends.floatValue).ToString() + "px (" + StylizedGrassRenderer.TexelsPerMeter + " texels/m)", MessageType.None);
                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.PropertyField(maskEdges);
                    if (!Application.isPlaying)
                    {
                        EditorGUILayout.HelpBox("Only takes effect in Play mode", MessageType.None);
                    }
                }
                EditorGUILayout.PropertyField(followSceneCamera);
                EditorGUILayout.PropertyField(followTarget);
                EditorGUILayout.Space();

                //renderLayer.intValue = EditorGUILayout.Popup("Render layer", renderLayer.intValue, layerStr);
                EditorGUILayout.PropertyField(colorMap);
                EditorGUILayout.PropertyField(listenToWindZone);
                using (new EditorGUILayout.HorizontalScope())
                {
                    if (listenToWindZone.boolValue)
                    {
                        EditorGUILayout.PropertyField(windZone);

                        if (!windZone.objectReferenceValue)
                        {
                            if (GUILayout.Button("Create", GUILayout.MaxWidth(75f)))
                            {
                                GameObject obj = new GameObject();
                                obj.name = "Wind Zone";
                                WindZone wz = obj.AddComponent <WindZone>();

                                windZone.objectReferenceValue = wz;
                            }
                        }
                    }
                }
            }

            EditorGUILayout.Space();

            StylizedGrassGUI.ParameterGroup.DrawHeader(new GUIContent("Grass benders (" + StylizedGrassRenderer.benderCount + ")"));

            benderScrollPos = EditorGUILayout.BeginScrollView(benderScrollPos, StylizedGrassGUI.ParameterGroup.Section, GUILayout.MaxHeight(150f));
            {
                var prevColor   = GUI.color;
                var prevBgColor = GUI.backgroundColor;
                //var rect = EditorGUILayout.BeginHorizontal();

                int i = 0;

                foreach (KeyValuePair <int, List <GrassBender> > layer in StylizedGrassRenderer.GrassBenders)
                {
                    if (StylizedGrassRenderer.GrassBenders.Count > 1)
                    {
                        EditorGUILayout.LabelField("Layer " + layer.Key, EditorStyles.boldLabel);
                    }
                    foreach (GrassBender bender in layer.Value)
                    {
                        var rect = EditorGUILayout.BeginHorizontal();
                        GUI.color = i % 2 == 0 ? Color.white * 0.66f : Color.grey * (EditorGUIUtility.isProSkin ? 1.1f : 1.5f);

                        if (rect.Contains(Event.current.mousePosition))
                        {
                            GUI.color = Color.white * 0.75f;
                        }
                        if (Selection.activeGameObject == bender.gameObject)
                        {
                            GUI.color = Color.white * 0.8f;
                        }

                        EditorGUI.DrawRect(rect, GUI.color);

                        //GUILayout.Space(5);
                        GUI.color           = prevColor;
                        GUI.backgroundColor = prevBgColor;

                        if (bender.benderType == GrassBenderBase.BenderType.Mesh)
                        {
                            benderIcon = EditorGUIUtility.IconContent("MeshRenderer Icon").image;
                        }
                        if (bender.benderType == GrassBenderBase.BenderType.Trail)
                        {
                            benderIcon = EditorGUIUtility.IconContent("TrailRenderer Icon").image;
                        }
                        if (bender.benderType == GrassBenderBase.BenderType.ParticleSystem)
                        {
                            benderIcon = EditorGUIUtility.IconContent("ParticleSystem Icon").image;
                        }

                        if (GUILayout.Button(new GUIContent(" " + bender.name, benderIcon), EditorStyles.miniLabel, GUILayout.MaxHeight(20f)))
                        {
                            Selection.activeGameObject = bender.gameObject;
                        }

                        EditorGUILayout.EndHorizontal();

                        i++;
                    }
                }
            }
            EditorGUILayout.EndScrollView();

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                if (colorMap.objectReferenceValue)
                {
                    script.colorMap.SetActive();
                }
            }

            EditorGUILayout.LabelField("- Staggart Creations -", EditorStyles.centeredGreyMiniLabel);
#endif
        }
    public void DoTerrainDescGUI()
    {
        MicroSplatTerrain bt = target as MicroSplatTerrain;
        Terrain           t  = bt.GetComponent <Terrain>();

        if (t == null || t.terrainData == null)
        {
            EditorGUILayout.HelpBox("No Terrain found, please add this component to your terrain", MessageType.Error);
            return;
        }
        if (t.materialType != Terrain.MaterialType.Custom || t.materialTemplate == null)
        {
            return;
        }

        if (!t.materialTemplate.IsKeywordEnabled("_TERRAINBLENDING") && !t.materialTemplate.IsKeywordEnabled("_DYNAMICFLOWS"))
        {
            return;
        }
        EditorGUILayout.Space();

        if (bt.terrainDesc == null)
        {
            EditorGUILayout.HelpBox("Terrain Descriptor Data is not present, please generate", MessageType.Info);
        }

        if (bt.terrainDesc != null && bt.sTerrainDirty)
        {
            EditorGUILayout.HelpBox("Terrain Descriptor data is out of date, please update", MessageType.Info);
        }
        if (GUILayout.Button(bt.terrainDesc == null ? "Generate Terrain Descriptor Data" : "Update Terrain Descriptor Data"))
        {
            GenerateTerrainBlendData(bt);
        }

        if (bt.terrainDesc != null && GUILayout.Button("Clear Terrain Descriptor Data"))
        {
            bt.terrainDesc = null;
        }

        if (bt.terrainDesc != null)
        {
            EditorGUILayout.BeginHorizontal();
            int mem = bt.terrainDesc.width * bt.terrainDesc.height;
            mem /= 128;
            EditorGUILayout.LabelField("Terrain Descriptor Data Memory: " + mem.ToString() + "kb");
            EditorGUILayout.EndHorizontal();
        }

        if (bt.blendMat == null && bt.templateMaterial != null && bt.templateMaterial.IsKeywordEnabled("_TERRAINBLENDING"))
        {
            var path = AssetDatabase.GetAssetPath(bt.templateMaterial);
            path        = path.Replace(".mat", "_TerrainObjectBlend.mat");
            bt.blendMat = AssetDatabase.LoadAssetAtPath <Material>(path);
            if (bt.blendMat == null)
            {
                string shaderPath = path.Replace(".mat", ".shader");
                Shader shader     = AssetDatabase.LoadAssetAtPath <Shader>(shaderPath);
                if (shader != null)
                {
                    Material mat = new Material(shader);
                    AssetDatabase.CreateAsset(mat, path);
                    AssetDatabase.SaveAssets();
                    MicroSplatTerrain.SyncAll();
                }
            }
        }
    }
コード例 #12
0
        // GUI
        //------------------------------------------------------------------------------------------------
        private void OnGUI()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

            width -= 10;

            //만약 이 다이얼로그가 켜진 상태로 뭔가 바뀌었다면 종료
            bool isClose                  = false;
            bool isMoveAnimKeyframe       = false;
            bool isMoveAnimKeyframeToNext = false;

            if (_editor == null || _meshGroup == null || _modifier == null || _modMesh == null || _renderUnit == null)
            {
                //데이터가 없다.
                isClose = true;
            }
            else if (_editor.Select.SelectionType != _selectionType)
            {
                //선택 타입이 바뀌었다.
                isClose = true;
            }
            else
            {
                if (!_isAnimEdit)
                {
                    //1. 일반 모디파이어 편집시
                    //- 현재 선택된 MeshGroup이 바뀌었다면
                    //- 현재 선택된 Modifier가 바뀌었다면
                    //- Modifier 메뉴가 아니라면
                    //- ExEditingMode가 꺼졌다면
                    //> 해제
                    if (_editor.Select.ExEditingMode == apSelection.EX_EDIT.None ||
                        _editor.Select.MeshGroup != _meshGroup ||
                        _editor.Select.Modifier != _modifier ||
                        _editor._meshGroupEditMode != apEditor.MESHGROUP_EDIT_MODE.Modifier)
                    {
                        isClose = true;
                    }
                }
                else
                {
                    //2. 애니메이션 편집 시
                    //- 현재 선택된 AnimationClip이 바뀌었다면
                    //- 현재 선택된 MeshGroup이 바뀌었다면 (AnimClip이 있을 때)
                    //- AnimExEditingMode가 꺼졌다면
                    //- 재생 중이라면
                    //> 해제
                    if (_editor.Select.ExAnimEditingMode == apSelection.EX_EDIT.None ||
                        _editor.Select.AnimClip != _animClip ||
                        _animClip == null ||
                        _keyframe == null ||
                        _editor.Select.AnimClip._targetMeshGroup != _meshGroup ||
                        _editor.Select.IsAnimPlaying)
                    {
                        isClose = true;
                    }
                }
            }

            if (isClose)
            {
                CloseDialog();
                return;
            }


            //------------------------------------------------------------

            //1. 선택된 객체 정보
            //- RenderUnit 아이콘과 이름

            //2. <애니메이션인 경우>
            //- 현재 키프레임과 키프레임 이동하기

            //3. 가중치
            //- [일반] Weight CutOut
            //- [Anim] Prev / Next CutOut

            // (구분선)

            //4. Depth
            //- 아이콘과 Chainging Depth 레이블
            //- On / Off 버튼
            //- Depth 증감과 리스트 (좌우에 배치)

            //5. Texture (RenderUnit이 MeshTransform인 경우)
            //- 현재 텍스쳐
            //- 바뀔 텍스쳐
            //- 텍스쳐 선택하기 버튼

            //1. 선택된 객체 정보
            //- RenderUnit 아이콘과 이름
            //int iconSize = 25;
            GUIStyle guiStyle_TargetBox = new GUIStyle(GUI.skin.box);

            guiStyle_TargetBox.alignment = TextAnchor.MiddleCenter;
            Color prevColor = GUI.backgroundColor;

            // RenderUnit 이름
            Texture2D iconRenderUnit = null;

            if (_renderUnit._meshTransform != null)
            {
                iconRenderUnit = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Mesh);
            }
            else
            {
                iconRenderUnit = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_MeshGroup);
            }
            GUI.backgroundColor = new Color(0.5f, 1.0f, 1.0f, 1.0f);
            GUILayout.Box(new GUIContent("  " + _renderUnit.Name, iconRenderUnit), guiStyle_TargetBox, GUILayout.Width(width), GUILayout.Height(30));
            GUI.backgroundColor = prevColor;

            GUILayout.Space(5);

            //"Extra Property ON", "Extra Property OFF"
            if (apEditorUtil.ToggledButton_2Side(_editor.GetText(TEXT.ExtraOpt_ExtraPropertyOn), _editor.GetText(TEXT.ExtraOpt_ExtraPropertyOff), _modMesh._isExtraValueEnabled, true, width, 25))
            {
                apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);

                _modMesh._isExtraValueEnabled = !_modMesh._isExtraValueEnabled;
                _meshGroup.RefreshModifierLink();                //<<옵션의 형태가 바뀌면 Modifier의 Link를 다시 해야한다.
                apEditorUtil.ReleaseGUIFocus();
            }

            GUILayout.Space(5);

            if (_isAnimEdit)
            {
                GUILayout.Space(10);

                //2. <애니메이션인 경우>
                //- 현재 키프레임과 키프레임 이동하기

                //"Target Frame"
                EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_TargetFrame));
                int frameBtnSize      = 20;
                int frameCurBtnWidth  = 100;
                int frameMoveBtnWidth = (width - (10 + frameCurBtnWidth)) / 2;
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(frameBtnSize));
                GUILayout.Space(5);
                if (GUILayout.Button(_editor.ImageSet.Get(apImageSet.PRESET.Anim_MoveToPrevFrame), GUILayout.Width(frameMoveBtnWidth), GUILayout.Height(frameBtnSize)))
                {
                    //이전 프레임으로 이동하기
                    isMoveAnimKeyframe       = true;
                    isMoveAnimKeyframeToNext = false;
                }
                if (GUILayout.Button(_keyframe._frameIndex.ToString(), GUILayout.Width(frameCurBtnWidth), GUILayout.Height(frameBtnSize)))
                {
                    _animClip.SetFrame_Editor(_keyframe._frameIndex);
                    _editor.SetRepaint();
                }
                if (GUILayout.Button(_editor.ImageSet.Get(apImageSet.PRESET.Anim_MoveToNextFrame), GUILayout.Width(frameMoveBtnWidth), GUILayout.Height(frameBtnSize)))
                {
                    //다음 프레임으로 이동하기
                    isMoveAnimKeyframe       = true;
                    isMoveAnimKeyframeToNext = true;
                }

                EditorGUILayout.EndHorizontal();
            }

            GUILayout.Space(10);

            //3. 가중치
            //- [일반] Weight CutOut
            //- [Anim] Prev / Next CutOut

            EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_WeightSettings));            //"Weight Settings"
            GUILayout.Space(5);
            if (!_isAnimEdit)
            {
                //일반이면 CutOut이 1개
                float cutOut = EditorGUILayout.DelayedFloatField(_editor.GetText(TEXT.ExtraOpt_Offset), _modMesh._extraValue._weightCutout);                //"Offset (0~1)"

                if (cutOut != _modMesh._extraValue._weightCutout)
                {
                    cutOut = Mathf.Clamp01(cutOut);
                    apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);

                    _modMesh._extraValue._weightCutout = cutOut;
                    apEditorUtil.ReleaseGUIFocus();
                }
            }
            else
            {
                //애니메이션이면 CutOut이 2개
                EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_Offset));
                float animPrevCutOut = EditorGUILayout.DelayedFloatField(_editor.GetText(TEXT.ExtraOpt_OffsetPrevKeyframe), _modMesh._extraValue._weightCutout_AnimPrev);                //"Prev Keyframe"
                float animNextCutOut = EditorGUILayout.DelayedFloatField(_editor.GetText(TEXT.ExtraOpt_OffsetNextKeyframe), _modMesh._extraValue._weightCutout_AnimNext);                //"Next Keyframe"

                if (animPrevCutOut != _modMesh._extraValue._weightCutout_AnimPrev ||
                    animNextCutOut != _modMesh._extraValue._weightCutout_AnimNext
                    )
                {
                    animPrevCutOut = Mathf.Clamp01(animPrevCutOut);
                    animNextCutOut = Mathf.Clamp01(animNextCutOut);
                    apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);

                    _modMesh._extraValue._weightCutout_AnimPrev = animPrevCutOut;
                    _modMesh._extraValue._weightCutout_AnimNext = animNextCutOut;
                    apEditorUtil.ReleaseGUIFocus();
                }
            }

            GUILayout.Space(10);
            apEditorUtil.GUI_DelimeterBoxH(width);
            GUILayout.Space(10);

            int tabBtnWidth  = ((width - 10) / 2);
            int tabBtnHeight = 25;

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(tabBtnHeight));
            GUILayout.Space(5);
            if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.ExtraOpt_Tab_Depth), _tab == TAB.Depth, tabBtnWidth, tabBtnHeight))           //"Depth"
            {
                _tab = TAB.Depth;
            }
            if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.ExtraOpt_Tab_Image), _tab == TAB.Image, tabBtnWidth, tabBtnHeight))           //"Image"
            {
                _tab = TAB.Image;
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10);

            if (_tab == TAB.Depth)
            {
                //4. Depth
                //- 아이콘과 Chainging Depth 레이블
                //- On / Off 버튼
                //- Depth 증감과 리스트 (좌우에 배치)

                EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_ChangingDepth));                //"Changing Depth"
                GUILayout.Space(5);

                //"Depth Option ON", "Depth Option OFF"
                if (apEditorUtil.ToggledButton_2Side(_editor.GetText(TEXT.ExtraOpt_DepthOptOn), _editor.GetText(TEXT.ExtraOpt_DepthOptOff), _modMesh._extraValue._isDepthChanged, _modMesh._isExtraValueEnabled, width, 25))
                {
                    apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);

                    _modMesh._extraValue._isDepthChanged = !_modMesh._extraValue._isDepthChanged;
                    _meshGroup.RefreshModifierLink();                    //<<Modifier Link를 다시 해야한다.
                    _editor.SetRepaint();
                }
                GUILayout.Space(5);

                bool isDepthAvailable = _modMesh._extraValue._isDepthChanged && _modMesh._isExtraValueEnabled;

                int depthListWidth_Left       = 80;
                int depthListWidth_Right      = width - (10 + depthListWidth_Left);
                int depthListWidth_RightInner = depthListWidth_Right - 20;
                int depthListHeight           = 276;
                //int depthListHeight_LeftBtn = (depthListHeight - 40) / 2;
                int depthListHeight_LeftBtn   = 40;
                int depthListHeight_LeftSpace = (depthListHeight - (40 + depthListHeight_LeftBtn * 2)) / 2;
                int depthListHeight_RightList = 20;

                //리스트 배경
                Rect lastRect = GUILayoutUtility.GetLastRect();
                if (!isDepthAvailable)
                {
                    GUI.backgroundColor = new Color(1.0f, 0.6f, 0.6f, 1.0f);
                }
                GUI.Box(new Rect(5 + depthListWidth_Left + 8, lastRect.y + 8, depthListWidth_Right, depthListHeight), "");
                if (!isDepthAvailable)
                {
                    GUI.backgroundColor = prevColor;
                }

                EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(depthListHeight));
                GUILayout.Space(5);
                EditorGUILayout.BeginVertical(GUILayout.Width(depthListWidth_Left), GUILayout.Height(depthListHeight));
                // Depth List의 왼쪽
                // Depth 증감 버튼과 값
                GUILayout.Space(depthListHeight_LeftSpace);

                Texture2D img_AddWeight      = _editor.ImageSet.Get(apImageSet.PRESET.Rig_AddWeight);
                Texture2D img_SubtractWeight = _editor.ImageSet.Get(apImageSet.PRESET.Rig_SubtractWeight);


                //if (GUILayout.Button(, GUILayout.Width(depthListWidth_Left), GUILayout.Height(depthListHeight_LeftBtn)))
                if (apEditorUtil.ToggledButton(img_AddWeight, false, isDepthAvailable, depthListWidth_Left, depthListHeight_LeftBtn))
                {
                    //Depth 증가
                    apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);
                    _modMesh._extraValue._deltaDepth++;
                    _editor.SetRepaint();
                    apEditorUtil.ReleaseGUIFocus();
                }

                //"Delta Depth"
                EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_DeltaDepth), GUILayout.Width(depthListWidth_Left));
                int deltaDepth = EditorGUILayout.DelayedIntField(_modMesh._extraValue._deltaDepth, GUILayout.Width(depthListWidth_Left));
                if (deltaDepth != _modMesh._extraValue._deltaDepth)
                {
                    if (isDepthAvailable)
                    {
                        apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);
                        _modMesh._extraValue._deltaDepth = deltaDepth;
                        _editor.SetRepaint();
                        apEditorUtil.ReleaseGUIFocus();
                    }
                }

                //if (GUILayout.Button(_editor.ImageSet.Get(apImageSet.PRESET.Rig_SubtractWeight), GUILayout.Width(depthListWidth_Left), GUILayout.Height(depthListHeight_LeftBtn)))
                if (apEditorUtil.ToggledButton(img_SubtractWeight, false, isDepthAvailable, depthListWidth_Left, depthListHeight_LeftBtn))
                {
                    //Depth 감소
                    apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);
                    _modMesh._extraValue._deltaDepth--;
                    _editor.SetRepaint();
                    apEditorUtil.ReleaseGUIFocus();
                }

                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(GUILayout.Width(depthListWidth_Right), GUILayout.Height(depthListHeight));
                // RenderUnit 리스트와 변환될 Depth 위치
                _scrollList = EditorGUILayout.BeginScrollView(_scrollList, false, true, GUILayout.Width(depthListWidth_Right), GUILayout.Height(depthListHeight));

                EditorGUILayout.BeginVertical(GUILayout.Width(depthListWidth_RightInner), GUILayout.Height(depthListHeight));
                GUILayout.Space(5);

                SubUnit curSubUnit = null;



                //int cursorDepth = _renderUnit.GetDepth() + _modMesh._extraValue._deltaDepth;
                int cursorDepth = _targetDepth + _modMesh._extraValue._deltaDepth;

                //GUI Content 생성 [11.16 수정]
                if (_guiContent_DepthMidCursor == null)
                {
                    _guiContent_DepthMidCursor = apGUIContentWrapper.Make(_img_DepthMidCursor);
                }
                if (_guiContent_DepthCursor == null)
                {
                    _guiContent_DepthCursor = apGUIContentWrapper.Make(_img_DepthCursor);
                }
                if (_guiContent_MeshIcon == null)
                {
                    _guiContent_MeshIcon = apGUIContentWrapper.Make(_img_MeshTF);
                }
                if (_guiContent_MeshGroupIcon == null)
                {
                    _guiContent_MeshGroupIcon = apGUIContentWrapper.Make(_img_MeshGroupTF);
                }
                //이전 코드
                //GUIContent guiContent_DepthMidCursor = new GUIContent(_img_DepthMidCursor);
                //GUIContent guiContent_DepthCursor = new GUIContent(_img_DepthCursor);
                //GUIContent guiContent_MeshIcon = new GUIContent(_img_MeshTF);
                //GUIContent guiContent_MeshGroupIcon = new GUIContent(_img_MeshGroupTF);

                int depthCursorSize = depthListHeight_RightList;

                for (int i = 0; i < _subUnits_All.Count; i++)
                {
                    curSubUnit = _subUnits_All[i];

                    if (curSubUnit._isTarget)
                    {
                        //타겟이면 배경색을 그려주자
                        lastRect = GUILayoutUtility.GetLastRect();
                        if (EditorGUIUtility.isProSkin)
                        {
                            GUI.backgroundColor = new Color(0.0f, 1.0f, 1.0f, 1.0f);
                        }
                        else
                        {
                            GUI.backgroundColor = new Color(0.4f, 0.8f, 1.0f, 1.0f);
                        }

                        int yOffset = 6;
                        if (i == 0)
                        {
                            yOffset = 7 - depthListHeight_RightList;
                        }
                        GUI.Box(new Rect(lastRect.x, lastRect.y + depthListHeight_RightList + yOffset, depthListWidth_RightInner + 10, depthListHeight_RightList), "");
                        GUI.backgroundColor = prevColor;
                    }

                    EditorGUILayout.BeginHorizontal(GUILayout.Width(depthListWidth_RightInner), GUILayout.Height(depthListHeight_RightList));


                    //TODO : Depth 커서 그려주기
                    //GUILayout.Space(20);

                    DEPTH_CURSOR_TYPE depthCursorType = DEPTH_CURSOR_TYPE.None;
                    if (!curSubUnit._isTarget)
                    {
                        if (cursorDepth != _targetDepth)
                        {
                            if (cursorDepth == curSubUnit._depth)
                            {
                                depthCursorType = DEPTH_CURSOR_TYPE.Target;
                            }
                            else
                            {
                                if (cursorDepth > _targetDepth)
                                {
                                    //Depth가 증가했을 때
                                    if (_targetDepth < curSubUnit._depth && curSubUnit._depth < cursorDepth)
                                    {
                                        depthCursorType = DEPTH_CURSOR_TYPE.Mid;
                                    }
                                }
                                else
                                {
                                    //Depth가 감소했을 때
                                    if (cursorDepth < curSubUnit._depth && curSubUnit._depth < _targetDepth)
                                    {
                                        depthCursorType = DEPTH_CURSOR_TYPE.Mid;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (cursorDepth != _targetDepth)
                        {
                            depthCursorType = DEPTH_CURSOR_TYPE.Mid;
                        }
                        else
                        {
                            depthCursorType = DEPTH_CURSOR_TYPE.Target;
                        }
                    }
                    GUILayout.Space(5);
                    switch (depthCursorType)
                    {
                    case DEPTH_CURSOR_TYPE.None:
                        GUILayout.Space(depthCursorSize + 4);
                        break;

                    case DEPTH_CURSOR_TYPE.Mid:
                        EditorGUILayout.LabelField(_guiContent_DepthMidCursor.Content, GUILayout.Width(depthCursorSize), GUILayout.Height(depthCursorSize));
                        break;

                    case DEPTH_CURSOR_TYPE.Target:
                        EditorGUILayout.LabelField(_guiContent_DepthCursor.Content, GUILayout.Width(depthCursorSize), GUILayout.Height(depthCursorSize));
                        break;
                    }

                    EditorGUILayout.LabelField(curSubUnit._isMeshTransform ? _guiContent_MeshIcon.Content : _guiContent_MeshGroupIcon.Content, GUILayout.Width(depthCursorSize), GUILayout.Height(depthCursorSize));
                    EditorGUILayout.LabelField(curSubUnit._depth.ToString(), GUILayout.Width(20), GUILayout.Height(depthListHeight_RightList));
                    EditorGUILayout.LabelField(curSubUnit._name,
                                               GUILayout.Width(depthListWidth_RightInner - (24 + 5 + depthCursorSize + depthCursorSize + 20 + 8)),
                                               GUILayout.Height(depthListHeight_RightList)
                                               );

                    EditorGUILayout.EndHorizontal();
                }

                GUILayout.Space(depthListHeight + 100);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndScrollView();
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndHorizontal();
            }
            else
            {
                //5. Texture (RenderUnit이 MeshTransform인 경우)
                //- 현재 텍스쳐
                //- 바뀔 텍스쳐
                //- 텍스쳐 선택하기 버튼

                //"Changing Image"
                EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_ChangingImage));
                GUILayout.Space(5);

                //"Image Option ON", "Image Option OFF"
                if (apEditorUtil.ToggledButton_2Side(_editor.GetText(TEXT.ExtraOpt_ImageOptOn), _editor.GetText(TEXT.ExtraOpt_ImageOptOff), _modMesh._extraValue._isTextureChanged, _isImageChangable && _modMesh._isExtraValueEnabled, width, 25))
                {
                    apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);

                    _modMesh._extraValue._isTextureChanged = !_modMesh._extraValue._isTextureChanged;
                    _meshGroup.RefreshModifierLink();                    //<<Modifier Link를 다시 해야한다.
                    _editor.SetRepaint();
                }
                GUILayout.Space(5);

                bool isTextureAvailable = _modMesh._extraValue._isTextureChanged && _isImageChangable && _modMesh._isExtraValueEnabled;

                int imageSlotSize      = 170;
                int imageSlotSpaceSize = width - (imageSlotSize * 2 + 6 + 10);
                int imageSlotHeight    = imageSlotSize + 50;

                Texture2D img_Src    = null;
                Texture2D img_Dst    = null;
                string    strSrcName = "< None >";
                string    strDstName = "< None >";

                if (_srcTexureData != null && _srcTexureData._image != null)
                {
                    img_Src    = _srcTexureData._image;
                    strSrcName = _srcTexureData._name;
                }
                if (_dstTexureData != null && _dstTexureData._image != null)
                {
                    img_Dst    = _dstTexureData._image;
                    strDstName = _dstTexureData._name;
                }

                GUIStyle guiStyle_ImageSlot = new GUIStyle(GUI.skin.box);
                guiStyle_ImageSlot.alignment = TextAnchor.MiddleCenter;

                GUIStyle guiStyle_ImageName = new GUIStyle(GUI.skin.label);
                guiStyle_ImageName.alignment = TextAnchor.MiddleCenter;

                EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(imageSlotHeight));
                GUILayout.Space(5);

                //이미지 슬롯 1 : 원래 이미지
                EditorGUILayout.BeginVertical(GUILayout.Width(imageSlotSize), GUILayout.Height(imageSlotHeight));
                //"Original"
                EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_SlotOriginal), GUILayout.Width(imageSlotSize));
                GUILayout.Box(img_Src, guiStyle_ImageSlot, GUILayout.Width(imageSlotSize), GUILayout.Height(imageSlotSize));
                GUILayout.Space(5);
                EditorGUILayout.LabelField(strSrcName, guiStyle_ImageName, GUILayout.Width(imageSlotSize));
                EditorGUILayout.EndVertical();

                GUILayout.Space(imageSlotSpaceSize);

                //이미지 슬롯 1 : 원래 이미지
                EditorGUILayout.BeginVertical(GUILayout.Width(imageSlotSize), GUILayout.Height(imageSlotHeight));
                //"Changed"
                EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_SlotChanged), GUILayout.Width(imageSlotSize));
                GUILayout.Box(img_Dst, guiStyle_ImageSlot, GUILayout.Width(imageSlotSize), GUILayout.Height(imageSlotSize));
                GUILayout.Space(5);
                EditorGUILayout.LabelField(strDstName, guiStyle_ImageName, GUILayout.Width(imageSlotSize));
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndHorizontal();
                //"Set Image"
                if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.ExtraOpt_SelectImage), false, isTextureAvailable, width, 30))
                {
                    //이미지 열기 열기
                    _loadKey_TextureSelect = apDialog_SelectTextureData.ShowDialog(_editor, null, OnTextureDataSelected);
                }
                //"Reset Image"
                if (GUILayout.Button(_editor.GetText(TEXT.ExtraOpt_ResetImage), GUILayout.Width(width), GUILayout.Height(20)))
                {
                    apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);
                    _modMesh._extraValue._textureDataID     = -1;
                    _modMesh._extraValue._linkedTextureData = null;

                    RefreshImagePreview();

                    Repaint();
                }
            }

            GUILayout.Space(10);
            apEditorUtil.GUI_DelimeterBoxH(width);
            GUILayout.Space(10);
            //"Close"
            if (GUILayout.Button(_editor.GetText(TEXT.Close), GUILayout.Height(30)))
            {
                isClose = true;
            }
            if (isClose)
            {
                CloseDialog();
            }

            if (isMoveAnimKeyframe)
            {
                //키프레임 이동의 경우,
                //타임라인 레이어를 따라서 전,후로 이동한다.
                //이때 ModMesh가 아예 바뀌기 때문에 여기서 처리해야한다.
                if (_keyframe != null && _keyframe._parentTimelineLayer != null && _animClip != null)
                {
                    apAnimKeyframe moveKeyframe = (isMoveAnimKeyframeToNext ? _keyframe._nextLinkedKeyframe : _keyframe._prevLinkedKeyframe);
                    if (moveKeyframe != null && moveKeyframe._linkedModMesh_Editor != null)
                    {
                        _keyframe = moveKeyframe;
                        _modMesh  = _keyframe._linkedModMesh_Editor;
                        _animClip.SetFrame_Editor(moveKeyframe._frameIndex);

                        RefreshImagePreview();

                        apEditorUtil.ReleaseGUIFocus();

                        Repaint();
                        _editor.SetRepaint();
                    }
                }
            }
        }
コード例 #13
0
    void EditorDataGUI()
    {
        m_isEditorFold = EditorGUILayout.Foldout(m_isEditorFold, "编辑数据");
        EditorGUI.indentLevel ++;

        if (m_isEditorFold)
        {
            List<string> keys = m_currentData.TableKeys;
            m_EditorPos = EditorGUILayout.BeginScrollView(m_EditorPos, GUILayout.ExpandHeight(false));
            for (int i = 0; i < keys.Count; i++)
            {
                string key = keys[i];
                FieldType type = m_currentData.GetFieldType(key);
                int EnumTypeIndex = EditorTool.GetAllEnumTypeIndex(m_currentData.GetEnumType(key));

                if (i == 0)
                {
                    EditorGUILayout.LabelField("<主键>字段名", key);
                    EditorGUILayout.LabelField("字段类型", m_currentData.GetFieldType(keys[i]).ToString());
                }
                else
                {
                    EditorGUILayout.BeginHorizontal();

                    EditorGUILayout.LabelField("字段名", key);

                    if(GUILayout.Button("删除字段"))
                    {
                        if (EditorUtility.DisplayDialog("警告", "确定要删除该字段吗?", "是", "取消"))
                        {
                            DeleteField(m_currentData, key);
                            continue;
                        }
                    }

                    EditorGUILayout.EndHorizontal();

                    bool isNewType = false;

                    m_editorNoteContent = EditorGUILayout.TextField("注释", m_currentData.GetNote(key));
                    m_currentData.SetNote(key, m_editorNoteContent);

                    m_editorNewType = (FieldType)EditorGUILayout.EnumPopup("字段类型", type);

                    if (m_editorNewType == FieldType.Enum)
                    {
                        m_editorNewEnumIndex = EditorGUILayout.Popup("枚举类型", EnumTypeIndex, EditorTool.GetAllEnumType());

                        if (EnumTypeIndex != m_editorNewEnumIndex)
                        {
                            isNewType = true;
                        }
                    }

                    if (type != m_editorNewType)
                    {
                        isNewType = true;
                    }

                    if (isNewType)
                    {
                        //弹出警告并重置数据
                        if (EditorUtility.DisplayDialog("警告", "改变字段类型会重置该字段的所有数据和默认值\n是否继续?", "是", "取消"))
                        {
                            m_currentData.SetFieldType(key, m_editorNewType, EditorTool.GetAllEnumType()[m_editorNewEnumIndex]);
                            ResetDataField(m_currentData, key, m_editorNewType, EditorTool.GetAllEnumType()[m_editorNewEnumIndex]);

                             type = m_editorNewType;
                             EnumTypeIndex = m_editorNewEnumIndex;
                             content = new SingleData();
                        }
                    }

                    string newContent;
                    if (type == FieldType.Enum)
                    {
                        newContent = EditorUtilGUI.FieldGUI_Type(type, EditorTool.GetAllEnumType()[EnumTypeIndex], m_currentData.GetDefault(key), "默认值");
                    }
                    else
                    {
                        newContent = EditorUtilGUI.FieldGUI_Type(type, null, m_currentData.GetDefault(key), "默认值");
                    }

                    m_currentData.SetDefault(key, newContent);
                }

                EditorGUILayout.Space();
            }

            EditorGUILayout.EndScrollView();

            AddFieldGUI();
        }
    }
コード例 #14
0
    SingleData EditorDataGUI(DataTable table, SingleData data)
    {
        try
        {
            List<string> keys = table.TableKeys;
            for (int i = 0; i < keys.Count; i++)
            {
                string keyTmp = keys[i];
                FieldType type = table.GetFieldType(keyTmp);

                if (i != 0)
                {
                    bool cancelDefault = false;
                    EditorGUILayout.BeginHorizontal();
                    
                    if (data.ContainsKey(keyTmp))
                    {
                        EditorGUILayout.LabelField("[" + keyTmp + "]");

                        if (GUILayout.Button("使用默认值"))
                        {
                            data.Remove(keyTmp);
                            EditorGUILayout.EndHorizontal();

                            continue;
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("[" + keyTmp + "] (默认值)");
                        if (GUILayout.Button("取消默认值"))
                        {
                            cancelDefault = true;
                        }
                    }

                    EditorGUILayout.EndHorizontal();

                    //EditorGUI.indentLevel++;
                    EditorGUI.indentLevel++;

                    //非默认值情况
                    if (data.ContainsKey(keyTmp))
                    {
                        EditorGUILayout.LabelField("字段名", keyTmp);
                        EditorGUILayout.LabelField("注释", table.GetNote(keyTmp));

                        string newContent = EditorUtilGUI.FieldGUI_TypeValue(type, data[keyTmp], table.GetEnumType(keyTmp));

                        if (newContent != data[keyTmp])
                        {
                            data[keyTmp] = newContent;
                        }
                    }
                    //如果是默认值则走这里
                    else
                    {
                        EditorGUILayout.LabelField("字段名", keyTmp);
                        EditorGUILayout.LabelField("注释", table.GetNote(keyTmp));
                        string newContent = "";

                        if (table.m_defaultValue.ContainsKey(keyTmp))
                        {
                            newContent = new SingleField(type, table.GetDefault(keyTmp), table.GetEnumType(keyTmp)).m_content;
                        }
                        else
                        {
                            newContent = new SingleField(type, null, table.GetEnumType(keyTmp)).m_content;
                        }

                        if (type != FieldType.Enum)
                        {
                            EditorGUILayout.LabelField("字段类型", type.ToString());
                        }
                        else
                        {
                            EditorGUILayout.LabelField("字段类型", type.ToString() + "/" + table.GetEnumType(keyTmp));
                        }

                        EditorGUILayout.LabelField("(默认)字段内容", new SingleField(type, newContent, table.GetEnumType(keyTmp)).GetShowString());

                        if (cancelDefault)
                        {
                            data.Add(keyTmp, newContent);
                        }
                    }

                    EditorGUI.indentLevel--;
                    //EditorGUI.indentLevel--;
                }

                EditorGUILayout.Space();
            }
        }
        catch(Exception e)
        {
            EditorGUILayout.TextArea(e.ToString());
        }

        return data;
    }
コード例 #15
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        var playback = (PlaybackManager)target;

        var isPlaying     = playback.Playhead != null && playback.Playhead.IsPlaying;
        var playingString = isPlaying ? "Playing" : "Stopped";
        var timeString    = "-";
        var beatString    = "-";
        var measureString = "-";

        if (isPlaying)
        {
            timeString = string.Format("{0:F} s", playback.Playhead.CurrentTime);

            if (playback.Playhead.CurrentBeat < 0)
            {
                beatString    = "Delayed";
                measureString = "Delayed";
            }
            else
            {
                beatString = string.Format("{0:00}.{1:0}", playback.Playhead.CurrentBeat,
                                           playback.Playhead.CurrentSubdivision);
                measureString = string.Format("{0:00}:{1:0} {2}", playback.Playhead.CurrentMeasure + 1,
                                              playback.Playhead.CurrentMeasureBeat + 1, playback.Playhead.CurrentMeasureBeat == 0 ? '*' : ' ');
            }
        }

        EditorGUILayout.Space();

        var restoreEnabled = GUI.enabled;

        GUI.enabled = Application.isPlaying && !isPlaying;
        if (GUILayout.Button("Play"))
        {
            playback.Play();
        }
        GUI.enabled = restoreEnabled;

        GUILayout.BeginVertical(GUI.skin.box);
        {
            GUILayout.Label(playingString, EditorStyles.boldLabel);
            EditorGUILayout.LabelField("Time", timeString);
            EditorGUILayout.LabelField("Beat/Subdivision", beatString);
            EditorGUILayout.LabelField("Measure", measureString);

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            {
                _beatInput = EditorGUILayout.IntField(_beatInput);
                GUILayout.Label(".");
                _subdivInput = EditorGUILayout.IntField(_subdivInput);
                GUILayout.Space(7);

                restoreEnabled = GUI.enabled;
                GUI.enabled    = Application.isPlaying &&
                                 playback.Playhead != null &&
                                 (_beatInput > playback.Playhead.CurrentBeat ||
                                  (_beatInput == playback.Playhead.CurrentBeat &&
                                   _subdivInput > playback.Playhead.CurrentSubdivision));
                if (GUILayout.Button("Skip Forward", EditorStyles.miniButton) && playback.Playhead != null)
                {
                    playback.Playhead.SeekTo(_beatInput, _subdivInput);
                }
                GUI.enabled = restoreEnabled;
            }
            EditorGUILayout.EndHorizontal();
        }
        GUILayout.EndVertical();
    }
コード例 #16
0
        public void Render(IEnumerable <AssertionComponent> allAssertions, List <string> foldMarkers)
        {
            foreach (var grouping in GroupResult(allAssertions))
            {
                var  key      = GetStringKey(grouping.Key);
                bool isFolded = foldMarkers.Contains(key);
                if (key != "")
                {
                    EditorGUILayout.BeginHorizontal();

                    EditorGUI.BeginChangeCheck();
                    isFolded = PrintFoldout(isFolded,
                                            grouping.Key);
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (isFolded)
                        {
                            foldMarkers.Add(key);
                        }
                        else
                        {
                            foldMarkers.Remove(key);
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                    if (isFolded)
                    {
                        continue;
                    }
                }
                foreach (var assertionComponent in grouping)
                {
                    EditorGUILayout.BeginVertical();
                    EditorGUILayout.BeginHorizontal();

                    if (key != "")
                    {
                        GUILayout.Space(15);
                    }

                    var  assertionKey    = assertionComponent.GetHashCode().ToString();
                    bool isDetailsFolded = foldMarkers.Contains(assertionKey);

                    EditorGUI.BeginChangeCheck();
                    if (GUILayout.Button("",
                                         EditorStyles.foldout,
                                         GUILayout.Width(15)))
                    {
                        isDetailsFolded = !isDetailsFolded;
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (isDetailsFolded)
                        {
                            foldMarkers.Add(assertionKey);
                        }
                        else
                        {
                            foldMarkers.Remove(assertionKey);
                        }
                    }
                    PrintFoldedAssertionLine(assertionComponent);
                    EditorGUILayout.EndHorizontal();

                    if (isDetailsFolded)
                    {
                        EditorGUILayout.BeginHorizontal();
                        if (key != "")
                        {
                            GUILayout.Space(15);
                        }
                        PrintAssertionLineDetails(assertionComponent);
                        EditorGUILayout.EndHorizontal();
                    }
                    GUILayout.Box("", new[] { GUILayout.ExpandWidth(true), GUILayout.Height(1) });

                    EditorGUILayout.EndVertical();
                }
            }
        }
コード例 #17
0
ファイル: MemberList.cs プロジェクト: d5j6/tntdoc_github
    public void OnGUI()
    {
        EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(false), GUILayout.Width(DocBrowser.kListWidth));

        ToolbarGUI();

        EditorGUILayout.BeginVertical(DocBrowser.styles.frameWithMargin);

        // List header
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Name", DocBrowser.styles.columnHeader, GUILayout.ExpandWidth(true));
        GUILayout.Label("Type", DocBrowser.styles.columnHeader, GUILayout.Width(m_ListTypeWidth));
        if (!m_Browser.translating)
        {
            GUILayout.Label("Asm", DocBrowser.styles.columnHeader, GUILayout.Width(kListPresenceWidth));
        }
        GUILayout.Label("Doc", DocBrowser.styles.columnHeader, GUILayout.Width(kListPresenceWidth));
        if (m_Browser.translating)
        {
            GUILayout.Label("Tr", DocBrowser.styles.columnHeader, GUILayout.Width(kListPresenceWidth));
        }
        GUILayout.Label("Special", DocBrowser.styles.columnHeader, GUILayout.Width(kListCommentWidth));
        GUILayout.Label("", DocBrowser.styles.columnHeader, GUILayout.Width(kSliderWidth));
        EditorGUILayout.EndHorizontal();

        // Make GUI for the list itself
        int  id       = GUIUtility.GetControlID(FocusType.Keyboard);
        Rect listRect = GUILayoutUtility.GetRect(100, 100, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));

        m_ListScroll = GUI.BeginScrollView(listRect, m_ListScroll, new Rect(0, 0, listRect.width - 20, Mathf.Max(m_FilteredMembers.Count * kListItemHeight, listRect.height)), false, true);
        int startIndex = Mathf.Max(0, Mathf.FloorToInt(m_ListScroll.y / kListItemHeight));
        int endIndex   = Mathf.Min(m_FilteredMembers.Count - 1, Mathf.CeilToInt((m_ListScroll.y + listRect.height) / kListItemHeight));

        for (int i = startIndex; i <= endIndex; i++)
        {
            ListElementGUI(new Rect(0, i * kListItemHeight, listRect.width - kSliderWidth, kListItemHeight), i, id);
        }
        GUI.EndScrollView();

        // Keyboard navigation with up/down arrow
        if (GUIUtility.keyboardControl == id && Event.current.type == EventType.KeyDown)
        {
            Event evt   = Event.current;
            int   delta = 0;
            if (evt.keyCode == KeyCode.UpArrow)
            {
                delta = -1;
            }
            else if (evt.keyCode == KeyCode.DownArrow)
            {
                delta = 1;
            }
            if (delta != 0)
            {
                int selected = GetSelectedMemberIndexSlow() + delta;
                selected = Mathf.Clamp(selected, 0, m_FilteredMembers.Count - 1);
                if (getSelectPermission())
                {
                    m_SelectedMemberName = m_FilteredMembers[selected].ItemName;
                    onSelectCallback(this, m_SelectedMemberName);
                    m_ListScroll.y = Mathf.Clamp(m_ListScroll.y, (selected + 1) * kListItemHeight - listRect.height, selected * kListItemHeight);
                }
                evt.Use();
            }
        }

        // Status bar
        GUILayout.Label(m_FilteredMembers.Count + " members shown.", DocBrowser.styles.frameStatusBar);

        EditorGUILayout.EndVertical();

        EditorGUILayout.EndVertical();
    }
コード例 #18
0
    void OnGUI()
    {
        //While the ParseWindow is still open
        //Don't attempt any interactions with camera values if there isn't any cameras in the file
        if (kinectsNames != null)
        {
            showCameras = EditorGUILayout.Foldout(showCameras, "Cameras");
            EditorGUI.indentLevel++;
            if (showCameras)                                 //if the Camera Foldout has been collapsed
            {
                for (int i = 0; i < kinectsNames.Count; i++) //for each Kinect
                {
                    if (i == showEachCamera.Count)           //if the collapse list has no record for this Kinect
                    {
                        showEachCamera.Add(false);
                    }
                    showEachCamera[i] = EditorGUILayout.Foldout(showEachCamera[i], "Kinect " + (i));
                    if (showEachCamera[i]) //if this Kinect's Foldout has been collapsed
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.BeginHorizontal();
                        kinectsNames[i].InnerText = EditorGUILayout.TextField("Name: ", kinectsNames[i].InnerText);
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                        kinectsIP[i].InnerText = EditorGUILayout.TextField("IP: ", kinectsIP[i].InnerText);
                        EditorGUILayout.EndHorizontal();
                        EditorGUI.indentLevel--;
                    }

                    if (!kinectsNames[i].InnerText.Equals(originalKinectsNames[i].InnerText) ||
                        !kinectsIP[i].InnerText.Equals(originalKinectsIP[i].InnerText))
                    { //if any changes have been made to any of the text fields for this Kinect
                        changes = true;
                    }
                }
            }
            EditorGUI.indentLevel--;
        }
        //Don't attempt any interactions with projector values if there isn't any projectors in the file
        if (projectorsNames != null)
        {
            showProjectors = EditorGUILayout.Foldout(showProjectors, "Projectors");
            EditorGUI.indentLevel++;
            if (showProjectors)                                 //if the Projector Foldout has been collapsed
            {
                for (int i = 0; i < projectorsNames.Count; i++) //for each Projector
                {
                    if (i == showEachProjector.Count)           //if the collapse list has no record for this Projector
                    {
                        showEachProjector.Add(false);
                    }
                    showEachProjector[i] = EditorGUILayout.Foldout(showEachProjector[i], "Projector " + (i));

                    if (showEachProjector[i]) //if this Projector's Foldout has been collapsed
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.BeginHorizontal();
                        projectorsNames[i].InnerText = EditorGUILayout.TextField("Name: ", projectorsNames[i].InnerText);
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                        projectorsIP[i].InnerText = EditorGUILayout.TextField("IP: ", projectorsIP[i].InnerText);
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                        projectorsDisplay[i].InnerText = EditorGUILayout.TextField("Display Index: ", projectorsDisplay[i].InnerText);
                        EditorGUILayout.EndHorizontal();
                        EditorGUI.indentLevel--;
                    }
                    if (!projectorsNames[i].InnerText.Equals(originalProjectorsNames[i].InnerText) ||
                        !projectorsIP[i].InnerText.Equals(originalProjectorsIP[i].InnerText) ||
                        !projectorsDisplay[i].InnerText.Equals(originalProjectorsDisplay[i].InnerText))
                    { //if any changes have been made to any of the text fields for this Projector
                        changes = true;
                    }
                }
            }
            EditorGUI.indentLevel--;
        }

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Add Kinect", GUILayout.Width(buttonWidth)))
        {
            addingKinect      = true;
            addingProjector   = false;
            removingKinect    = false;
            removingProjector = false;
        }
        if (GUILayout.Button("Remove Kinect", GUILayout.Width(buttonWidth)))
        {
            addingKinect      = false;
            addingProjector   = false;
            removingKinect    = true;
            removingProjector = false;
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Add Projector", GUILayout.Width(buttonWidth)))
        {
            addingKinect      = false;
            addingProjector   = true;
            removingKinect    = false;
            removingProjector = false;
        }
        if (GUILayout.Button("Remove Projector", GUILayout.Width(buttonWidth)))
        {
            addingKinect      = false;
            addingProjector   = false;
            removingKinect    = false;
            removingProjector = true;
        }
        EditorGUILayout.EndHorizontal();
        if (addingKinect)
        {
            EditorGUILayout.BeginHorizontal();
            newKinectsName = EditorGUILayout.TextField("Kinect's Name: ", newKinectsName);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            newKinectsIP = EditorGUILayout.TextField("Kinect's IP: ", newKinectsIP);
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Add", GUILayout.Width(buttonWidth)) && newKinectsName.Length > 0 && newKinectsIP.Length > 0)
            {
                addingKinect = false;
                changes      = true;
                AddKinect();
                ParseFile();
            }
        }
        if (removingKinect)
        {
            EditorGUILayout.BeginHorizontal();
            kinectNum = int.Parse(EditorGUILayout.TextField("Kinect Number: ", kinectNum + ""));
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Remove", GUILayout.Width(buttonWidth)) && kinectNum > 0 && kinectNum < kinectsNames.Count)
            {
                removingKinect = false;
                changes        = true;
                RemoveKinect();
                ParseFile();
            }
        }
        if (addingProjector)
        {
            EditorGUILayout.BeginHorizontal();
            newProjectorsName = EditorGUILayout.TextField("Projector's Name: ", newProjectorsName);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            newProjectorsIP = EditorGUILayout.TextField("Projector's IP: ", newProjectorsIP);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            newProjectorsDisplay = EditorGUILayout.TextField("Projector's Display Index: ", newProjectorsDisplay);
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Add", GUILayout.Width(buttonWidth)) && newProjectorsName.Length > 0 && newProjectorsIP.Length > 0 && newProjectorsDisplay.Length > 0)
            {
                addingProjector = false;
                changes         = true;
                AddProjector();
                ParseFile();
            }
        }
        if (removingProjector)
        {
            EditorGUILayout.BeginHorizontal();
            projectorNum = int.Parse(EditorGUILayout.TextField("Projector Number: ", projectorNum + ""));
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Remove", GUILayout.Width(buttonWidth)) && projectorNum < projectorsNames.Count)
            {
                removingProjector = false;
                changes           = true;
                RemoveProjector();
                ParseFile();
            }
        }
        EditorGUILayout.Separator();
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Apply", GUILayout.Width(buttonWidth)))
        {
            SaveChanges();
            changes = false;
        }
        ;
        EditorGUILayout.Space();

        if (GUILayout.Button("Reset", GUILayout.Width(buttonWidth)))
        {
            LoadFile();
            ParseFile();
            changes = false;
        }
        ;
        EditorGUILayout.EndHorizontal();
    }
コード例 #19
0
        private void RenderSceneOptimizations()
        {
            GUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField(this.ToolbarTitles[(int)ToolbarSection.Scene], MixedRealityStylesUtility.BoldLargeTitleStyle);
            using (new EditorGUI.IndentLevelScope())
            {
                EditorGUILayout.LabelField("This section provides controls and performance information for the currently opened scene. Any optimizations performed are only for the active scene at any moment.", EditorStyles.wordWrappedLabel);

                BuildSection("Live Scene Analysis", null, null, () =>
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(lastAnalyzedTime == null ? "Click analysis button for MRTK to scan your currently opened scene" : "Scanned " + GetRelativeTime(lastAnalyzedTime));

                    if (GUILayout.Button("Analyze Scene", GUILayout.Width(160f)))
                    {
                        AnalyzeScene();
                        lastAnalyzedTime = DateTime.UtcNow;
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.Space();

                    if (lastAnalyzedTime != null)
                    {
                        // Lighting analysis
                        bool showNumOfSceneLights = this.sceneLights != null && this.sceneLights.Length > SceneLightCountMax[(int)PerfTarget];
                        bool showDisableShadows   = this.PerfTarget == PerformanceTarget.AR_Headsets;
                        if (showNumOfSceneLights || showDisableShadows)
                        {
                            EditorGUILayout.LabelField("Lighting Analysis", EditorStyles.boldLabel);
                            if (showNumOfSceneLights)
                            {
                                EditorGUILayout.LabelField(this.sceneLights.Length + " lights in the scene. Consider reducing the number of lights.");
                            }

                            if (showDisableShadows)
                            {
                                foreach (var l in this.sceneLights)
                                {
                                    if (l != null && l.shadows != LightShadows.None)
                                    {
                                        EditorGUILayout.ObjectField("Disable shadows", l, typeof(Light), true);
                                    }
                                }
                            }
                            EditorGUILayout.Space();
                        }

                        // Mesh Analysis
                        EditorGUILayout.LabelField("Polygon Count Analysis", EditorStyles.boldLabel);

                        using (new EditorGUILayout.HorizontalScope())
                        {
                            EditorGUILayout.LabelField(TotalPolyCountStr);
                            EditorGUILayout.LabelField(TotalActivePolyCountStr);
                            EditorGUILayout.LabelField(TotalInactivePolyCountStr);
                        }

                        EditorGUILayout.LabelField("Top " + TopListSize + " GameObjects in scene with highest polygon count");
                        for (int i = 0; i < LargestMeshes.Length; i++)
                        {
                            if (LargestMeshes[i] != null)
                            {
                                using (new EditorGUILayout.HorizontalScope())
                                {
                                    EditorGUILayout.LabelField("Num of Polygons: " + this.LargestMeshSizes[i].ToString("N0"));
                                    EditorGUILayout.ObjectField(this.LargestMeshes[i], typeof(GameObject), true);
                                    if (GUILayout.Button(new GUIContent("View", "Selects & view this asset in inspector"), EditorStyles.miniButton, GUILayout.Width(42f)))
                                    {
                                        Selection.activeObject = this.LargestMeshes[i];
                                    }
                                }
                            }
                        }
                    }
                });
            }

            GUILayout.EndVertical();
        }
コード例 #20
0
        void RenderStrings(string label, List <TypeEntry> list, ref bool foldout, ref bool changes, Action apply, Action refresh, Action ui = null, bool color = false)
        {
            // foldout = EditorGUILayout.Foldout(foldout, label);

            // if (foldout)
            GUILayout.Label(label, EditorStyles.boldLabel);

            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                if (ui != null)
                {
                    ui();
                }
                for (int i = 0; i < list.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    int value = list[i].Value;
                    EditorGUILayout.LabelField(value.ToString(), GUILayout.MaxWidth(24f));
                    GUI.SetNextControlName(i.ToString());
                    var originalLabel = list[i].Label;
                    list[i].Label = EditorGUILayout.TextField(list[i].Label).ToUpper().Replace(' ', '_');

                    if (!originalLabel.Equals(list[i].Label))
                    {
                        changes = true;
                    }

                    if (color == true)
                    {
                        var originalColor = list[i].Color;
                        //make sure color alpha = 1f
#if UNITY_2018_2_OR_NEWER
                        list[i].Color = EditorGUILayout.ColorField(new GUIContent(""), list[i].Color, true, false, false, GUILayout.Width(32));
#else
                        list[i].Color = EditorGUILayout.ColorField(new GUIContent(""), list[i].Color, true, false, false, null, GUILayout.Width(32));
#endif
                        list[i].Color.a = 1f;

                        if (originalColor != list[i].Color)
                        {
                            changes = true;
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(m_ToolbarPlusIcon, GUILayout.Width(32f)))
                {
                    var value = Enumerable.Range(0, list.Count + 1).Except(list.Select((TypeEntry e) => e.Value)).Min();
                    list.Add(new TypeEntry
                    {
                        Label = "",
                        Value = value,
                        Color = m_DefaultHitboxColors[value % m_DefaultHitboxColors.Length]
                    });
                    list.Sort((TypeEntry a, TypeEntry b) => a.Value - b.Value);
                    changes = true;
                }
                if (GUILayout.Button(m_ToolbarMinusIcon, GUILayout.Width(32f)))
                {
                    var strIndex = GUI.GetNameOfFocusedControl();

                    if (!string.IsNullOrEmpty(strIndex))
                    {
                        list.RemoveAt(Convert.ToInt32(strIndex));
                    }

                    GUI.FocusControl("");
                    changes = true;
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();
                EditorGUILayout.BeginHorizontal();
                GUI.enabled = changes;
                if (GUILayout.Button("Apply", GUILayout.Width(64f)))
                {
                    changes = false; GUI.FocusControl(""); apply();
                }
                if (GUILayout.Button("Cancel", GUILayout.Width(64f)))
                {
                    changes = false; GUI.FocusControl(""); refresh();
                }
                GUI.enabled = true;
                EditorGUILayout.EndHorizontal();
            }
        }
コード例 #21
0
    void OnGUI()
    {
        Scroll = EditorGUILayout.BeginScrollView(Scroll);

        Utility.SetGUIColor(UltiDraw.Black);
        using (new EditorGUILayout.VerticalScope("Box")) {
            Utility.ResetGUIColor();

            Utility.SetGUIColor(UltiDraw.Grey);
            using (new EditorGUILayout.VerticalScope("Box")) {
                Utility.ResetGUIColor();

                Utility.SetGUIColor(UltiDraw.Orange);
                using (new EditorGUILayout.VerticalScope("Box")) {
                    Utility.ResetGUIColor();
                    EditorGUILayout.LabelField("Importer");
                }

                if (!Importing)
                {
                    if (Utility.GUIButton("Import Data", UltiDraw.DarkGrey, UltiDraw.White))
                    {
                        this.StartCoroutine(ImportFiles());
                    }

                    EditorGUILayout.BeginHorizontal();
                    if (Utility.GUIButton("Enable All", UltiDraw.DarkGrey, UltiDraw.White))
                    {
                        for (int i = 0; i < Import.Length; i++)
                        {
                            Import[i] = true;
                        }
                    }
                    if (Utility.GUIButton("Disable All", UltiDraw.DarkGrey, UltiDraw.White))
                    {
                        for (int i = 0; i < Import.Length; i++)
                        {
                            Import[i] = false;
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    if (Utility.GUIButton("Stop", UltiDraw.DarkRed, UltiDraw.White))
                    {
                        this.StopAllCoroutines();
                        Importing = false;
                    }
                }

                using (new EditorGUILayout.VerticalScope("Box")) {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Source", GUILayout.Width(50));
                    LoadDirectory(EditorGUILayout.TextField(Source));
                    GUI.skin.button.alignment = TextAnchor.MiddleCenter;
                    if (GUILayout.Button("O", GUILayout.Width(20)))
                    {
                        Source = EditorUtility.OpenFilePanel("Motion Importer", Source == string.Empty ? Application.dataPath : Source.Substring(0, Source.LastIndexOf("/")), "");
                        GUI.SetNextControlName("");
                        GUI.FocusControl("");
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Assets/", GUILayout.Width(50));
                    Destination = EditorGUILayout.TextField(Destination);
                    EditorGUILayout.EndHorizontal();

                    for (int i = 0; i < Files.Length; i++)
                    {
                        if (Import[i])
                        {
                            Utility.SetGUIColor(UltiDraw.DarkGreen);
                        }
                        else
                        {
                            Utility.SetGUIColor(UltiDraw.DarkRed);
                        }
                        using (new EditorGUILayout.VerticalScope("Box")) {
                            Utility.ResetGUIColor();
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField((i + 1).ToString(), GUILayout.Width(20f));
                            Import[i] = EditorGUILayout.Toggle(Import[i], GUILayout.Width(20f));
                            EditorGUILayout.LabelField(Files[i].Name);
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                }
            }
        }

        EditorGUILayout.EndScrollView();
    }
コード例 #22
0
    public override void OnInspectorGUI()
    {
        m_object.Update();
        DrawDefaultInspector();

        _2dxFX_AL_Hologram _2dxScript = (_2dxFX_AL_Hologram)target;

        Texture2D icon = Resources.Load("2dxfxinspector-al") as Texture2D;

        if (icon)
        {
            Rect  r;
            float ih     = icon.height;
            float iw     = icon.width;
            float result = ih / iw;
            float w      = Screen.width;
            result = result * w;
            r      = GUILayoutUtility.GetRect(ih, result);
            EditorGUI.DrawTextureTransparent(r, icon);
        }
        EditorGUILayout.LabelField("Advanced Lightning may work on mobile high-end devices and may be slower than the Standard 2DxFX effects due to is lightning system. Use it only if you need it.", EditorStyles.helpBox);
        EditorGUILayout.PropertyField(m_object.FindProperty("AddShadow"), new GUIContent("Add Shadow", "Use a unique material, reduce drastically the use of draw call"));
        if (_2dxScript.AddShadow)
        {
            EditorGUILayout.PropertyField(m_object.FindProperty("ReceivedShadow"), new GUIContent("Received Shadow : No Transparency and Use Z Buffering instead of Sprite Order Layers", "Received Shadow, No Transparency and Use Z Buffering instead of Sprite Order Layers"));
            if (_2dxScript.ReceivedShadow)
            {
                EditorGUILayout.LabelField("Note 1: Blend Fusion work but without transparency\n", EditorStyles.helpBox);
            }
        }

        // Mode Blend
        string BlendMethode = "Normal";

        if (_2dxScript.BlendMode == 0)
        {
            BlendMethode = "Normal";
        }
        if (_2dxScript.BlendMode == 1)
        {
            BlendMethode = "Additive";
        }
        if (_2dxScript.BlendMode == 2)
        {
            BlendMethode = "Darken";
        }
        if (_2dxScript.BlendMode == 3)
        {
            BlendMethode = "Lighten";
        }
        if (_2dxScript.BlendMode == 4)
        {
            BlendMethode = "Linear Burn";
        }
        if (_2dxScript.BlendMode == 5)
        {
            BlendMethode = "Linear Dodge";
        }
        if (_2dxScript.BlendMode == 6)
        {
            BlendMethode = "Multiply";
        }
        if (_2dxScript.BlendMode == 7)
        {
            BlendMethode = "Soft Aditive";
        }
        if (_2dxScript.BlendMode == 8)
        {
            BlendMethode = "2x Multiplicative";
        }

        EditorGUILayout.PropertyField(m_object.FindProperty("ForceMaterial"), new GUIContent("Shared Material", "Use a unique material, reduce drastically the use of draw call"));

        if (_2dxScript.ForceMaterial == null)
        {
            _2dxScript.ActiveChange = true;
        }
        else
        {
            if (GUILayout.Button("Remove Shared Material"))
            {
                _2dxScript.ForceMaterial = null;
                _2dxScript.ShaderChange  = 1;
                _2dxScript.ActiveChange  = true;
                _2dxScript.CallUpdate();
            }

            EditorGUILayout.PropertyField(m_object.FindProperty("ActiveChange"), new GUIContent("Change Material Property", "Change The Material Property"));
        }

        if (_2dxScript.ActiveChange)
        {
            EditorGUILayout.BeginVertical("Box");

            Texture2D icone = Resources.Load("2dxfx-icon-time") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("Speed"), new GUIContent("Time Speed", icone, "Change the time speed"));
            icone = Resources.Load("2dxfx-icon-distortion") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("Distortion"), new GUIContent("Distortion", icone, "Change the distortion"));

            EditorGUILayout.BeginVertical("Box");



            icone = Resources.Load("2dxfx-icon-fade") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("_Alpha"), new GUIContent("Fading", icone, "Fade from nothing to showing"));

            EditorGUILayout.EndVertical();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Change Blend Fusion = " + BlendMethode, EditorStyles.whiteLargeLabel);
            if (_2dxScript.ReceivedShadow)
            {
                EditorGUILayout.LabelField("Note: Blend Fusion is not working correctly with Received Shadow", EditorStyles.helpBox);
            }

            EditorGUILayout.BeginHorizontal("Box");

            if (GUILayout.Button("Normal", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 0;
                _2dxScript.CallUpdate();
            }
            if (GUILayout.Button("Additive", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 1;
                _2dxScript.CallUpdate();
            }
            if (GUILayout.Button("Darken", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 2;
                _2dxScript.CallUpdate();
            }
            if (GUILayout.Button("Lighten", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 3;
                _2dxScript.CallUpdate();
            }
            if (GUILayout.Button("Linear Burn", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 4;
                _2dxScript.CallUpdate();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal("Box");

            if (GUILayout.Button("Linear Dodge", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 5;
                _2dxScript.CallUpdate();
            }
            if (GUILayout.Button("Multiply", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 6;
                _2dxScript.CallUpdate();
            }
            if (GUILayout.Button("Soft Aditive", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 7;
                _2dxScript.CallUpdate();
            }
            if (GUILayout.Button("2x Multiplicative", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 8;
                _2dxScript.CallUpdate();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
        }

        m_object.ApplyModifiedProperties();
    }
コード例 #23
0
        /**
         * Shows the GUI.
         */
        public void ShowGUI()
        {
            if (icon == null)
            {
                icon = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof(Texture2D));
            }

            EditorGUILayout.BeginVertical("Button");
            drawInEditor = EditorGUILayout.Toggle("Test in Game Window?", drawInEditor);
            drawOutlines = EditorGUILayout.Toggle("Draw outlines?", drawOutlines);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Pause background texture:", GUILayout.Width(255f));
            pauseTexture = (Texture2D)EditorGUILayout.ObjectField(pauseTexture, typeof(Texture2D), false, GUILayout.Width(70f), GUILayout.Height(30f));
            EditorGUILayout.EndHorizontal();
            scaleTextEffects = EditorGUILayout.Toggle("Scale text effects?", scaleTextEffects);
            globalDepth      = EditorGUILayout.IntField("GUI depth:", globalDepth);
            eventSystem      = (UnityEngine.EventSystems.EventSystem)EditorGUILayout.ObjectField("Event system prefab:", eventSystem, typeof(UnityEngine.EventSystems.EventSystem), false);

            if (drawInEditor && KickStarter.menuPreview == null)
            {
                EditorGUILayout.HelpBox("A GameEngine prefab is required to display menus while editing - please click Organise Room Objects within the Scene Manager.", MessageType.Warning);
            }
            else if (Application.isPlaying)
            {
                EditorGUILayout.HelpBox("Changes made to the menus will not be registed by the game until the game is restarted.", MessageType.Info);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Menus", EditorStyles.boldLabel);
            CreateMenusGUI();

            if (selectedMenu != null)
            {
                EditorGUILayout.Space();

                string menuTitle = selectedMenu.title;
                if (menuTitle == "")
                {
                    menuTitle = "(Untitled)";
                }

                EditorGUILayout.LabelField("Menu " + selectedMenu.id + ": '" + menuTitle + "' properties", EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical("Button");
                selectedMenu.ShowGUI();
                EditorGUILayout.EndVertical();

                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Menu " + selectedMenu.id + ": '" + menuTitle + "' elements", EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical("Button");
                CreateElementsGUI(selectedMenu);
                EditorGUILayout.EndVertical();

                if (selectedMenuElement != null)
                {
                    EditorGUILayout.Space();

                    string elementName = selectedMenuElement.title;
                    if (elementName == "")
                    {
                        elementName = "(Untitled)";
                    }

                    string elementType = "";
                    foreach (string _elementType in elementTypes)
                    {
                        if (selectedMenuElement.GetType().ToString().Contains(_elementType))
                        {
                            elementType = _elementType;
                            break;
                        }
                    }

                    EditorGUILayout.LabelField(elementType + " " + selectedMenuElement.ID + ": '" + elementName + "' properties", EditorStyles.boldLabel);
                    oldVisibility = selectedMenuElement.isVisible;
                    selectedMenuElement.ShowGUIStart(selectedMenu.menuSource);
                    if (selectedMenuElement.isVisible != oldVisibility)
                    {
                        if (!Application.isPlaying)
                        {
                            selectedMenu.Recalculate();
                        }
                    }
                }
            }

            if (GUI.changed)
            {
                if (!Application.isPlaying)
                {
                    SaveAllMenus();
                }
                EditorUtility.SetDirty(this);
            }
        }
コード例 #24
0
        public override void Draw(PropertyData data)
        {
            var attr = data.Attributes.FirstOrDefault() as ListDrawerAttribute;

            if (attr == null)
            {
                attr = new ListDrawerAttribute();
            }

            Rect rect = EditorGUILayout.BeginVertical(Style.ListBackground);

            PerunEditor.DropRect dropRect = null;
            if (Event.current.type == EventType.Repaint)
            {
                dropRect          = Editor.CreateDropRect();
                dropRect.Position = rect;
                object objParent = data.Parent.Value;
                object obj       = data.Value;
                string path      = data.Property.propertyPath;
                dropRect.Validate = () => {
                    return(DropValidate(obj, path));// DragAndDrop.objectReferences.FirstOrDefault(e => e is type);
                };
                dropRect.Action = i => Drop(objParent, obj, path, i);
            }

            AnimBool animBool = Editor.GetAnimBool(data.Property.propertyPath, data.Property.isExpanded);

            // Header

            EditorGUILayout.BeginHorizontal(Style.Toolbar);

            //data.Property.isExpanded = EditorGUILayout.Foldout(data.Property.isExpanded, new GUIContent(data.Property.displayName));
            if (EditorGUILayout.DropdownButton(new GUIContent(data.Property.displayName), FocusType.Passive,
                                               data.Property.isExpanded ? Style.FoldoutExpanded : Style.Foldout))
            {
                data.Property.isExpanded = !data.Property.isExpanded;
            }

            //Foldout

            animBool.target = data.Property.isExpanded;

            EditorGUILayout.LabelField(data.Property != null && data.Property.arraySize > 0 ? data.Property.arraySize + " items" : "empty", Style.ToolbarLabelRight, GUILayout.Width(64));

            if (attr.ShowAddButton && GUILayout.Button("", Style.ToolbarAddButton, GUILayout.Width(18)))
            {
                data.AddNewItem();
                data.Property.serializedObject.ApplyModifiedProperties();
            }

            EditorGUILayout.EndHorizontal();
            //

            EditorGUILayout.BeginVertical(data.Property.isExpanded ? Style.ListContent : Style.ListContentEmpty);

            if (EditorGUILayout.BeginFadeGroup(animBool.faded))
            {
                for (int i = 0; i < data.Property.arraySize; i++)
                {
                    SerializedProperty itemProperty = data.Property.GetArrayElementAtIndex(i);

                    /*
                     * if(i > 0 && itemProperty.propertyType == SerializedPropertyType.Generic)
                     *  EditorGUILayout.Space();
                     */
                    Rect itemRect = EditorGUILayout.BeginHorizontal(Style.ListItem);
                    if (dropRect != null && data.Property.isExpanded)
                    {
                        dropRect.Childs.Add(new Rect(itemRect.x - 5, itemRect.y - 1, itemRect.width + 6, itemRect.height + 2));
                    }

                    if (attr.ShowDrag)
                    {
                        Rect itemDragRect = EditorGUILayout.GetControlRect(false, 10, Style.ListDragElement, GUILayout.Width(13));
                        itemDragRect = new Rect(itemDragRect.x, itemDragRect.y + itemRect.height / 2 - 12, 12, 16);
                        GUI.Box(itemDragRect, GUIContent.none, Style.ListDragElement);
                        itemDragRect = new Rect(itemDragRect.x, itemDragRect.y + 6, 12, 16);
                        GUI.Box(itemDragRect, GUIContent.none, Style.ListDragElement);

                        //GUI.Box(itemDragRect, GUIContent.none, Style.ListDragElement);
                        //EditorGUI.DropdownButton(itemDragRect, GUIContent.none, FocusType.Passive, Style.ListDragElement);

                        if (Event.current.type == EventType.Repaint)
                        {
                            PerunEditor.DragRect dragRect = Editor.CreateDragRect();
                            dragRect.Position = new Rect(itemDragRect.x - 3, itemRect.y, itemDragRect.width + 6, itemRect.height);
                            int    index = i;
                            string path  = data.Property.propertyPath;
                            object obj   = data.Value;
                            dragRect.Action = () =>
                            {
                                DragAndDrop.PrepareStartDrag();
                                DragAndDrop.SetGenericData("ListDragData", new DragData(Editor, path, index, obj, data.Value, data.Parent.Value));
                                DragAndDrop.StartDrag(itemProperty.propertyPath);
                            };
                        }
                    }

                    EditorGUILayout.BeginVertical();
                    Editor.Property.Draw(new PropertyData(data, i));
                    EditorGUILayout.EndVertical();
                    //DrawItem(attr, itemProperty, i, type, attrList, parent);
                    //
                    if (attr.ShowRemoveButton)
                    {
                        Rect deleteRect = EditorGUILayout.GetControlRect(false, 16, GUILayout.Width(16));
                        deleteRect = new Rect(deleteRect.x, deleteRect.y + itemRect.height / 2 - 10, 16, 16);

                        if (GUI.Button(deleteRect, GUIContent.none, Style.ListDeleteItem))
                        {
                            data.Property.DeleteArrayElementAtIndex(i);
                        }

                        /*
                         * if (GUILayout.Button("", Style.ListDeleteItem, GUILayout.Width(16)))
                         * {
                         * }*/
                    }

                    EditorGUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndFadeGroup();

            EditorGUILayout.EndVertical();
            //

            EditorGUILayout.EndVertical();
        }
コード例 #25
0
        void OnGUI()
        {
            SoundBoardWindow window = (SoundBoardWindow)GetWindow(typeof(SoundBoardWindow), false, "Sound Board");

            window.minSize = new Vector2(412f, 80f);

            if (_soundPool == null)
            {
                _soundPool = new EditorSoundPool();
            }

            if (_buttonStyle == null)
            {
                _buttonStyle        = new GUIStyle(GUI.skin.GetStyle("Button"));
                _buttonStyle.margin = new RectOffset(4, 4, 1, 0);
            }



            GUILayout.Space(10f);
            GUILayout.BeginHorizontal();

            GUILayout.Space(20f);
            GUILayout.Label("Sound Bank", "BoldLabel", GUILayout.MinWidth(200f), GUILayout.MaxWidth(300f));

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("PLAY ALL", GUILayout.MinWidth(80f), GUILayout.MaxWidth(100f)))
            {
                for (int i = 0; i < _soundInstances.Count; i++)
                {
                    StopSound(i);
                    PlaySound(i);
                }
            }
            if (GUILayout.Button("STOP", GUILayout.MaxWidth(80f)))
            {
                for (int i = 0; i < _soundInstances.Count; i++)
                {
                    StopSound(i);
                }
            }
            if (GUILayout.Button("X", GUILayout.MaxWidth(25f)))
            {
                _soundPool.Clear();
                _soundInstances.Clear();
                _soundBanks.Clear();
            }

            GUILayout.Space(15f);
            GUILayout.EndHorizontal();

            GUILayout.BeginVertical("GroupBox");



            for (int i = 0; i < _soundBanks.Count; i++)
            {
                DrawRow(i);
            }

            EditorGUILayout.BeginHorizontal();

            Object newBank = EditorGUILayout.ObjectField("", null, typeof(SoundBank), false, GUILayout.Width(_newBankWidth));

            if (newBank != null)
            {
                _soundBanks.Add((SoundBank)newBank);
                _soundInstances.Add(null);
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
コード例 #26
0
        void OnGUI()
        {
            EditorGUI.DrawPreviewTexture(this.headerRect, this.conceptTexture);

            GUILayout.Space(this.headerRect.height + 10);

            // Config file Settings
            GUILayout.Label("Config file Settings", EditorStyles.boldLabel);

            EditorGUI.indentLevel++;

            EditorGUIUtility.labelWidth = 240;

            EditorGUI.BeginChangeCheck();



            this.rosbridgeIP         = EditorGUILayout.TextField("Rosbridge IP", this.rosbridgeIP, GUILayout.Width(EditorGUIUtility.labelWidth + 120));
            this.rosbridgePort       = EditorGUILayout.IntField("Rosbridge Port", this.rosbridgePort, GUILayout.Width(EditorGUIUtility.labelWidth + 80));
            this.sigverseBridgePort  = EditorGUILayout.IntField("SIGVerse Bridge Port", this.sigverseBridgePort, GUILayout.Width(EditorGUIUtility.labelWidth + 80));
            this.logFileName         = EditorGUILayout.TextField("Log File Name", this.logFileName, GUILayout.Width(EditorGUIUtility.labelWidth + 300));
            this.useSigverseMenu     = EditorGUILayout.Toggle("Use SIGVerse menu", this.useSigverseMenu);
            this.isAutoStartWithMenu = EditorGUILayout.Toggle("     (option)  Auto Start", this.isAutoStartWithMenu);
            this.setUpRosTimestamp   = EditorGUILayout.Toggle("Set up Time stamps of ROS message", this.setUpRosTimestamp);

            if (EditorGUI.EndChangeCheck())
            {
                ConfigInfo configInfo = new ConfigInfo();

                configInfo.rosbridgeIP         = this.rosbridgeIP;
                configInfo.rosbridgePort       = this.rosbridgePort;
                configInfo.sigverseBridgePort  = this.sigverseBridgePort;
                configInfo.logFileName         = this.logFileName;
                configInfo.useSigverseMenu     = this.useSigverseMenu;
                configInfo.isAutoStartWithMenu = this.isAutoStartWithMenu;
                configInfo.setUpRosTimestamp   = this.setUpRosTimestamp;

                ConfigManager.InitConfigFile();                 // Create config file
                ConfigManager.SaveConfig(configInfo);
            }

            GUILayout.Space(10);
            GUILayout.Box("", GUILayout.Width(this.position.width), GUILayout.Height(2));


            // Scripting Define Symbols Settings
            GUILayout.Label("Define symbols Settings", EditorStyles.boldLabel);

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.BeginHorizontal();
            {
                this.isUsingMySQL = EditorGUILayout.Toggle("Use MySQL", this.isUsingMySQL);
                GUILayout.Space(20);
                GUILayout.Label("* Please add some libraries(MySql.Data.dll) if you want to use MySQL.");
                GUILayout.FlexibleSpace();
            }
            EditorGUILayout.EndHorizontal();

            if (EditorGUI.EndChangeCheck())
            {
                foreach (BuildTargetGroup buildTargetGroup in BuildTargetGroupList)
                {
                    string[] scriptingDefineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup).Split(SymbolSeparator);

                    List <string> scriptingDefineSymbolList = new List <string>(scriptingDefineSymbols);

                    // Add/Remove MySQL define
                    this.UpdateScriptingDefineSymbolList(ref scriptingDefineSymbolList, this.isUsingMySQL, DefineSIGVerseMySQL);

                    string defineSymbolsStr = String.Join(SymbolSeparator.ToString(), scriptingDefineSymbolList.ToArray());

                    // Update ScriptingDefineSymbols of PlayerSettings
                    PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, defineSymbolsStr);

                    // Update SIGVerseScriptingDefineSymbols of EditorUserSettings
                    EditorUserSettings.SetConfigValue(SIGVerseScriptingDefineSymbolsKey, defineSymbolsStr);
                }
            }

            GUILayout.Space(10);
            GUILayout.Box("", GUILayout.Width(this.position.width), GUILayout.Height(2));


            //// Create Scripts
            //GUILayout.Label("Create Scripts", EditorStyles.boldLabel);

            //EditorGUI.indentLevel++;

            //if (GUILayout.Button ("Create '" +SIGVerseScriptCreator.ScriptName+ "'", GUILayout.Width(300)))
            //{
            //	SIGVerseScriptCreator.CreateScript();
            //}
        }
コード例 #27
0
        static public T[] ArrayEditor <T>(string label, T[] list) where T : UnityEngine.Object
        {
            EditorGUILayout.BeginVertical("box");

            // Header and ADD button
            EditorGUILayout.BeginHorizontal();
            if (!string.IsNullOrEmpty(label))
            {
                EditorGUILayout.LabelField(label);
            }
            // Force ADD button to the right
            EditorGUILayout.Space();
            if (GUI.enabled && GUILayout.Button(" + ", GUILayout.ExpandWidth(false)))
            {
                var newList = Array.CreateInstance(typeof(T), list.Length + 1);
                Array.Copy(list, newList, list.Length);
                list = (T[])newList;
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            if (!string.IsNullOrEmpty(label))
            {
                EditorGUILayout.LabelField(label);
            }

            if (list == null)
            {
                list = (T[])Activator.CreateInstance(typeof(T[]));
            }
            if (list.Length > 0)
            {
                EditorGUILayout.BeginVertical("box");
                int remove  = -1;
                int shift   = -1;
                int shiftTo = -1;

                int from, to;
                GetArrayPageFromTo(list.GetHashCode(), list.Length, out from, out to);

                for (int i = from; i <= to; i++)
                {
                    EditorGUILayout.BeginHorizontal();

                    // Index...  Shift up or down?
                    EditorGUILayout.LabelField(string.Format("[{0}]", i), GUILayout.Width(36f));
                    ArrayShiftButtons(i, list.Length, ref shift, ref shiftTo);

                    list[i] = (T)EditorGUILayout.ObjectField(list[i], typeof(T), true, GUILayout.ExpandWidth(true));
                    if (GUI.enabled && GUILayout.Button("×", GUILayout.ExpandWidth(false)))
                    {
                        remove = i;
                    }
                    EditorGUILayout.EndHorizontal();
                }
                if (remove >= 0)
                {
                    var newList = Array.CreateInstance(typeof(T), list.Length - 1);
                    if (remove > 0)
                    {
                        Array.Copy(list, 0, newList, 0, remove);
                    }
                    if (remove < list.Length - 1)
                    {
                        Array.Copy(list, remove + 1, newList, remove, list.Length - 1 - remove);
                    }
                    list = (T[])newList;
                }
                if (shift >= 0)
                {
                    var temp = list[shift];
                    list[shift]   = list[shiftTo];
                    list[shiftTo] = temp;
                }
                EditorGUILayout.EndVertical();
            }

            ArrayPageButtons(list.GetHashCode(), list.Length);

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            return(list);
        }
コード例 #28
0
        public static void ArrayGUI(SerializedProperty arrayProp, string label, string helpMessage)
        {
            InitGUIStyle();

            bool addElement = false;
            int  moveBefore = -1;
            int  moveAfter  = -1;
            int  addAfter   = -1;
            int  toDelete   = -1;

            EditorGUILayout.BeginVertical("Box");

            EditorGUILayout.LabelField(label, arrayTitleLabel);
            EditorGUILayout.Separator();
            EditorGUILayout.HelpBox(helpMessage, MessageType.None);
            EditorGUILayout.Separator();

            addElement = GUILayout.Button("Ajouter un élément");

            EditorGUILayout.Separator();

            EditorGUI.indentLevel++;
            if (arrayProp.arraySize == 0)
            {
                EditorGUILayout.LabelField("Aucun élément", EditorStyles.boldLabel);
            }

            for (int i = 0; i < arrayProp.arraySize; ++i)
            {
                EditorGUILayout.BeginHorizontal();

                moveBefore = GUILayout.Button("▲") ? i : moveBefore;
                moveAfter  = GUILayout.Button("▼") ? i : moveAfter;

                EditorGUILayout.PropertyField(arrayProp.GetArrayElementAtIndex(i), noLabel);

                addAfter = GUILayout.Button("+") ? i : addAfter;
                toDelete = GUILayout.Button("X") ? i : toDelete;

                EditorGUILayout.EndHorizontal();
            }
            EditorGUI.indentLevel--;

            EditorGUILayout.Separator();
            EditorGUILayout.EndVertical();

            // Add element
            if (addElement)
            {
                arrayProp.arraySize++;
            }

            // Move Before
            if (moveBefore > -1 && moveBefore - 1 > -1)
            {
                arrayProp.MoveArrayElement(moveBefore, moveBefore - 1);
            }

            // Move After
            if (moveAfter > -1 && moveAfter + 1 < arrayProp.arraySize)
            {
                arrayProp.MoveArrayElement(moveAfter, moveAfter + 1);
            }

            // Add after an element
            if (addAfter > -1)
            {
                arrayProp.InsertArrayElementAtIndex(addAfter);
            }

            // Delete an element
            if (toDelete > -1)
            {
                arrayProp.DeleteArrayElementAtIndex(toDelete);
            }
        }
コード例 #29
0
    public override void OnInspectorGUI()
    {
        if (!metaTarget)
        {
            return;
        }
        main = (UIManager)metaTarget;

        Undo.RecordObject(main, "");
        Color defColor = GUI.color;

        if (main.UImodules == null)
        {
            main.UImodules = new List <Transform>();
        }

        if (main.pages == null)
        {
            main.pages = new List <UIManager.Page>();
        }

        #region UI Modules


        mySerializedObject.Update();
        listUIModules.drawHeaderCallback  = rect => { EditorGUI.LabelField(rect, "Canvas parent"); };
        listUIModules.drawElementCallback =
            (Rect rect, int index, bool isActive, bool isFocused) =>
        {
            EditorGUI.PropertyField(rect, listUIModules.serializedProperty.GetArrayElementAtIndex(index), GUIContent.none, true);
        };
        listUIModules.DoLayoutList();
        main.ArraysConvertation();
        if (listUIModules == null || listUIModules.count <= 0)
        {
            EditorGUILayout.HelpBox("Drag Canvas parent to get Panel", MessageType.Info);
        }
        if (main.panels == null || main.panels.Count <= 0)
        {
            EditorGUILayout.HelpBox("Canvas must have UIPanel", MessageType.Info);
        }


        mySerializedObject.ApplyModifiedProperties();

        #endregion

        #region Pages


        GUILayout.Space(20);

        EditorGUILayout.BeginVertical("Box");
        GUI.color = Color.red;
        GUILayout.Label("Pages", EditorStyles.centeredGreyMiniLabel, GUILayout.ExpandWidth(true));
        GUI.color = defColor;
        foreach (UIManager.Page page in main.pages)
        {
            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal("Box");
            if (GUILayout.Button("X", EditorStyles.miniButtonLeft, GUILayout.Width(20)))
            {
                main.pages.Remove(page);
                break;
            }

            if (edit == page)
            {
                if (GUILayout.Button("Hide", EditorStyles.miniButtonRight, GUILayout.Width(35)))
                {
                    edit = null;
                }
            }
            else
            {
                if (GUILayout.Button("Edit", EditorStyles.miniButtonRight, GUILayout.Width(35)))
                {
                    edit = page;
                }
            }

            page.name = EditorGUILayout.TextField(page.name, GUILayout.ExpandWidth(true));

            //   GUILayout.FlexibleSpace();
            UIManager.Page default_page = main.pages.Find(x => x.default_page);

            if (default_page == null)
            {
                default_page      = page;
                page.default_page = true;
            }

            if (page.default_page && default_page != page)
            {
                page.default_page = false;
            }


            if (page.default_page)
            {
                GUI.color = Color.red;
                GUILayout.Label("DEFAULT", GUILayout.Width(80));
                GUI.color = defColor;
            }
            else
            if (GUILayout.Button("Make default", EditorStyles.miniButtonRight, GUILayout.Width(80)))
            {
                default_page.default_page = false;
                default_page      = page;
                page.default_page = true;
            }

            EditorGUILayout.EndHorizontal();
            if (string.IsNullOrEmpty(page.name))
            {
                EditorGUILayout.HelpBox("Fill page name", MessageType.Warning);
            }
            EditorGUILayout.EndVertical();


            if (edit == page)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(40);
                EditorGUILayout.BeginVertical("Box");


                if (!AudioManager.Instance)
                {
                    EditorGUILayout.HelpBox("AudioAssistant is missing", MessageType.Error, true);
                }
                else if (AudioManager.Instance.tracks.Count > 0)
                {
                    List <string> tracks = new List <string>();
                    //  tracks.Add("-");
                    tracks.Add("None");
                    tracks.AddRange(AudioManager.Instance.tracks.Select(x => x.name).ToList());
                    int selected = -1;
                    selected = tracks.FindIndex(x => x == page.soundtrack);
                    if (selected == -1)
                    {
                        selected = 0;
                    }

                    selected = EditorGUILayout.Popup("Soundtrack", selected, tracks.ToArray());

                    page.soundtrack = tracks[selected];
                }

                if (!AdAssistant.Instance)
                {
                    EditorGUILayout.HelpBox("AdAssistant is missing", MessageType.Error, true);
                }
                else
                {
                    EditorGUILayout.BeginHorizontal();
                    page.show_ads = EditorGUILayout.Toggle(page.show_ads, GUILayout.Width(20));
                    GUILayout.Label("Show Ads", GUILayout.Width(100));
                    EditorGUILayout.EndHorizontal();
                }
                //bool active = GUI.enabled;
                //GUI.enabled = false;
                //EditorGUILayout.BeginHorizontal();
                //EditorGUILayout.Toggle(false, GUILayout.Width(20));
                //GUILayout.Label("Show Ads", GUILayout.Width(100));
                //EditorGUILayout.EndHorizontal();
                //GUI.enabled = active;

                //EditorGUILayout.BeginHorizontal();
                //page.setTimeScale = EditorGUILayout.Toggle(page.setTimeScale, GUILayout.Width(20));
                //GUILayout.Label("Time Scale", GUILayout.Width(100));
                //if (page.setTimeScale)
                //    page.timeScale = EditorGUILayout.Slider(page.timeScale, 0, 1);
                //EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Panel Name", EditorStyles.boldLabel, GUILayout.Width(150));
                GUI.color = Color.green;
                GUILayout.Label("Show", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                GUI.color = Color.yellow;
                GUILayout.Label("Ignor", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                GUI.color = Color.cyan;
                GUILayout.Label("Hide", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                GUI.color = defColor;
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginVertical();
                Dictionary <UIPanel, int> mask = new Dictionary <UIPanel, int>();
                foreach (UIPanel panel in main.panels)
                {
                    if (!mask.ContainsKey(panel))
                    {
                        mask.Add(panel, -1);
                    }
                    if (page.panels.Contains(panel))
                    {
                        mask[panel] = 1;
                    }
                    else if (page.ignoring_panels.Contains(panel))
                    {
                        mask[panel] = 0;
                    }
                }

                foreach (UIPanel panel in main.panels)
                {
                    EditorGUILayout.BeginHorizontal();
                    switch (mask[panel])
                    {
                    case -1: GUI.color = Color.cyan; break;

                    case 0: GUI.color = Color.yellow; break;

                    case 1: GUI.color = Color.green; break;
                    }
                    EditorGUILayout.LabelField(panel.name, GUILayout.Width(150));
                    GUI.color = defColor;

                    if (EditorGUILayout.Toggle(mask[panel] == 1))
                    {
                        mask[panel] = 1;
                    }
                    GUILayout.FlexibleSpace();
                    if (EditorGUILayout.Toggle(mask[panel] == 0))
                    {
                        mask[panel] = 0;
                    }
                    GUILayout.FlexibleSpace();
                    if (EditorGUILayout.Toggle(mask[panel] == -1))
                    {
                        mask[panel] = -1;
                    }
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.EndVertical();

                page.panels.Clear();
                page.ignoring_panels.Clear();
                foreach (KeyValuePair <UIPanel, int> pair in mask)
                {
                    if (pair.Value == 1)
                    {
                        page.panels.Add(pair.Key);
                    }
                    else if (pair.Value == 0)
                    {
                        page.ignoring_panels.Add(pair.Key);
                    }
                }

                EditorGUILayout.EndVertical();
                EditorGUILayout.EndHorizontal();
            }
        }
        GUI.color = Color.green;
        if (GUILayout.Button("Create Page", GUILayout.Width(100)))
        {
            main.pages.Add(new UIManager.Page());
        }

        GUI.color = defColor;
        EditorGUILayout.EndVertical();
        #endregion

        GUI.color = defColor;
        mySerializedObject.ApplyModifiedProperties();
    }
        private static void RenderList(SerializedProperty list)
        {
            EditorGUILayout.Space();
            GUILayout.BeginVertical();

            if (GUILayout.Button(AddButtonContent, EditorStyles.miniButton))
            {
                list.arraySize += 1;
                var speechCommand = list.GetArrayElementAtIndex(list.arraySize - 1);
                var keyword       = speechCommand.FindPropertyRelative("keyword");
                keyword.stringValue = string.Empty;
                var keyCode = speechCommand.FindPropertyRelative("keyCode");
                keyCode.intValue = (int)KeyCode.None;
                var action   = speechCommand.FindPropertyRelative("action");
                var actionId = action.FindPropertyRelative("id");
                actionId.intValue = 0;
            }

            GUILayout.Space(12f);

            if (list == null || list.arraySize == 0)
            {
                EditorGUILayout.HelpBox("Create a new Speech Command.", MessageType.Warning);
                GUILayout.EndVertical();
                return;
            }

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            var labelWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 36f;
            EditorGUILayout.LabelField(KeywordContent, GUILayout.ExpandWidth(true));
            EditorGUILayout.LabelField(KeyCodeContent, GUILayout.Width(64f));
            EditorGUILayout.LabelField(ActionContent, GUILayout.Width(64f));
            EditorGUILayout.LabelField(string.Empty, GUILayout.Width(24f));
            EditorGUIUtility.labelWidth = labelWidth;
            GUILayout.EndHorizontal();

            for (int i = 0; i < list.arraySize; i++)
            {
                EditorGUILayout.BeginHorizontal();
                SerializedProperty speechCommand = list.GetArrayElementAtIndex(i);
                var keyword = speechCommand.FindPropertyRelative("keyword");
                EditorGUILayout.PropertyField(keyword, GUIContent.none, GUILayout.ExpandWidth(true));
                var keyCode = speechCommand.FindPropertyRelative("keyCode");
                EditorGUILayout.PropertyField(keyCode, GUIContent.none, GUILayout.Width(64f));
                var action            = speechCommand.FindPropertyRelative("action");
                var actionId          = action.FindPropertyRelative("id");
                var actionDescription = action.FindPropertyRelative("description");
                var actionConstraint  = action.FindPropertyRelative("axisConstraint");

                EditorGUI.BeginChangeCheck();
                actionId.intValue = EditorGUILayout.IntPopup(GUIContent.none, actionId.intValue, actionLabels, actionIds, GUILayout.Width(64f));

                if (EditorGUI.EndChangeCheck())
                {
                    MixedRealityInputAction inputAction = actionId.intValue == 0 ? MixedRealityInputAction.None : MixedRealityManager.Instance.ActiveProfile.InputActionsProfile.InputActions[actionId.intValue - 1];
                    actionDescription.stringValue   = inputAction.Description;
                    actionConstraint.enumValueIndex = (int)inputAction.AxisConstraint;
                }

                if (GUILayout.Button(MinusButtonContent, EditorStyles.miniButtonRight, GUILayout.Width(24f)))
                {
                    list.DeleteArrayElementAtIndex(i);
                }

                EditorGUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();
            GUILayout.EndVertical();
        }