예제 #1
0
 public static int ToolbarDelayedIntField(int value)
 {
     return(EditorGUILayout.DelayedIntField(value, EditorStyles.toolbarTextField));
 }
        // GUI
        //------------------------------------------------------------------
        void OnGUI()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

            if (_editor == null || _targetPortrait == null)
            {
                Debug.LogError("Exit - Editor / Portrait is Null");
                CloseDialog();
                return;
            }

            //만약 Portriat가 바뀌었거나 Editor가 리셋되면 닫자
            if (_editor != apEditor.CurrentEditor || _targetPortrait != apEditor.CurrentEditor._portrait)
            {
                Debug.LogError("Exit - Editor / Portrait Missmatch");
                CloseDialog();
                return;
            }

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

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(tabBtnHeight));
            GUILayout.Space(5);
            if (apEditorUtil.ToggledButton("Portrait", _tab == TAB.PortriatSetting, tabBtnWidth, tabBtnHeight))
            {
                _tab = TAB.PortriatSetting;
            }
            if (apEditorUtil.ToggledButton("Editor", _tab == TAB.EditorSetting, tabBtnWidth, tabBtnHeight))
            {
                _tab = TAB.EditorSetting;
            }
            if (apEditorUtil.ToggledButton("About", _tab == TAB.About, tabBtnWidth, tabBtnHeight))
            {
                _tab = TAB.About;
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);

            int scrollHeight = height - 40;

            _scroll = EditorGUILayout.BeginScrollView(_scroll, false, true, GUILayout.Width(width), GUILayout.Height(scrollHeight));
            width  -= 25;
            GUILayout.BeginVertical(GUILayout.Width(width));

            switch (_tab)
            {
            case TAB.PortriatSetting:
            {
                //Portrait 설정
                EditorGUILayout.LabelField("Portrait Settings");
                GUILayout.Space(10);
                string nextName = EditorGUILayout.DelayedTextField("Name", _targetPortrait.name);
                if (nextName != _targetPortrait.name)
                {
                    _targetPortrait.name = nextName;
                }

                int nextFPS = EditorGUILayout.DelayedIntField("Update FPS", _targetPortrait._FPS);
                if (_targetPortrait._FPS != nextFPS)
                {
                    if (nextFPS < 10)
                    {
                        nextFPS = 10;
                    }
                    _targetPortrait._FPS = nextFPS;
                }

                bool nextGPUAcc = EditorGUILayout.Toggle("GPU Acceleration", _targetPortrait._isGPUAccel);
                if (nextGPUAcc != _targetPortrait._isGPUAccel)
                {
                    _targetPortrait._isGPUAccel = nextGPUAcc;
                }
            }
            break;

            case TAB.EditorSetting:
            {
                EditorGUILayout.LabelField("Editor Settings");
                GUILayout.Space(10);

                apEditor.LANGUAGE prevLanguage = _editor._language;
                bool prevGUIFPS = _editor._guiOption_isFPSVisible;

                Color prevColor_Background = _editor._colorOption_Background;
                Color prevColor_GridCenter = _editor._colorOption_GridCenter;
                Color prevColor_Grid       = _editor._colorOption_Grid;

                Color prevColor_MeshEdge        = _editor._colorOption_MeshEdge;
                Color prevColor_MeshHiddenEdge  = _editor._colorOption_MeshHiddenEdge;
                Color prevColor_Outline         = _editor._colorOption_Outline;
                Color prevColor_TFBorder        = _editor._colorOption_TransformBorder;
                Color prevColor_VertNotSelected = _editor._colorOption_VertColor_NotSelected;
                Color prevColor_VertSelected    = _editor._colorOption_VertColor_Selected;

                Color prevColor_GizmoFFDLine      = _editor._colorOption_GizmoFFDLine;
                Color prevColor_GizmoFFDInnerLine = _editor._colorOption_GizmoFFDInnerLine;

                _editor._language = (apEditor.LANGUAGE)EditorGUILayout.EnumPopup("Language", _editor._language);

                GUILayout.Space(10);
                _editor._guiOption_isFPSVisible = EditorGUILayout.Toggle("Show FPS", _editor._guiOption_isFPSVisible);


                GUILayout.Space(10);
                try
                {
                    int width_Btn   = 65;
                    int width_Color = width - (width_Btn + 8);

                    int height_Color = 18;
                    EditorGUILayout.LabelField("Background Colors");

                    //EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(height_Color));
                    //GUILayout.Space(5);
                    //_editor._colorOption_Background = EditorGUILayout.ColorField("Background", _editor._colorOption_Background, GUILayout.Width(width_Color), GUILayout.Height(height_Color));
                    //if(GUILayout.Button("Default", GUILayout.Width(width_Btn), GUILayout.Height(height_Color)))
                    //{
                    //	_editor._colorOption_Background = apEditor.DefaultColor_Background;
                    //}
                    //EditorGUILayout.EndHorizontal();

                    //_editor._colorOption_GridCenter = EditorGUILayout.ColorField("Grid Center", _editor._colorOption_GridCenter);
                    //_editor._colorOption_Grid = EditorGUILayout.ColorField("Grid", _editor._colorOption_Grid);
                    //_editor._colorOption_AtlasBorder = EditorGUILayout.ColorField("Atlas Border", _editor._colorOption_AtlasBorder);

                    _editor._colorOption_Background  = ColorUI("Background", _editor._colorOption_Background, width, apEditor.DefaultColor_Background);
                    _editor._colorOption_GridCenter  = ColorUI("Grid Center", _editor._colorOption_GridCenter, width, apEditor.DefaultColor_GridCenter);
                    _editor._colorOption_Grid        = ColorUI("Grid", _editor._colorOption_Grid, width, apEditor.DefaultColor_Grid);
                    _editor._colorOption_AtlasBorder = ColorUI("Atlas Border", _editor._colorOption_AtlasBorder, width, apEditor.DefaultColor_AtlasBorder);


                    GUILayout.Space(5);
                    EditorGUILayout.LabelField("Mesh GUI Colors");
                    //_editor._colorOption_MeshEdge = EditorGUILayout.ColorField("Mesh Edge", _editor._colorOption_MeshEdge);
                    //_editor._colorOption_MeshHiddenEdge = EditorGUILayout.ColorField("Mesh Hidden Edge", _editor._colorOption_MeshHiddenEdge);
                    //_editor._colorOption_Outline = EditorGUILayout.ColorField("Outline", _editor._colorOption_Outline);
                    //_editor._colorOption_TransformBorder = EditorGUILayout.ColorField("Transform Border", _editor._colorOption_TransformBorder);
                    //_editor._colorOption_VertColor_NotSelected = EditorGUILayout.ColorField("Vertex", _editor._colorOption_VertColor_NotSelected);
                    //_editor._colorOption_VertColor_Selected = EditorGUILayout.ColorField("Selected Vertex", _editor._colorOption_VertColor_Selected);

                    _editor._colorOption_MeshEdge              = ColorUI("Mesh Edge", _editor._colorOption_MeshEdge, width, apEditor.DefaultColor_MeshEdge);
                    _editor._colorOption_MeshHiddenEdge        = ColorUI("Mesh Hidden Edge", _editor._colorOption_MeshHiddenEdge, width, apEditor.DefaultColor_MeshHiddenEdge);
                    _editor._colorOption_Outline               = ColorUI("Outline", _editor._colorOption_Outline, width, apEditor.DefaultColor_Outline);
                    _editor._colorOption_TransformBorder       = ColorUI("Transform Border", _editor._colorOption_TransformBorder, width, apEditor.DefaultColor_TransformBorder);
                    _editor._colorOption_VertColor_NotSelected = ColorUI("Vertex", _editor._colorOption_VertColor_NotSelected, width, apEditor.DefaultColor_VertNotSelected);
                    _editor._colorOption_VertColor_Selected    = ColorUI("Selected Vertex", _editor._colorOption_VertColor_Selected, width, apEditor.DefaultColor_VertSelected);


                    GUILayout.Space(5);
                    EditorGUILayout.LabelField("Gizmo Colors");
                    //_editor._colorOption_GizmoFFDLine = EditorGUILayout.ColorField("FFD Line", _editor._colorOption_GizmoFFDLine);
                    //_editor._colorOption_GizmoFFDInnerLine = EditorGUILayout.ColorField("FFD Inner Line", _editor._colorOption_GizmoFFDInnerLine);

                    _editor._colorOption_GizmoFFDLine      = ColorUI("FFD Line", _editor._colorOption_GizmoFFDLine, width, apEditor.DefaultColor_GizmoFFDLine);
                    _editor._colorOption_GizmoFFDInnerLine = ColorUI("FFD Inner Line", _editor._colorOption_GizmoFFDInnerLine, width, apEditor.DefaultColor_GizmoFFDInnerLine);
                }
                catch (Exception)
                {
                }

                GUILayout.Space(20);
                if (GUILayout.Button("Restore Editor Default Setting", GUILayout.Height(20)))
                {
                    _editor.RestoreEditorPref();
                }


                if (prevLanguage != _editor._language ||
                    prevGUIFPS != _editor._guiOption_isFPSVisible ||
                    prevColor_Background != _editor._colorOption_Background ||
                    prevColor_GridCenter != _editor._colorOption_GridCenter ||
                    prevColor_Grid != _editor._colorOption_Grid ||

                    prevColor_MeshEdge != _editor._colorOption_MeshEdge ||
                    prevColor_MeshHiddenEdge != _editor._colorOption_MeshHiddenEdge ||
                    prevColor_Outline != _editor._colorOption_Outline ||
                    prevColor_TFBorder != _editor._colorOption_TransformBorder ||
                    prevColor_VertNotSelected != _editor._colorOption_VertColor_NotSelected ||
                    prevColor_VertSelected != _editor._colorOption_VertColor_Selected ||

                    prevColor_GizmoFFDLine != _editor._colorOption_GizmoFFDLine ||
                    prevColor_GizmoFFDInnerLine != _editor._colorOption_GizmoFFDInnerLine)
                {
                    _editor.SaveEditorPref();
                }
            }
            break;

            case TAB.About:
            {
                EditorGUILayout.LabelField("About");

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

                EditorGUILayout.LabelField("[AnyPortrait]");
                GUILayout.Space(10);
                EditorGUILayout.LabelField("Copyright (c) 2017 RainyRizzle. All right reserved.");

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

                EditorGUILayout.LabelField("[PSD File Import Library]");
                GUILayout.Space(10);
                EditorGUILayout.LabelField("Ntreev Photoshop Document Parser for .Net");
                GUILayout.Space(10);

                EditorGUILayout.LabelField("Released under the MIT License.");
                GUILayout.Space(10);

                EditorGUILayout.LabelField("Copyright (c) 2015 Ntreev Soft co., Ltd.");
                GUILayout.Space(10);

                EditorGUILayout.LabelField("Permission is hereby granted, free of charge,");
                EditorGUILayout.LabelField("to any person obtaining a copy of this software");
                EditorGUILayout.LabelField("and associated documentation files (the \"Software\"),");
                EditorGUILayout.LabelField("to deal in the Software without restriction,");
                EditorGUILayout.LabelField("including without limitation the rights ");
                EditorGUILayout.LabelField("to use, copy, modify, merge, publish, distribute,");
                EditorGUILayout.LabelField("sublicense, and/or sell copies of the Software, ");
                EditorGUILayout.LabelField("and to permit persons to whom the Software is furnished");
                EditorGUILayout.LabelField("to do so, subject to the following conditions:");
                GUILayout.Space(10);

                EditorGUILayout.LabelField("The above copyright notice and ");
                EditorGUILayout.LabelField("this permission notice shall be included");
                EditorGUILayout.LabelField("in all copies or substantial portions of the Software.");
                GUILayout.Space(10);

                EditorGUILayout.LabelField("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT ");
                EditorGUILayout.LabelField("WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, ");
                EditorGUILayout.LabelField("INCLUDING BUT NOT LIMITED TO THE WARRANTIES ");
                EditorGUILayout.LabelField("OF MERCHANTABILITY, FITNESS FOR A PARTICULAR ");
                EditorGUILayout.LabelField("PURPOSE AND NONINFRINGEMENT. ");
                EditorGUILayout.LabelField("IN NO EVENT SHALL THE AUTHORS OR ");
                EditorGUILayout.LabelField("COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES ");
                EditorGUILayout.LabelField("OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ");
                EditorGUILayout.LabelField("TORT OR OTHERWISE, ARISING FROM, OUT OF OR ");
                EditorGUILayout.LabelField("IN CONNECTION WITH THE SOFTWARE OR ");
                EditorGUILayout.LabelField("THE USE OR OTHER DEALINGS IN THE SOFTWARE.");

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

                EditorGUILayout.LabelField("[GIF Export Library]");
                GUILayout.Space(10);
                EditorGUILayout.LabelField("NGif, Animated GIF Encoder for .NET");
                GUILayout.Space(10);
                EditorGUILayout.LabelField("Released under the CPOL 1.02.");
                GUILayout.Space(10);
            }
            break;
            }



            GUILayout.Space(height);
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }
예제 #3
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            serializedObject.Update();

            ResourceComponent t = (ResourceComponent)target;

            bool isEditorResourceMode = (bool)m_EditorResourceModeFieldInfo.GetValue(target);

            if (isEditorResourceMode)
            {
                EditorGUILayout.HelpBox("Editor resource mode is enabled. Some options are disabled.", MessageType.Warning);
            }

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            {
                if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
                {
                    EditorGUILayout.EnumPopup("Resource Mode", t.ResourceMode);
                }
                else
                {
                    int selectedIndex = EditorGUILayout.Popup("Resource Mode", m_ResourceModeIndex, ResourceModeNames);
                    if (selectedIndex != m_ResourceModeIndex)
                    {
                        m_ResourceModeIndex           = selectedIndex;
                        m_ResourceMode.enumValueIndex = selectedIndex + 1;
                    }
                }

                m_ReadWritePathType.enumValueIndex = (int)(ReadWritePathType)EditorGUILayout.EnumPopup("Read Write Path Type", t.ReadWritePathType);
            }
            EditorGUI.EndDisabledGroup();

            float minUnloadUnusedAssetsInterval = EditorGUILayout.Slider("Min Unload Unused Assets Interval", m_MinUnloadUnusedAssetsInterval.floatValue, 0f, 3600f);

            if (minUnloadUnusedAssetsInterval != m_MinUnloadUnusedAssetsInterval.floatValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.MinUnloadUnusedAssetsInterval = minUnloadUnusedAssetsInterval;
                }
                else
                {
                    m_MinUnloadUnusedAssetsInterval.floatValue = minUnloadUnusedAssetsInterval;
                }
            }

            float maxUnloadUnusedAssetsInterval = EditorGUILayout.Slider("Max Unload Unused Assets Interval", m_MaxUnloadUnusedAssetsInterval.floatValue, 0f, 3600f);

            if (maxUnloadUnusedAssetsInterval != m_MaxUnloadUnusedAssetsInterval.floatValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.MaxUnloadUnusedAssetsInterval = maxUnloadUnusedAssetsInterval;
                }
                else
                {
                    m_MaxUnloadUnusedAssetsInterval.floatValue = maxUnloadUnusedAssetsInterval;
                }
            }

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlaying && isEditorResourceMode);
            {
                float assetAutoReleaseInterval = EditorGUILayout.DelayedFloatField("Asset Auto Release Interval", m_AssetAutoReleaseInterval.floatValue);
                if (assetAutoReleaseInterval != m_AssetAutoReleaseInterval.floatValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.AssetAutoReleaseInterval = assetAutoReleaseInterval;
                    }
                    else
                    {
                        m_AssetAutoReleaseInterval.floatValue = assetAutoReleaseInterval;
                    }
                }

                int assetCapacity = EditorGUILayout.DelayedIntField("Asset Capacity", m_AssetCapacity.intValue);
                if (assetCapacity != m_AssetCapacity.intValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.AssetCapacity = assetCapacity;
                    }
                    else
                    {
                        m_AssetCapacity.intValue = assetCapacity;
                    }
                }

                float assetExpireTime = EditorGUILayout.DelayedFloatField("Asset Expire Time", m_AssetExpireTime.floatValue);
                if (assetExpireTime != m_AssetExpireTime.floatValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.AssetExpireTime = assetExpireTime;
                    }
                    else
                    {
                        m_AssetExpireTime.floatValue = assetExpireTime;
                    }
                }

                int assetPriority = EditorGUILayout.DelayedIntField("Asset Priority", m_AssetPriority.intValue);
                if (assetPriority != m_AssetPriority.intValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.AssetPriority = assetPriority;
                    }
                    else
                    {
                        m_AssetPriority.intValue = assetPriority;
                    }
                }

                float resourceAutoReleaseInterval = EditorGUILayout.DelayedFloatField("Resource Auto Release Interval", m_ResourceAutoReleaseInterval.floatValue);
                if (resourceAutoReleaseInterval != m_ResourceAutoReleaseInterval.floatValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.ResourceAutoReleaseInterval = resourceAutoReleaseInterval;
                    }
                    else
                    {
                        m_ResourceAutoReleaseInterval.floatValue = resourceAutoReleaseInterval;
                    }
                }

                int resourceCapacity = EditorGUILayout.DelayedIntField("Resource Capacity", m_ResourceCapacity.intValue);
                if (resourceCapacity != m_ResourceCapacity.intValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.ResourceCapacity = resourceCapacity;
                    }
                    else
                    {
                        m_ResourceCapacity.intValue = resourceCapacity;
                    }
                }

                float resourceExpireTime = EditorGUILayout.DelayedFloatField("Resource Expire Time", m_ResourceExpireTime.floatValue);
                if (resourceExpireTime != m_ResourceExpireTime.floatValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.ResourceExpireTime = resourceExpireTime;
                    }
                    else
                    {
                        m_ResourceExpireTime.floatValue = resourceExpireTime;
                    }
                }

                int resourcePriority = EditorGUILayout.DelayedIntField("Resource Priority", m_ResourcePriority.intValue);
                if (resourcePriority != m_ResourcePriority.intValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.ResourcePriority = resourcePriority;
                    }
                    else
                    {
                        m_ResourcePriority.intValue = resourcePriority;
                    }
                }

                if (m_ResourceModeIndex > 0)
                {
                    string updatePrefixUri = EditorGUILayout.DelayedTextField("Update Prefix Uri", m_UpdatePrefixUri.stringValue);
                    if (updatePrefixUri != m_UpdatePrefixUri.stringValue)
                    {
                        if (EditorApplication.isPlaying)
                        {
                            t.UpdatePrefixUri = updatePrefixUri;
                        }
                        else
                        {
                            m_UpdatePrefixUri.stringValue = updatePrefixUri;
                        }
                    }

                    int generateReadWriteVersionListLength = EditorGUILayout.DelayedIntField("Generate Read Write Version List Length", m_GenerateReadWriteVersionListLength.intValue);
                    if (generateReadWriteVersionListLength != m_GenerateReadWriteVersionListLength.intValue)
                    {
                        if (EditorApplication.isPlaying)
                        {
                            t.GenerateReadWriteVersionListLength = generateReadWriteVersionListLength;
                        }
                        else
                        {
                            m_GenerateReadWriteVersionListLength.intValue = generateReadWriteVersionListLength;
                        }
                    }

                    int updateRetryCount = EditorGUILayout.DelayedIntField("Update Retry Count", m_UpdateRetryCount.intValue);
                    if (updateRetryCount != m_UpdateRetryCount.intValue)
                    {
                        if (EditorApplication.isPlaying)
                        {
                            t.UpdateRetryCount = updateRetryCount;
                        }
                        else
                        {
                            m_UpdateRetryCount.intValue = updateRetryCount;
                        }
                    }
                }
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            {
                EditorGUILayout.PropertyField(m_InstanceRoot);

                m_ResourceHelperInfo.Draw();
                m_LoadResourceAgentHelperInfo.Draw();
                m_LoadResourceAgentHelperCount.intValue = EditorGUILayout.IntSlider("Load Resource Agent Helper Count", m_LoadResourceAgentHelperCount.intValue, 1, 128);
            }
            EditorGUI.EndDisabledGroup();

            if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
            {
                EditorGUILayout.LabelField("Unload Unused Assets", Utility.Text.Format("{0} / {1}", t.LastUnloadUnusedAssetsOperationElapseSeconds.ToString("F2"), t.MaxUnloadUnusedAssetsInterval.ToString("F2")));
                EditorGUILayout.LabelField("Read Only Path", t.ReadOnlyPath.ToString());
                EditorGUILayout.LabelField("Read Write Path", t.ReadWritePath.ToString());
                EditorGUILayout.LabelField("Current Variant", t.CurrentVariant ?? "<Unknwon>");
                EditorGUILayout.LabelField("Applicable Game Version", isEditorResourceMode ? "N/A" : t.ApplicableGameVersion ?? "<Unknwon>");
                EditorGUILayout.LabelField("Internal Resource Version", isEditorResourceMode ? "N/A" : t.InternalResourceVersion.ToString());
                EditorGUILayout.LabelField("Asset Count", isEditorResourceMode ? "N/A" : t.AssetCount.ToString());
                EditorGUILayout.LabelField("Resource Count", isEditorResourceMode ? "N/A" : t.ResourceCount.ToString());
                EditorGUILayout.LabelField("Resource Group Count", isEditorResourceMode ? "N/A" : t.ResourceGroupCount.ToString());
                if (m_ResourceModeIndex > 0)
                {
                    EditorGUILayout.LabelField("Applying Resource Pack Path", isEditorResourceMode ? "N/A" : t.ApplyingResourcePackPath ?? "<Unknwon>");
                    EditorGUILayout.LabelField("Apply Waiting Count", isEditorResourceMode ? "N/A" : t.ApplyWaitingCount.ToString());
                    EditorGUILayout.LabelField("Updating Resource Group", isEditorResourceMode ? "N/A" : t.UpdatingResourceGroup != null ? t.UpdatingResourceGroup.Name : "<Unknwon>");
                    EditorGUILayout.LabelField("Update Waiting Count", isEditorResourceMode ? "N/A" : t.UpdateWaitingCount.ToString());
                    EditorGUILayout.LabelField("Update Waiting While Playing Count", isEditorResourceMode ? "N/A" : t.UpdateWaitingWhilePlayingCount.ToString());
                    EditorGUILayout.LabelField("Update Candidate Count", isEditorResourceMode ? "N/A" : t.UpdateCandidateCount.ToString());
                }
                EditorGUILayout.LabelField("Load Total Agent Count", isEditorResourceMode ? "N/A" : t.LoadTotalAgentCount.ToString());
                EditorGUILayout.LabelField("Load Free Agent Count", isEditorResourceMode ? "N/A" : t.LoadFreeAgentCount.ToString());
                EditorGUILayout.LabelField("Load Working Agent Count", isEditorResourceMode ? "N/A" : t.LoadWorkingAgentCount.ToString());
                EditorGUILayout.LabelField("Load Waiting Task Count", isEditorResourceMode ? "N/A" : t.LoadWaitingTaskCount.ToString());
                if (!isEditorResourceMode)
                {
                    EditorGUILayout.BeginVertical("box");
                    {
                        TaskInfo[] loadAssetInfos = t.GetAllLoadAssetInfos();
                        if (loadAssetInfos.Length > 0)
                        {
                            foreach (TaskInfo loadAssetInfo in loadAssetInfos)
                            {
                                DrawLoadAssetInfo(loadAssetInfo);
                            }

                            if (GUILayout.Button("Export CSV Data"))
                            {
                                string exportFileName = EditorUtility.SaveFilePanel("Export CSV Data", string.Empty, "Load Asset Task Data.csv", string.Empty);
                                if (!string.IsNullOrEmpty(exportFileName))
                                {
                                    try
                                    {
                                        int      index = 0;
                                        string[] data  = new string[loadAssetInfos.Length + 1];
                                        data[index++] = "Load Asset Name,Serial Id,Priority,Status";
                                        foreach (TaskInfo loadAssetInfo in loadAssetInfos)
                                        {
                                            data[index++] = Utility.Text.Format("{0},{1},{2},{3}", loadAssetInfo.Description, loadAssetInfo.SerialId.ToString(), loadAssetInfo.Priority.ToString(), loadAssetInfo.Status.ToString());
                                        }

                                        File.WriteAllLines(exportFileName, data, Encoding.UTF8);
                                        Debug.Log(Utility.Text.Format("Export load asset task CSV data to '{0}' success.", exportFileName));
                                    }
                                    catch (Exception exception)
                                    {
                                        Debug.LogError(Utility.Text.Format("Export load asset task CSV data to '{0}' failure, exception is '{1}'.", exportFileName, exception.ToString()));
                                    }
                                }
                            }
                        }
                        else
                        {
                            GUILayout.Label("Load Asset Task is Empty ...");
                        }
                    }
                    EditorGUILayout.EndVertical();
                }
            }

            serializedObject.ApplyModifiedProperties();

            Repaint();
        }
예제 #4
0
    public override void OnInspectorGUI()
    {
        World world = (World)target;

        //Edit the worldsize
        Vector2 worldSize = EditorGUILayout.Vector2Field("WorldSize: ", new Vector2(world.width, world.height));

        world.width  = (int)worldSize.x;
        world.height = (int)worldSize.y;

        //BiomModels
        getObjectsForArray("BiomModels: ", ref showBiomModels, ref world.biomModels, typeof(BiomModels));

        //HexagonBorders
        getObjectsForArray("HexagonBorders: ", ref showHexagonBorders, ref world.hexagonBorderModels, typeof(HexagonBorders));

        //StructureModels
        getObjectsForArray("StructureModels: ", ref showStructureModels, ref world.structureModels, typeof(Structures));

        //BuildingModels
        getObjectsForArray("BuildingModels: ", ref showBuildingModels, ref world.buildingModels, typeof(Buildings));

        //Ressources
        getSpritesForArray("RessourceSprites: ", ref showRessourceSprites, ref world.ressourceSprites, typeof(Ressources));
        getObjectsForArray("RessourceTexts: ", ref showRessourceColors, ref world.ressourceTexts, typeof(Ressources));

        //Bioms
        showBioms = EditorGUILayout.Toggle("Bioms: ", showBioms);
        if (showBioms)
        {
            //Change the size of the array
            BiomData[] arrayNew = new BiomData[EditorGUILayout.DelayedIntField("     Size:", world.biomsData.Length)];
            if (arrayNew.Length != world.biomsData.Length && arrayNew.Length > 0)
            {
                //Copy the values of array
                if (arrayNew.Length > world.biomsData.Length)
                {
                    for (int i = 0; i < world.biomsData.Length; i++)
                    {
                        arrayNew[i] = world.biomsData[i];
                    }
                }
                else
                {
                    for (int i = 0; i < arrayNew.Length; i++)
                    {
                        arrayNew[i] = world.biomsData[i];
                    }
                }

                world.biomsData = arrayNew;
            }

            for (int i = 0; i < world.biomsData.Length; i++)
            {
                EditorGUILayout.LabelField("     " + System.Enum.GetName(typeof(Bioms), i));
                world.biomsData[i].biomModel = (BiomModels)EditorGUILayout.EnumPopup("          BiomModel:", world.biomsData[i].biomModel);
                world.biomsData[i].structure = (Structures)EditorGUILayout.EnumPopup("          Structure:", world.biomsData[i].structure);
                EditorGUILayout.LabelField("");
            }
        }

        //Time
        world.timeText = (Text)EditorGUILayout.ObjectField("Time Text: ", world.timeText, typeof(Text));
    }
예제 #5
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            m_Rule._OnInspectorGUI();

            m_Rule.BundleName = EditorGUILayout.TextField("Bundle名字", m_Rule.BundleName).ToLower();
            EditorGUILayout.Space();

            EditorGUILayout.HelpBox("可以没有Shaders\n"
                                    + "用途:方便查看用到的Shader\n"
                                    + "\t在Shaders上扩展功能来收集分析Shader\n"
                                    + "用法:\n"
                                    + "\t1. 写一个继承自IShaders的类\n"
                                    + "\t2. 创建这个类的Asset,拖到下方"
                                    , MessageType.Info);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("Shaders")
                                          , EditorGUIUtility.TrTextContent("Shaders")
                                          , true);
            EditorGUILayout.Space();

            m_Rule.AutoGenerateShaderVariantCollection = EditorGUILayout.Toggle("自动生成变体集"
                                                                                , m_Rule.AutoGenerateShaderVariantCollection);
            if (m_Rule.AutoGenerateShaderVariantCollection)
            {
                m_Rule.AutoGenerateShaderVariantCollectionPath = EGLUtility.AssetPath <ShaderVariantCollection>("自动变体集路径"
                                                                                                                , m_Rule.AutoGenerateShaderVariantCollectionPath);
            }

            m_Rule.CustomShaderVariantCollectionPathsFoldout = EditorGUILayout.Foldout(m_Rule.CustomShaderVariantCollectionPathsFoldout
                                                                                       , "自定义变体集");
            if (m_Rule.CustomShaderVariantCollectionPathsFoldout)
            {
                EditorGUI.indentLevel++;
                int oldCount = m_Rule.CustomShaderVariantCollectionPaths == null ? 0 : m_Rule.CustomShaderVariantCollectionPaths.Length;
                int count    = EditorGUILayout.DelayedIntField("数量", oldCount);
                if (count != oldCount)
                {
                    string[] customShaderVariantCollectionPaths = new string[count];
                    count = Mathf.Min(count, oldCount);
                    for (int iShader = 0; iShader < count; iShader++)
                    {
                        customShaderVariantCollectionPaths[iShader] = m_Rule.CustomShaderVariantCollectionPaths[iShader];
                    }

                    m_Rule.CustomShaderVariantCollectionPaths = customShaderVariantCollectionPaths;
                }

                count = m_Rule.CustomShaderVariantCollectionPaths == null ? 0 : m_Rule.CustomShaderVariantCollectionPaths.Length;
                for (int iShader = 0; iShader < count; iShader++)
                {
                    m_Rule.CustomShaderVariantCollectionPaths[iShader] = EGLUtility.AssetPath <ShaderVariantCollection>("自定义变体集路径"
                                                                                                                        , m_Rule.CustomShaderVariantCollectionPaths[iShader]);
                }
                EditorGUI.indentLevel--;
            }

            GUI.enabled = true;
            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
                EditorUtility.SetDirty(target);
            }
        }
예제 #6
0
    public override void OnInspectorGUI()
    {
        Tapestry_AnimatedLight l = target as Tapestry_AnimatedLight;

        string
            displayTooltip          = "What string will display on the player's HUD when looking at this object.",
            changeTimeTooltip       = "The amount of time, in seconds, it takes for the door to open or close.",
            interactableTooltip     = "Can the player interact with this door?",
            displayNameTooltip      = "Should the object still show its display name when the player's cursor is hovering over the object?",
            toggleOnActivateTooltip = "Should the light switch between being on or off when the player activates it?";

        GUILayout.BeginVertical("box");

        GUILayout.BeginHorizontal();
        GUILayout.Label(new GUIContent("Display Name", displayTooltip));
        GUILayout.FlexibleSpace();
        l.displayName = EditorGUILayout.DelayedTextField(l.displayName, GUILayout.Width(270));
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label(new GUIContent("Change Time", changeTimeTooltip));
        l.transitionSpeed = EditorGUILayout.DelayedFloatField(l.transitionSpeed, GUILayout.Width(30));
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Turn On", GUILayout.Width(70)))
        {
            if (Application.isPlaying)
            {
                l.TurnOn();
            }
            else
            {
                l.TurnOn(true);
            }
        }
        if (GUILayout.Button("Turn Off", GUILayout.Width(70)))
        {
            if (Application.isPlaying)
            {
                l.TurnOff();
            }
            else
            {
                l.TurnOff(true);
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        l.isInteractable = EditorGUILayout.Toggle(l.isInteractable, GUILayout.Width(12));
        GUILayout.Label(new GUIContent("Interactable?", interactableTooltip));
        GUILayout.Space(20);
        if (!l.isInteractable)
        {
            l.displayNameWhenUnactivatable = EditorGUILayout.Toggle(l.displayNameWhenUnactivatable, GUILayout.Width(12));
            GUILayout.Label(new GUIContent("Display Name Anyway?", displayNameTooltip));
            GUILayout.FlexibleSpace();
        }
        else
        {
            l.toggleOnActivate = EditorGUILayout.Toggle(l.toggleOnActivate, GUILayout.Width(12));
            GUILayout.Label(new GUIContent("Toggle on Activate?", toggleOnActivateTooltip));
            GUILayout.FlexibleSpace();
        }
        GUILayout.EndHorizontal();

        GUILayout.EndVertical();

        toolbarActive = GUILayout.Toolbar(toolbarActive, toolbarNames);

        if (toolbarActive != -1)
        {
            if (toolbarNames[toolbarActive] == "Jitter")
            {
                string
                    lintJitterTooltip     = "Does the intensity of the light randomly change over time?",
                    lposJitterTooltip     = "Does the position of the light randomly change over time?",
                    emissionJitterTooltip = "Does this light contain something that has emission that changes randomly over time?";

                GUILayout.BeginVertical("box");

                GUILayout.BeginHorizontal();
                l.lightIntensityJitter = EditorGUILayout.Toggle(l.lightIntensityJitter, GUILayout.Width(12));
                GUILayout.Label(new GUIContent("Light Intensity Jitter?", lintJitterTooltip));
                GUILayout.EndHorizontal();

                if (l.lightIntensityJitter)
                {
                    string
                        lintBaseTooltip = "The base intensity of the light. This will override any changes made to the Intensity parameter of the Light component on T_Light; if you intend to use jitter, set the value here instead.",
                        lvarTooltip     = "How far the intensity can deviate from its base intensity.",
                        lspeedTooltip   = "How long, in seconds, it takes to reach the jitter target at maximum. (Minimum is 40% of this value)";

                    GUILayout.BeginVertical("box");

                    GUILayout.BeginHorizontal();
                    GUILayout.Label(new GUIContent("Intensity Variance", lvarTooltip));
                    l.lightIntensityJitterAmount = EditorGUILayout.DelayedFloatField(l.lightIntensityJitterAmount, GUILayout.Width(40));
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent("Jitter Speed", lspeedTooltip));
                    l.lightJitterSpeed = EditorGUILayout.DelayedFloatField(l.lightJitterSpeed, GUILayout.Width(40));
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Label(new GUIContent("Base Intensity", lintBaseTooltip));
                    l.lightIntensityBase = EditorGUILayout.DelayedFloatField(l.lightIntensityBase, GUILayout.Width(40));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();
                }

                GUILayout.BeginHorizontal();
                l.lightPositionJitter = EditorGUILayout.Toggle(l.lightPositionJitter, GUILayout.Width(12));
                GUILayout.Label(new GUIContent("Light Position Jitter?", lposJitterTooltip));
                GUILayout.EndHorizontal();

                if (l.lightPositionJitter)
                {
                    string
                        ldistTooltip  = "How far, in Unity units, the light can deviate from its starting position.",
                        lspeedTooltip = "How long, in seconds, it takes to reach the jitter target at maximum. (Minimum is 40% of this value)";

                    GUILayout.BeginVertical("box");

                    GUILayout.BeginHorizontal();
                    GUILayout.Label(new GUIContent("Position Variance", ldistTooltip));
                    l.positionJitterAmount = EditorGUILayout.DelayedFloatField(l.positionJitterAmount, GUILayout.Width(40));
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent("Jitter Speed", lspeedTooltip));
                    l.positionJitterSpeed = EditorGUILayout.DelayedFloatField(l.positionJitterSpeed, GUILayout.Width(40));
                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();
                }

                GUILayout.BeginHorizontal();
                l.emissionJitter = EditorGUILayout.Toggle(l.emissionJitter, GUILayout.Width(12));
                GUILayout.Label(new GUIContent("Emission Jitter?", emissionJitterTooltip));
                GUILayout.EndHorizontal();

                if (l.emissionJitter)
                {
                    string
                        erangeTooltip = "The minimum and maximum emission values that the object will choose between randomly. Note that values above 1.0 will clamp to 1.0 unless the player has HDR enabled.",
                        ecolTooltip   = "What color is multiplied against the emissive map.",
                        espeedTooltip = "How long, in seconds, it takes to reach the jitter target at maximum. (Minimum is 40% of this value)";

                    GUILayout.BeginVertical("box");

                    GUILayout.BeginHorizontal();
                    GUILayout.Label(new GUIContent("Emission Range", erangeTooltip));
                    l.emissionMin = EditorGUILayout.DelayedFloatField(l.emissionMin, GUILayout.Width(40));
                    l.emissionMax = EditorGUILayout.DelayedFloatField(l.emissionMax, GUILayout.Width(40));
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent("Jitter Speed", espeedTooltip));
                    l.emissionJitterSpeed = EditorGUILayout.DelayedFloatField(l.emissionJitterSpeed, GUILayout.Width(40));
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Label(new GUIContent("Emission Color", ecolTooltip));
                    l.emissionColor = EditorGUILayout.ColorField(l.emissionColor, GUILayout.Width(80));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();
                }

                GUILayout.EndVertical();
            }
            if (toolbarNames[toolbarActive] == "Particles")
            {
                string
                    inTooltip     = "Whether to use the particle system attached to T_PS_In. If true, plays the system when the light is turned on.",
                    activeTooltip = "Whether to use the particle system attached to T_PS_Active. If true, plays the system when the light is on, and shuts off the system when the light is off.",
                    outTooltip    = "Whether to use the particle system attached to T_PS_Out. If true, plays the system when the light is turned off.";

                GUILayout.BeginVertical("box");

                GUILayout.BeginHorizontal();
                l.useInPsys = EditorGUILayout.Toggle(l.useInPsys, GUILayout.Width(12));
                GUILayout.Label(new GUIContent("Use 'In'?", inTooltip));
                GUILayout.FlexibleSpace();
                l.useHoldPsys = EditorGUILayout.Toggle(l.useHoldPsys, GUILayout.Width(12));
                GUILayout.Label(new GUIContent("Use 'Active'?", activeTooltip));
                GUILayout.FlexibleSpace();
                l.useOutPsys = EditorGUILayout.Toggle(l.useOutPsys, GUILayout.Width(12));
                GUILayout.Label(new GUIContent("Use 'Out'?", outTooltip));
                GUILayout.EndHorizontal();

                GUILayout.EndVertical();
            }
            if (toolbarNames[toolbarActive] == "Sound")
            {
                string
                    inSoundTooltip     = "The sound to play when the light is turned on.",
                    activeSoundTooltip = "The sound to play while the light is on. This soundclip is looped for as long as the light stays on.",
                    outSoundTooltip    = "The sound to play when the light is turned off.";

                GUILayout.BeginVertical("box");

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent("'In' Sound", inSoundTooltip));
                l.inSound = (AudioClip)EditorGUILayout.ObjectField(l.inSound, typeof(AudioClip), true, GUILayout.Width(240));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent("'Active' Sound", activeSoundTooltip));
                l.activeSound = (AudioClip)EditorGUILayout.ObjectField(l.activeSound, typeof(AudioClip), true, GUILayout.Width(240));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent("'Out' Sound", outSoundTooltip));
                l.outSound = (AudioClip)EditorGUILayout.ObjectField(l.outSound, typeof(AudioClip), true, GUILayout.Width(240));
                GUILayout.EndHorizontal();

                GUILayout.EndVertical();
            }
            if (toolbarNames[toolbarActive] == "Timing")
            {
                string
                    clockLightTooltip = "Does this light turn itself on and off at specific times of day? Note: Enabling this option will disable the Timed Light controls.",
                    timedLightTooltip = "Does this light switch between on and off after a certain amount of time elapses? Note: Enabling this option will disable the Clock Light controls.",
                    durationTooltip   = "How long the light remains on (or off, if inverted) before switching to the other state.",
                    invertTooltip     = "By default, a timed light will stay on for a certain time before turning itself off. Setting this to true reverses this behavior.",
                    onTimeTooltip     = "What time of day the light turns itself on. Please note, at extremely high time speeds, the light may miss its cue to change.",
                    offTimeTooltip    = "What time of day the light turns itself off. Please note, at extremely high time speeds, the light may miss its cue to change.";

                GUILayout.BeginVertical("box");

                GUILayout.BeginHorizontal();
                l.timedLight = EditorGUILayout.Toggle(l.timedLight, GUILayout.Width(12));
                GUILayout.Label(new GUIContent("Timed Light?", timedLightTooltip));
                GUILayout.FlexibleSpace();
                l.clockLight = EditorGUILayout.Toggle(l.clockLight, GUILayout.Width(12));
                GUILayout.Label(new GUIContent("Clock Light?", clockLightTooltip));
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                if (l.timedLight)
                {
                    l.clockLight = false;

                    GUILayout.BeginVertical("box");

                    GUILayout.BeginHorizontal();
                    GUILayout.Label(new GUIContent("Duration", durationTooltip));
                    l.timedDuration = EditorGUILayout.DelayedFloatField(l.timedDuration, GUILayout.Width(40));
                    GUILayout.FlexibleSpace();
                    l.invertTimed = EditorGUILayout.Toggle(l.invertTimed, GUILayout.Width(12));
                    GUILayout.Label(new GUIContent("Invert?", invertTooltip));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();
                }

                if (l.clockLight)
                {
                    l.timedLight = false;

                    GUILayout.BeginVertical("box");

                    GUILayout.BeginHorizontal();
                    GUILayout.Label(new GUIContent("On Time", onTimeTooltip));
                    l.timedOn.x = EditorGUILayout.DelayedIntField(l.timedOn.x, GUILayout.Width(24));
                    GUILayout.Label(":");
                    l.timedOn.y = EditorGUILayout.DelayedIntField(l.timedOn.y, GUILayout.Width(24));
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent("Off Time", offTimeTooltip));
                    l.timedOff.x = EditorGUILayout.DelayedIntField(l.timedOff.x, GUILayout.Width(24));
                    GUILayout.Label(":");
                    l.timedOff.y = EditorGUILayout.DelayedIntField(l.timedOff.y, GUILayout.Width(24));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();
                }

                GUILayout.EndVertical();
            }
        }
    }
        public void OnGUI(SerializedHDRenderPipelineAsset serialized, Editor owner)
        {
            CheckStyles();

            serializedObject  = serialized.serializedObject;
            serializedRPAsset = serialized;

            EditorGUILayout.Space();

#if !ENABLE_VIRTUALTEXTURES
            EditorGUI.BeginDisabledGroup(true);
#endif

            using (var scope = new EditorGUI.ChangeCheckScope())
            {
                serialized.virtualTexturingSettings.streamingCpuCacheSizeInMegaBytes.intValue = Mathf.Max(CPUCacheSizeMinValue, EditorGUILayout.DelayedIntField(s_Styles.cpuCacheSize, serialized.virtualTexturingSettings.streamingCpuCacheSizeInMegaBytes.intValue));

                // GPU Cache size settings
                if (m_GPUCacheSizeOverrideListStreaming == null ||
                    m_GPUCacheSizeOverridesPropertyStreaming != serialized.virtualTexturingSettings.streamingGpuCacheSettings)
                {
                    m_GPUCacheSizeOverridesPropertyStreaming = serialized.virtualTexturingSettings.streamingGpuCacheSettings;
                    m_GPUCacheSizeOverrideListStreaming      = CreateGPUCacheSizeOverrideList(m_GPUCacheSizeOverridesPropertyStreaming, DrawStreamingOverrideElement);
                }

                m_GPUCacheSizeOverrideListStreaming.DoLayoutList();
            }

#if !ENABLE_VIRTUALTEXTURES
            EditorGUI.EndDisabledGroup();
#endif

            serialized.serializedObject.ApplyModifiedProperties();
        }
예제 #8
0
    public override void OnInspectorGUI()
    {
        Actor myActor = target as Actor;

        //Actor name can not be empty, default to name of game object
        myActor.actorName = EditorGUILayout.TextField("Actor Name", myActor.actorName);
        if (myActor.actorName == "")
        {
            myActor.actorName = myActor.name;
        }

        EditorGUILayout.Space();

        //Max HP must be > 0
        int newHP = EditorGUILayout.DelayedIntField("Max HP", myActor.maxHitPoints);

        if (newHP > 0)
        {
            myActor.maxHitPoints = newHP;
        }

        //Initiative must be between 10 and 100 in steps of 5
        const int STEP = 5;

        myActor.initiative = STEP * (EditorGUILayout.IntSlider("Initiative", myActor.initiative, 10, 100) / STEP);

        //Immunities
        Actor.ActionSource[] sourceValues          = Enum.GetValues(typeof(Actor.ActionSource)) as Actor.ActionSource[];
        string[]             sourceNames           = Enum.GetNames(typeof(Actor.ActionSource));
        SelectionList <Actor.ActionSource> sources = new SelectionList <Actor.ActionSource>(sourceValues, sourceNames);

        isImmunitiesShowing = EditorGUILayout.Foldout(isImmunitiesShowing, "Immunities");
        if (isImmunitiesShowing)
        {
            myActor.immunities = sources.CheckboxList("Immunities", myActor.immunities, 3);
        }

        EditorGUILayout.Space();

        //Action Effect
        Actor.ActionEffect[] effectValues          = Enum.GetValues(typeof(Actor.ActionEffect)) as Actor.ActionEffect[];
        string[]             effectNames           = Enum.GetNames(typeof(Actor.ActionEffect));
        SelectionList <Actor.ActionEffect> effects = new SelectionList <Actor.ActionEffect>(effectValues, effectNames);

        myActor.actionEffect = effects.RadioList("Action Effect", myActor.actionEffect, 3);

        //Damage & Chance to hit
        if (myActor.actionEffect == Actor.ActionEffect.Normal)
        {
            myActor.damage             = EditorGUILayout.IntSlider("Damage", myActor.damage, 0, 180);
            myActor.percentChanceToHit = EditorGUILayout.IntSlider("Percent Chance to Hit", myActor.percentChanceToHit, 0, 100);
        }
        else if (myActor.actionEffect == Actor.ActionEffect.Heal)
        {
            myActor.damage             = EditorGUILayout.IntSlider("Damage", myActor.damage, 0, 180);
            myActor.percentChanceToHit = 100;
        }
        else
        {
            myActor.damage             = 0;
            myActor.percentChanceToHit = EditorGUILayout.IntSlider("Percent Chance to Hit", myActor.percentChanceToHit, 0, 100);
        }

        //Action Effect Source
        myActor.actionEffectSource = (Actor.ActionSource)EditorGUILayout.EnumPopup("Action Effect Source", myActor.actionEffectSource);

        //Action Target
        myActor.actionTarget = (Actor.ActionTarget)EditorGUILayout.EnumPopup("Action Target", myActor.actionTarget);

        //Target Select Rule
        myActor.targetSelectionRule = (Actor.TargetSelectionRule)EditorGUILayout.EnumPopup("Target Selection Rule", myActor.targetSelectionRule);

        //Current Target
        EditorGUILayout.LabelField("Current Target:", myActor.currentTarget.name);

        EditorGUILayout.Space();

        //Board Position
        Actor.Position[] positionValues          = Enum.GetValues(typeof(Actor.Position)) as Actor.Position[];
        string[]         positionNames           = Enum.GetNames(typeof(Actor.Position));
        SelectionList <Actor.Position> positions = new SelectionList <Actor.Position>(positionValues, positionNames);

        isBoardPosShowing = EditorGUILayout.Foldout(isBoardPosShowing, "Board Position");
        if (isBoardPosShowing)
        {
            myActor.boardPosition = positions.PositionGrid("Board Position", myActor.boardPosition, 3);
        }
    }
        static void Drawer_SectionReflection(SerializedHDRenderPipelineAsset serialized, Editor owner)
        {
            EditorGUILayout.PropertyField(serialized.renderPipelineSettings.supportSSR, k_SupportSSRContent);

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.reflectionCacheCompressed, k_CompressProbeCacheContent);
            EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.reflectionCubemapSize, k_CubemapSizeContent);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.DelayedIntField(serialized.renderPipelineSettings.lightLoopSettings.reflectionProbeCacheSize, k_ProbeCacheSizeContent);
            if (EditorGUI.EndChangeCheck())
            {
                serialized.renderPipelineSettings.lightLoopSettings.reflectionProbeCacheSize.intValue = Mathf.Clamp(serialized.renderPipelineSettings.lightLoopSettings.reflectionProbeCacheSize.intValue, 1, TextureCache.k_MaxSupported);
            }
            if (serialized.renderPipelineSettings.lightLoopSettings.reflectionProbeCacheSize.hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox(k_MultipleDifferenteValueMessage, MessageType.Info);
            }
            else
            {
                long currentCache = ReflectionProbeCache.GetApproxCacheSizeInByte(serialized.renderPipelineSettings.lightLoopSettings.reflectionProbeCacheSize.intValue, serialized.renderPipelineSettings.lightLoopSettings.reflectionCubemapSize.intValue, serialized.renderPipelineSettings.lightLoopSettings.supportFabricConvolution.boolValue ? 2 : 1);
                if (currentCache > LightLoop.k_MaxCacheSize)
                {
                    int    reserved = ReflectionProbeCache.GetMaxCacheSizeForWeightInByte(LightLoop.k_MaxCacheSize, serialized.renderPipelineSettings.lightLoopSettings.reflectionCubemapSize.intValue, serialized.renderPipelineSettings.lightLoopSettings.supportFabricConvolution.boolValue ? 2 : 1);
                    string message  = string.Format(k_CacheErrorFormat, HDEditorUtils.HumanizeWeight(currentCache), reserved);
                    EditorGUILayout.HelpBox(message, MessageType.Error);
                }
                else
                {
                    string message = string.Format(k_CacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache));
                    EditorGUILayout.HelpBox(message, MessageType.Info);
                }
            }

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.planarReflectionCacheCompressed, k_CompressPlanarProbeCacheContent);
            EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.planarReflectionCubemapSize, k_PlanarTextureSizeContent);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.DelayedIntField(serialized.renderPipelineSettings.lightLoopSettings.planarReflectionProbeCacheSize, k_PlanarProbeCacheSizeContent);
            if (EditorGUI.EndChangeCheck())
            {
                serialized.renderPipelineSettings.lightLoopSettings.planarReflectionProbeCacheSize.intValue = Mathf.Clamp(serialized.renderPipelineSettings.lightLoopSettings.planarReflectionProbeCacheSize.intValue, 1, TextureCache.k_MaxSupported);
            }
            if (serialized.renderPipelineSettings.lightLoopSettings.planarReflectionProbeCacheSize.hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox(k_MultipleDifferenteValueMessage, MessageType.Info);
            }
            else
            {
                long currentCache = PlanarReflectionProbeCache.GetApproxCacheSizeInByte(serialized.renderPipelineSettings.lightLoopSettings.planarReflectionProbeCacheSize.intValue, serialized.renderPipelineSettings.lightLoopSettings.planarReflectionCubemapSize.intValue, 1);
                if (currentCache > LightLoop.k_MaxCacheSize)
                {
                    int    reserved = PlanarReflectionProbeCache.GetMaxCacheSizeForWeightInByte(LightLoop.k_MaxCacheSize, serialized.renderPipelineSettings.lightLoopSettings.planarReflectionCubemapSize.intValue, 1);
                    string message  = string.Format(k_CacheErrorFormat, HDEditorUtils.HumanizeWeight(currentCache), reserved);
                    EditorGUILayout.HelpBox(message, MessageType.Error);
                }
                else
                {
                    string message = string.Format(k_CacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache));
                    EditorGUILayout.HelpBox(message, MessageType.Info);
                }
            }

            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.DelayedIntField(serialized.renderPipelineSettings.lightLoopSettings.maxEnvLightsOnScreen, k_MaxEnvContent);
            if (EditorGUI.EndChangeCheck())
            {
                serialized.renderPipelineSettings.lightLoopSettings.maxEnvLightsOnScreen.intValue = Mathf.Clamp(serialized.renderPipelineSettings.lightLoopSettings.maxEnvLightsOnScreen.intValue, 1, LightLoop.k_MaxEnvLightsOnScreen);
            }
        }
예제 #10
0
    void OnGUI()
    {
        if (EditorApplication.isPlayingOrWillChangePlaymode)
        {
            return;
        }
        if (toCreate == null)
        {
            toCreate = ScriptableObject.CreateInstance <CardScriptable>();
            return;
        }
        else
        {
            toCreate.name       = EditorGUILayout.DelayedTextField("Name:", toCreate.name);
            toCreate.flavorText = EditorGUILayout.DelayedTextField("Flavor Text:", toCreate.flavorText);
            toCreate.textBox    = EditorGUILayout.DelayedTextField("Textbox:", toCreate.textBox);
            toCreate.attack     = EditorGUILayout.DelayedIntField("Attack:", toCreate.attack);
            toCreate.countdown  = EditorGUILayout.DelayedIntField("Countdown:", toCreate.countdown);
            toCreate.cost       = EditorGUILayout.DelayedIntField("Cost:", toCreate.cost);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Type:");
            typeIndex     = EditorGUILayout.Popup(typeIndex, Enum.GetNames(typeof(CardType)));
            toCreate.type = (CardType)typeIndex;
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Sprite:");
            toCreate.picture = EditorGUILayout.ObjectField(toCreate.picture, typeof(Sprite), false) as Sprite;
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.LabelField("Effects");
            EditorGUI.indentLevel++;
            foreach (TriggeredAbility item in toCreate.abilities)
            {
                EditorGUILayout.LabelField(item.ToString());
            }
            EditorGUI.indentLevel--;

            EditorGUILayout.BeginHorizontal();
            triggerIndex = EditorGUILayout.Popup(triggerIndex, Enum.GetNames(typeof(Triggers)));
            effectIndex  = EditorGUILayout.Popup(effectIndex, Enum.GetNames(typeof(PossibleEffects)));
            if (GUILayout.Button("Add Effect"))
            {
                toCreate.abilities.Add(new TriggeredAbility((Triggers)triggerIndex, (PossibleEffects)effectIndex));
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Make the Card!") && toCreate != null)
            {
                AssetDatabase.CreateAsset(toCreate, "Assets/ScriptableAssets/Cards/" + toCreate.name + ".asset");
                toCreate = null;
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
                return;
            }

            if (GUILayout.Button("Reset!"))
            {
                toCreate = null;
            }
        }
    }
예제 #11
0
        public override void OnInspectorGUI()
        {
            mData.BuildTarget      = (BuildTarget)EditorGUILayout.EnumPopup("BuildTarget", mData.BuildTarget);
            mData.BuildTargetGroup = (BuildTargetGroup)EditorGUILayout.EnumPopup("BuildTargetGroup", mData.BuildTargetGroup);

            EditorGUILayout.PropertyField(serializedObject.FindProperty("BundleId"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("Version"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("BuildNumber"));
            SerializedProperty definesProperty = serializedObject.FindProperty("Defines");

            if (EditorGUILayout.PropertyField(definesProperty))
            {
                EditorGUI.indentLevel++;
                definesProperty.arraySize = EditorGUILayout.DelayedIntField("Size", definesProperty.arraySize);
                for (int i = 0, size = definesProperty.arraySize; i < size; i++)
                {
                    SerializedProperty element = definesProperty.GetArrayElementAtIndex(i);
                    EditorGUILayout.PropertyField(element);
                }
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.PropertyField(serializedObject.FindProperty("ICON"));
            SerializedProperty scenesProperty = serializedObject.FindProperty("Scenes");

            if (EditorGUILayout.PropertyField(scenesProperty))
            {
                EditorGUI.indentLevel++;
                scenesProperty.arraySize = EditorGUILayout.DelayedIntField("Size", scenesProperty.arraySize);
                for (int i = 0, size = scenesProperty.arraySize; i < size; i++)
                {
                    SerializedProperty element = scenesProperty.GetArrayElementAtIndex(i);
                    EditorGUILayout.PropertyField(element);
                }
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();
            if (mData.BuildTarget == BuildTarget.iOS)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("AppleDeveloperTeamID"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("TargetOSVersionString"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("CameraUsageDescription"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("LocationUsageDescription"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("MicrophoneUsageDescription"));
            }
            else if (mData.BuildTarget == BuildTarget.Android)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("WritePermissionInternal"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("KeyStorePass"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("KeyAliasPass"));
            }

            serializedObject.ApplyModifiedProperties();
            if (GUILayout.Button("Setup"))
            {
                string      filename = serializedObject.FindProperty("m_Name").stringValue;
                BuildConfig cfg      = BuildDriver.GetConfigFile(filename);
                if (cfg != null)
                {
                    if (BuildDriver.Configure(cfg))
                    {
                        Debug.Log("Build Configure Complete!");
                    }
                }
            }
        }
예제 #12
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        GUI.changed = false;

        SolarSystem solar = (SolarSystem)target;

        if (!sunMassOk)
        {
            CheckSunMass(solar);
        }

        float planetScale = 0;
        float epochTime   = solar.epochTime;
        bool  epochFoldout;

        GameObject planetPrefab   = null;
        GameObject asteroidPrefab = null;
        GameObject cometPrefab    = null;

        EditorGUIUtility.labelWidth = 200f;
        planetScale = EditorGUILayout.FloatField(new GUIContent("Planet size per 10000km"), solar.planetScale);

        EditorGUIUtility.labelWidth = 0f;         // reset

        System.DateTime datetime = SolarUtils.DateForEpoch(solar.epochTime);
        epochFoldout = EditorGUILayout.Foldout(solar.epochFoldout, "Start date: " + datetime.ToString("yyyy-MM-dd"));
        if (epochFoldout)
        {
            EditorGUILayout.LabelField("Press ENTER to update changes in start date.");
            int             year    = EditorGUILayout.DelayedIntField("YYYY", datetime.Year);
            int             month   = EditorGUILayout.DelayedIntField("MM", datetime.Month);
            int             day     = EditorGUILayout.DelayedIntField("DD", datetime.Day);
            System.DateTime newTime = new System.DateTime(year, month, day);
            Debug.LogFormat("newTime={0}", newTime.Ticks);
            if (!newTime.Equals(datetime))
            {
                epochTime = SolarUtils.DateTimeToEpoch(newTime);
            }
        }

        EditorGUILayout.LabelField("Prefabs", EditorStyles.boldLabel);
        planetPrefab = (GameObject)EditorGUILayout.ObjectField(
            new GUIContent("Planet Prefab", "Game object with NBody"), solar.planetPrefab, typeof(GameObject), true);
        asteroidPrefab = (GameObject)EditorGUILayout.ObjectField(
            new GUIContent("Asteroid Prefab", "Game object with NBody"), solar.asteroidPrefab, typeof(GameObject), true);
        cometPrefab = (GameObject)EditorGUILayout.ObjectField(
            new GUIContent("Comet Prefab", "Game object with NBody"), solar.cometPrefab, typeof(GameObject), true);

        if (GUILayout.Button("Add Body"))
        {
            SolarBodyCreatorWindow.Init();
        }

        // Apply changes to the serializedProperty
        //  - always do this in the end of OnInspectorGUI.
        // Checking the Event type lets us update after Undo and Redo commands.
        if (Event.current.type == EventType.ExecuteCommand &&
            Event.current.commandName == "UndoRedoPerformed")
        {
            // explicitly re-set so setter code will run
            solar.planetScale = planetScale;
            solar.epochTime   = epochTime;
        }

        if (GUI.changed)
        {
            Undo.RecordObject(solar, "Solar System Change");
            solar.planetScale  = planetScale;
            solar.epochFoldout = epochFoldout;
            // epochTime runs a setter that updates the objects in the scene
            solar.epochTime      = epochTime;
            solar.planetPrefab   = planetPrefab;
            solar.asteroidPrefab = asteroidPrefab;
            solar.cometPrefab    = cometPrefab;
            EditorUtility.SetDirty(solar);
        }
    }
예제 #13
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            numSockets = EditorGUILayout.DelayedIntField("# of possible values:", numSockets);
            numSockets = Mathf.Clamp(numSockets, 1, 100);

            disallowSuccessive = EditorGUILayout.Toggle("Prevent same value twice?", disallowSuccessive);

            if (disallowSuccessive)
            {
                saveToVariable = EditorGUILayout.Toggle("Save last value?", saveToVariable);
                if (saveToVariable)
                {
                    if (isAssetFile)
                    {
                        location = VariableLocation.Global;
                    }
                    else
                    {
                        location = (VariableLocation)EditorGUILayout.EnumPopup("Variable source:", location);
                    }

                    if (location == VariableLocation.Global)
                    {
                        if (AdvGame.GetReferences().variablesManager)
                        {
                            parameterID = Action.ChooseParameterGUI("Integer variable:", parameters, parameterID, ParameterType.GlobalVariable);
                            if (parameterID >= 0)
                            {
                                variableID = ShowVarGUI(AdvGame.GetReferences().variablesManager.vars, variableID, false);
                            }
                            else
                            {
                                EditorGUILayout.BeginHorizontal();
                                variableID = ShowVarGUI(AdvGame.GetReferences().variablesManager.vars, variableID, true);
                                if (GUILayout.Button(Resource.CogIcon, GUILayout.Width(20f), GUILayout.Height(15f)))
                                {
                                    SideMenu();
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                    }
                    else if (location == VariableLocation.Local)
                    {
                        if (KickStarter.localVariables)
                        {
                            parameterID = Action.ChooseParameterGUI("Integer variable:", parameters, parameterID, ParameterType.LocalVariable);
                            if (parameterID >= 0)
                            {
                                variableID = ShowVarGUI(KickStarter.localVariables.localVars, variableID, false);
                            }
                            else
                            {
                                EditorGUILayout.BeginHorizontal();
                                variableID = ShowVarGUI(KickStarter.localVariables.localVars, variableID, true);
                                if (GUILayout.Button(Resource.CogIcon, GUILayout.Width(20f), GUILayout.Height(15f)))
                                {
                                    SideMenu();
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("No 'Local Variables' component found in the scene. Please add an AC GameEngine object from the Scene Manager.", MessageType.Info);
                        }
                    }
                }
            }
        }
예제 #14
0
    override public void OnInspectorGUI()
    {
        Bezier3DSpline spline = target as Bezier3DSpline;

        ValidateSelected();

        EditorGUILayout.LabelField("Spline settings");

        EditorGUI.indentLevel = 1;

        EditorGUI.BeginChangeCheck();
        int steps = spline.cacheDensity;

        steps = EditorGUILayout.DelayedIntField("Cache density", steps);
        if (EditorGUI.EndChangeCheck())
        {
            spline.SetCacheDensity(steps);
            if (onUpdateSpline != null)
            {
                onUpdateSpline(spline);
            }
        }

        EditorGUI.BeginChangeCheck();
        bool closed = spline.closed;

        closed = EditorGUILayout.Toggle(new GUIContent("Closed", "Generate an extra curve, connecting the final point to the first point."), closed);
        if (EditorGUI.EndChangeCheck())
        {
            spline.SetClosed(closed);
            if (onUpdateSpline != null)
            {
                onUpdateSpline(spline);
            }
            SceneView.RepaintAll();
        }

        Rect position = EditorGUILayout.GetControlRect(false, 19f, EditorStyles.numberField);

        position.xMin += EditorGUIUtility.labelWidth;

        Rect flipRect = new Rect(position.x, position.y, position.width, position.height);

        if (GUI.Button(flipRect, new GUIContent("Flip", "Flip spline direction.")))
        {
            spline.Flip();
            if (onUpdateSpline != null)
            {
                onUpdateSpline(spline);
            }
            SceneView.RepaintAll();
        }

        EditorGUI.indentLevel = 0;

        EditorGUILayout.Space();
        if (activeKnot != -1)
        {
            EditorGUILayout.LabelField("Selected point");
            EditorGUI.indentLevel = 1;
            Bezier3DSpline.Knot knot = spline.GetKnot(activeKnot);

            position       = EditorGUILayout.GetControlRect(false, 19f, EditorStyles.numberField);
            position.xMin += EditorGUIUtility.labelWidth;

            EditorGUI.BeginChangeCheck();
            bool orientation     = knot.orientation != null;
            Rect orientationRect = new Rect(position.x, position.y, position.height, position.height);
            orientation = GUI.Toggle(orientationRect, orientation, new GUIContent("O", "Orientation Anchor"), "Button");
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(spline, "Toggle Bezier Orientation Anchor");
                if (orientation)
                {
                    knot.orientation = Quaternion.identity;
                }
                else
                {
                    knot.orientation = null;
                }
                spline.SetKnot(activeKnot, knot);
                if (onUpdateSpline != null)
                {
                    onUpdateSpline(spline);
                }
                SceneView.RepaintAll();
            }

            EditorGUI.BeginChangeCheck();
            bool auto     = knot.auto != 0f;
            Rect autoRect = new Rect(position.x + position.height + 4, position.y, position.height, position.height);
            auto = GUI.Toggle(autoRect, auto, new GUIContent("A", "Auto Handles"), "Button");
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(spline, "Toggle Bezier Auto Handles");
                if (auto)
                {
                    knot.auto = 0.33f;
                }
                else
                {
                    knot.auto = 0f;
                }
                spline.SetKnot(activeKnot, knot);
                if (onUpdateSpline != null)
                {
                    onUpdateSpline(spline);
                }
                SceneView.RepaintAll();
            }

            if (orientation)
            {
                EditorGUILayout.Space();
                EditorGUI.BeginChangeCheck();
                Vector3 orientationEuler = knot.orientation.Value.eulerAngles;
                orientationEuler = EditorGUILayout.Vector3Field("Orientation", orientationEuler);
                if (EditorGUI.EndChangeCheck())
                {
                    knot.orientation = Quaternion.Euler(orientationEuler);
                    spline.SetKnot(activeKnot, knot);
                    SceneView.RepaintAll();
                }
            }

            if (auto)
            {
                EditorGUILayout.Space();
                EditorGUI.BeginChangeCheck();
                knot.position = EditorGUILayout.Vector3Field("Position", knot.position);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(spline, "Edit Bezier Point");
                    spline.SetKnot(activeKnot, knot);
                    if (onUpdateSpline != null)
                    {
                        onUpdateSpline(spline);
                    }
                    SceneView.RepaintAll();
                }
                EditorGUI.BeginChangeCheck();
                knot.auto = EditorGUILayout.FloatField("Distance", knot.auto);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(spline, "Edit Bezier Point");
                    spline.SetKnot(activeKnot, knot);
                    if (onUpdateSpline != null)
                    {
                        onUpdateSpline(spline);
                    }
                    SceneView.RepaintAll();
                }
            }
            else
            {
                EditorGUILayout.Space();
                EditorGUI.BeginChangeCheck();
                knot.position = EditorGUILayout.Vector3Field("Position", knot.position);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(spline, "Edit Bezier Point");
                    spline.SetKnot(activeKnot, knot);
                    if (onUpdateSpline != null)
                    {
                        onUpdateSpline(spline);
                    }
                    SceneView.RepaintAll();
                }
                EditorGUI.BeginChangeCheck();
                knot.handleIn = EditorGUILayout.Vector3Field("Handle in", knot.handleIn);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(spline, "Edit Bezier Handle");
                    if (mirror)
                    {
                        knot.handleOut = -knot.handleIn;
                    }
                    spline.SetKnot(activeKnot, knot);
                    if (onUpdateSpline != null)
                    {
                        onUpdateSpline(spline);
                    }
                    SceneView.RepaintAll();
                }
                EditorGUI.BeginChangeCheck();
                knot.handleOut = EditorGUILayout.Vector3Field("Handle out", knot.handleOut);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(spline, "Edit Bezier Handle");
                    if (mirror)
                    {
                        knot.handleIn = -knot.handleOut;
                    }
                    spline.SetKnot(activeKnot, knot);
                    if (onUpdateSpline != null)
                    {
                        onUpdateSpline(spline);
                    }
                    SceneView.RepaintAll();
                }
            }
        }
    }
        /// <summary>
        /// Unity callback to draw this UI.
        /// </summary>
        void OnGUI()
        {
            SetupUI();

            HEU_SessionSyncData syncData = GetSessionSyncData();

            EditorGUI.BeginChangeCheck();

            bool bSessionStarted  = (syncData != null && syncData.SyncStatus != HEU_SessionSyncData.Status.Stopped);
            bool bSessionCanStart = !bSessionStarted;

            if (bSessionCanStart)
            {
                // Only able to start a session if no session exists.
                HEU_SessionBase session = HEU_SessionManager.GetDefaultSession();
                if (session != null && session.IsSessionValid())
                {
                    bSessionCanStart = false;
                }
            }

            HEU_HoudiniAssetUI.DrawHeaderSection();

            // Draw SessionSync status.
            if (syncData != null)
            {
                if (syncData.SyncStatus == HEU_SessionSyncData.Status.Stopped)
                {
                    if (!bSessionCanStart)
                    {
                        EditorGUILayout.LabelField("Another session already running. Disconnect it to start SessionSync.");
                    }
                    else
                    {
                        EditorGUILayout.LabelField("Status: " + syncData.SyncStatus);
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("Status: " + syncData.SyncStatus);
                }
            }
            else
            {
                if (!bSessionCanStart)
                {
                    EditorGUILayout.LabelField("Another session already running. Disconnect it to start SessionSync.");
                }
                else
                {
                    EditorGUILayout.LabelField("No active session.");
                }
            }

            EditorGUILayout.Separator();

            EditorGUI.indentLevel++;

            // Draw initial connection buttons (Start, Connect)
            using (new EditorGUILayout.HorizontalScope())
            {
                using (new EditorGUI.DisabledScope(bSessionStarted || !bSessionCanStart))
                {
                    if (GUILayout.Button("Start Houdini"))
                    {
                        StartAndConnectToHoudini(syncData);
                    }
                    else if (GUILayout.Button("Connect to Houdini"))
                    {
                        ConnectSessionSync(syncData);
                    }
                }
            }

            using (new EditorGUI.DisabledScope((syncData == null || !bSessionStarted) && bSessionCanStart))
            {
                if (GUILayout.Button("Disconnect"))
                {
                    Disconnect(syncData);
                }
            }

            EditorGUILayout.Separator();

            // Draw Connection Settings
            EditorGUILayout.LabelField("Connection Settings");

            using (new EditorGUI.DisabledScope(bSessionStarted))
            {
                SessionMode newSessionMode = (SessionMode)EditorGUILayout.EnumPopup("Type", _sessionMode);
                if (_sessionMode != newSessionMode)
                {
                    _sessionMode = newSessionMode;
                    HEU_PluginSettings.Session_Mode = newSessionMode;
                }

                EditorGUI.indentLevel++;
                if (_sessionMode == SessionMode.Pipe)
                {
                    string newPipeName = EditorGUILayout.DelayedTextField("Pipe Name", _pipeName);
                    if (_pipeName != newPipeName)
                    {
                        HEU_PluginSettings.Session_PipeName = newPipeName;
                        _pipeName = newPipeName;
                    }
                }
                else if (_sessionMode == SessionMode.Socket)
                {
                    int newPort = EditorGUILayout.DelayedIntField("Port", _port);
                    HEU_PluginSettings.Session_Port = newPort;
                    if (_port != newPort)
                    {
                        HEU_PluginSettings.Session_Port = newPort;
                        _port = newPort;
                    }
                }
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Separator();

            // The rest requires syncData

            // Synchronization settings, and new nodes
            if (syncData != null)
            {
                using (new EditorGUI.DisabledScope(syncData.SyncStatus != HEU_SessionSyncData.Status.Connected))
                {
                    EditorGUILayout.LabelField("Synchronization Settings");

                    EditorGUI.indentLevel++;

                    HEU_PluginSettings.SessionSyncAutoCook = HEU_EditorUI.DrawToggleLeft(HEU_PluginSettings.SessionSyncAutoCook, "Sync With Houdini Cook");

                    bool enableHoudiniTime = HEU_EditorUI.DrawToggleLeft(syncData._syncInfo.cookUsingHoudiniTime, "Cook Using Houdini Time");
                    if (syncData._syncInfo.cookUsingHoudiniTime != enableHoudiniTime)
                    {
                        syncData._syncInfo.cookUsingHoudiniTime = enableHoudiniTime;
                        UploadSessionSyncInfo(null, syncData);
                    }

                    bool enableSyncViewport = HEU_EditorUI.DrawToggleLeft(syncData._syncInfo.syncViewport, "Sync Viewport");
                    if (syncData._syncInfo.syncViewport != enableSyncViewport)
                    {
                        syncData._syncInfo.syncViewport = enableSyncViewport;
                        UploadSessionSyncInfo(null, syncData);
                    }

                    EditorGUI.indentLevel--;
                }

                EditorGUILayout.Separator();

                EditorGUILayout.LabelField("New Node");

                using (new EditorGUI.DisabledScope(syncData.SyncStatus != HEU_SessionSyncData.Status.Connected))
                {
                    EditorGUI.indentLevel++;

                    syncData._newNodeName = EditorGUILayout.TextField("Name", syncData._newNodeName);

                    syncData._nodeTypeIndex = EditorGUILayout.Popup("Type", syncData._nodeTypeIndex, _nodeTypesLabels);

                    using (new EditorGUI.DisabledGroupScope(string.IsNullOrEmpty(syncData._newNodeName)))
                    {
                        using (new EditorGUILayout.VerticalScope())
                        {
                            if (GUILayout.Button("Create"))
                            {
                                if (syncData._nodeTypeIndex >= 0 && syncData._nodeTypeIndex < 3)
                                {
                                    HEU_NodeSync.CreateNodeSync(null, _nodeTypes[syncData._nodeTypeIndex],
                                                                syncData._newNodeName);
                                }
                                else if (syncData._nodeTypeIndex == 3)
                                {
                                    CreateCurve(syncData._newNodeName);
                                }
                                else if (syncData._nodeTypeIndex == 4)
                                {
                                    CreateInput(syncData._newNodeName);
                                }
                            }

                            if (GUILayout.Button("Load NodeSync"))
                            {
                                LoadNodeSyncDialog(syncData._newNodeName);
                            }
                        }
                    }

                    EditorGUI.indentLevel--;
                }

                EditorGUILayout.Separator();

                // Log
                using (new EditorGUILayout.VerticalScope(_backgroundStyle))
                {
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        EditorGUILayout.PrefixLabel(_eventMessageContent);

                        if (GUILayout.Button("Clear"))
                        {
                            ClearLog();
                        }
                    }

                    string logMsg = GetLog();

                    using (var scrollViewScope = new EditorGUILayout.ScrollViewScope(_eventMessageScrollPos, GUILayout.Height(120)))
                    {
                        _eventMessageScrollPos = scrollViewScope.scrollPosition;

                        GUILayout.Label(logMsg, _eventMessageStyle);
                    }
                }
            }

            EditorGUI.indentLevel--;

            if (EditorGUI.EndChangeCheck() && syncData != null)
            {
                HEU_SessionBase sessionBase = HEU_SessionManager.GetDefaultSession();
                if (sessionBase != null)
                {
                    HEU_SessionManager.SaveAllSessionData();
                }
            }
        }
예제 #16
0
        /// <summary>
        /// Callback for painting the inspector GUI for the RandomBrush in the Tile Palette.
        /// The RandomBrush Editor overrides this to have a custom inspector for this Brush.
        /// </summary>
        public override void OnPaintInspectorGUI()
        {
            EditorGUI.BeginChangeCheck();
            randomBrush.pickRandomTiles = EditorGUILayout.Toggle("Pick Random Tiles", randomBrush.pickRandomTiles);
            using (new EditorGUI.DisabledScope(!randomBrush.pickRandomTiles))
            {
                randomBrush.addToRandomTiles =
                    EditorGUILayout.Toggle("Add To Random Tiles", randomBrush.addToRandomTiles);
            }

            EditorGUI.BeginChangeCheck();
            randomBrush.randomTileSetSize =
                EditorGUILayout.Vector3IntField("Tile Set Size", randomBrush.randomTileSetSize);
            if (EditorGUI.EndChangeCheck())
            {
                for (var i = 0; i < randomBrush.randomTileSets.Length; ++i)
                {
                    var sizeCount = randomBrush.randomTileSetSize.x * randomBrush.randomTileSetSize.y *
                                    randomBrush.randomTileSetSize.z;
                    randomBrush.randomTileSets[i].randomTiles = new TileBase[sizeCount];
                }
            }

            var randomTileSetCount = EditorGUILayout.DelayedIntField("Number of Tiles",
                                                                     randomBrush.randomTileSets != null ? randomBrush.randomTileSets.Length : 0);

            if (randomTileSetCount < 0)
            {
                randomTileSetCount = 0;
            }
            if (randomBrush.randomTileSets == null || randomBrush.randomTileSets.Length != randomTileSetCount)
            {
                Array.Resize(ref randomBrush.randomTileSets, randomTileSetCount);
                for (var i = 0; i < randomBrush.randomTileSets.Length; ++i)
                {
                    var sizeCount = randomBrush.randomTileSetSize.x * randomBrush.randomTileSetSize.y *
                                    randomBrush.randomTileSetSize.z;
                    if (randomBrush.randomTileSets[i].randomTiles == null ||
                        randomBrush.randomTileSets[i].randomTiles.Length != sizeCount)
                    {
                        randomBrush.randomTileSets[i].randomTiles = new TileBase[sizeCount];
                    }
                }
            }

            if (randomTileSetCount > 0)
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Place random tiles.");

                for (var i = 0; i < randomTileSetCount; i++)
                {
                    EditorGUILayout.LabelField("Tile Set " + (i + 1));
                    for (var j = 0; j < randomBrush.randomTileSets[i].randomTiles.Length; ++j)
                    {
                        randomBrush.randomTileSets[i].randomTiles[j] = (TileBase)EditorGUILayout.ObjectField(
                            "Tile " + (j + 1), randomBrush.randomTileSets[i].randomTiles[j], typeof(TileBase), false,
                            null);
                    }
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(randomBrush);
            }
        }
예제 #17
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            Editor.DrawPropertiesExcluding(serializedObject, new string[] { "hide", "loadBlendShapes", "activeRace", "defaultChangeRaceOptions", "cacheCurrentState", "rebuildSkeleton", "preloadWardrobeRecipes", "raceAnimationControllers",
                                                                            "characterColors", "BoundsOffset", "_buildCharacterEnabled",
                                                                            /*LoadOtions fields*/ "defaultLoadOptions", "loadPathType", "loadPath", "loadFilename", "loadString", "loadFileOnStart", "waitForBundles", /*"buildAfterLoad",*/
                                                                            /*SaveOptions fields*/ "defaultSaveOptions", "savePathType", "savePath", "saveFilename", "makeUniqueFilename", "ensureSharedColors",
                                                                            /*Moved into AdvancedOptions*/ "context", "umaData", "umaRecipe", "umaAdditionalRecipes", "umaGenerator", "animationController",
                                                                            /*Moved into CharacterEvents*/ "CharacterCreated", "CharacterBegun", "CharacterUpdated", "CharacterDestroyed", "CharacterDnaUpdated", "RecipeUpdated",
                                                                            /*PlaceholderOptions fields*/ "showPlaceholder", "previewModel", "customModel", "customRotation", "previewColor" });

            //The base DynamicAvatar properties- get these early because changing the race changes someof them
            SerializedProperty context              = serializedObject.FindProperty("context");
            SerializedProperty umaData              = serializedObject.FindProperty("umaData");
            SerializedProperty umaGenerator         = serializedObject.FindProperty("umaGenerator");
            SerializedProperty umaRecipe            = serializedObject.FindProperty("umaRecipe");
            SerializedProperty umaAdditionalRecipes = serializedObject.FindProperty("umaAdditionalRecipes");
            SerializedProperty animationController  = serializedObject.FindProperty("animationController");

            EditorGUI.BeginChangeCheck();
            showHelp = EditorGUILayout.Toggle("Show Help", showHelp);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
            SerializedProperty thisRaceSetter = serializedObject.FindProperty("activeRace");
            Rect currentRect = EditorGUILayout.GetControlRect(false, _racePropDrawer.GetPropertyHeight(thisRaceSetter, GUIContent.none));

            EditorGUI.BeginChangeCheck();
            _racePropDrawer.OnGUI(currentRect, thisRaceSetter, new GUIContent(thisRaceSetter.displayName));
            if (EditorGUI.EndChangeCheck())
            {
                thisDCA.ChangeRace((string)thisRaceSetter.FindPropertyRelative("name").stringValue);
                //Changing the race may cause umaRecipe, animationController to change so forcefully update these too
                umaRecipe.objectReferenceValue           = thisDCA.umaRecipe;
                animationController.objectReferenceValue = thisDCA.animationController;
                serializedObject.ApplyModifiedProperties();
            }
            if (showHelp)
            {
                EditorGUILayout.HelpBox("Active Race: Sets the race of the character, which defines the base recipe to build the character, the available DNA, and the available wardrobe.", MessageType.Info);
            }
            //the ChangeRaceOptions
            SerializedProperty defaultChangeRaceOptions = serializedObject.FindProperty("defaultChangeRaceOptions");

            EditorGUI.indentLevel++;
            defaultChangeRaceOptions.isExpanded = EditorGUILayout.Foldout(defaultChangeRaceOptions.isExpanded, new GUIContent("Race Change Options", "The default options for when the Race is changed. These can be overidden when calling 'ChangeRace' directly."));
            if (defaultChangeRaceOptions.isExpanded)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(defaultChangeRaceOptions, GUIContent.none);
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(serializedObject.FindProperty("cacheCurrentState"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("rebuildSkeleton"));
                EditorGUI.indentLevel--;
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
            }
            EditorGUI.indentLevel--;
            //Other DCA propertyDrawers
            //in order for the "preloadWardrobeRecipes" prop to properly check if it can load the recipies it gets assigned to it
            //it needs to know that its part of this DCA
            GUILayout.Space(2f);
            SerializedProperty thisPreloadWardrobeRecipes = serializedObject.FindProperty("preloadWardrobeRecipes");
            Rect pwrCurrentRect = EditorGUILayout.GetControlRect(false, _wardrobePropDrawer.GetPropertyHeight(thisPreloadWardrobeRecipes, GUIContent.none));

            _wardrobePropDrawer.OnGUI(pwrCurrentRect, thisPreloadWardrobeRecipes, new GUIContent(thisPreloadWardrobeRecipes.displayName));
            if (showHelp)
            {
                EditorGUILayout.HelpBox("Preload Wardrobe: Sets the default wardrobe recipes to use on the Avatar. This is useful when creating specific Avatar prefabs.", MessageType.Info);
            }
            if (_wardrobePropDrawer.changed)
            {
                serializedObject.ApplyModifiedProperties();
                if (Application.isPlaying)
                {
                    thisDCA.ClearSlots();
                    thisDCA.LoadDefaultWardrobe();
                    thisDCA.BuildCharacter(true);
                }
            }

            //Move UMAAddidtionalRecipes out of advanced into its own section
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(umaAdditionalRecipes, new GUIContent("Additional Utility Recipes", "Additional Recipes to add when the character is generated, like the capsuleCollider recipe for example"), true);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
            GUILayout.Space(2f);

            SerializedProperty thisRaceAnimationControllers = serializedObject.FindProperty("raceAnimationControllers");
            Rect racCurrentRect = EditorGUILayout.GetControlRect(false, _animatorPropDrawer.GetPropertyHeight(thisRaceAnimationControllers, GUIContent.none));

            EditorGUI.BeginChangeCheck();
            _animatorPropDrawer.OnGUI(racCurrentRect, thisRaceAnimationControllers, new GUIContent(thisRaceAnimationControllers.displayName));
            if (showHelp)
            {
                EditorGUILayout.HelpBox("Race Animation Controllers: This sets the animation controllers used for each race. When changing the race, the animation controller for the active race will be used by default.", MessageType.Info);
            }
            //EditorGUI.BeginChangeCheck();
            //EditorGUILayout.PropertyField(serializedObject.FindProperty("raceAnimationControllers"));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                if (Application.isPlaying)
                {
                    thisDCA.SetExpressionSet();                    //this triggers any expressions to reset.
                    thisDCA.SetAnimatorController();
                }
            }
            //NewCharacterColors
            SerializedProperty characterColors    = serializedObject.FindProperty("characterColors");
            SerializedProperty newCharacterColors = characterColors.FindPropertyRelative("_colors");

            //for ColorValues as OverlayColorDatas we need to outout something that looks like a list but actully uses a method to add/remove colors because we need the new OverlayColorData to have 3 channels
            newCharacterColors.isExpanded = EditorGUILayout.Foldout(newCharacterColors.isExpanded, new GUIContent("Character Colors"));
            var n_origArraySize = newCharacterColors.arraySize;
            var n_newArraySize  = n_origArraySize;

            EditorGUI.BeginChangeCheck();
            if (newCharacterColors.isExpanded)
            {
                n_newArraySize = EditorGUILayout.DelayedIntField(new GUIContent("Size"), n_origArraySize);
                EditorGUILayout.Space();
                EditorGUI.indentLevel++;
                if (n_origArraySize > 0)
                {
                    for (int i = 0; i < n_origArraySize; i++)
                    {
                        EditorGUILayout.PropertyField(newCharacterColors.GetArrayElementAtIndex(i));
                    }
                }
                EditorGUI.indentLevel--;
            }
            if (showHelp)
            {
                EditorGUILayout.HelpBox("Character Colors: This lets you set predefined colors to be used when building the Avatar. The colors will be assigned to the Shared Colors on the overlays as they are applied to the Avatar.", MessageType.Info);
            }
            if (EditorGUI.EndChangeCheck())
            {
                if (n_newArraySize != n_origArraySize)
                {
                    SetNewColorCount(n_newArraySize);                    //this is not prompting a save so mark the scene dirty...
                    if (!Application.isPlaying)
                    {
                        EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                    }
                }
                serializedObject.ApplyModifiedProperties();
                if (Application.isPlaying)
                {
                    thisDCA.UpdateColors(true);
                }
            }
            GUILayout.Space(2f);
            //Load save fields
            EditorGUI.BeginChangeCheck();
            SerializedProperty loadPathType = serializedObject.FindProperty("loadPathType");

            loadPathType.isExpanded = EditorGUILayout.Foldout(loadPathType.isExpanded, "Load/Save Options");
            if (loadPathType.isExpanded)
            {
                SerializedProperty loadString      = serializedObject.FindProperty("loadString");
                SerializedProperty loadPath        = serializedObject.FindProperty("loadPath");
                SerializedProperty loadFilename    = serializedObject.FindProperty("loadFilename");
                SerializedProperty loadFileOnStart = serializedObject.FindProperty("loadFileOnStart");
                SerializedProperty savePathType    = serializedObject.FindProperty("savePathType");
                SerializedProperty savePath        = serializedObject.FindProperty("savePath");
                SerializedProperty saveFilename    = serializedObject.FindProperty("saveFilename");
                //LoadSave Flags
                SerializedProperty defaultLoadOptions = serializedObject.FindProperty("defaultLoadOptions");
                SerializedProperty defaultSaveOptions = serializedObject.FindProperty("defaultSaveOptions");
                //extra LoadSave Options in addition to flags
                SerializedProperty waitForBundles     = serializedObject.FindProperty("waitForBundles");
                SerializedProperty makeUniqueFilename = serializedObject.FindProperty("makeUniqueFilename");
                SerializedProperty ensureSharedColors = serializedObject.FindProperty("ensureSharedColors");

                EditorGUILayout.PropertyField(loadPathType);

                if (loadPathType.enumValueIndex == Convert.ToInt32(DynamicCharacterAvatar.loadPathTypes.String))
                {
                    EditorGUILayout.PropertyField(loadString);
                }
                else
                {
                    if (loadPathType.enumValueIndex <= 1)
                    {
                        EditorGUILayout.PropertyField(loadPath);
                    }
                }

                EditorGUILayout.PropertyField(loadFilename);
                if (loadFilename.stringValue != "")
                {
                    EditorGUILayout.PropertyField(loadFileOnStart);
                }
                EditorGUI.indentLevel++;
                //LoadOptionsFlags
                defaultLoadOptions.isExpanded = EditorGUILayout.Foldout(defaultLoadOptions.isExpanded, new GUIContent("Load Options", "The default options for when a character is loaded from an UMATextRecipe asset or a recipe string. Can be overidden when calling 'LoadFromRecipe' or 'LoadFromString' directly."));
                if (defaultLoadOptions.isExpanded)
                {
                    EditorGUILayout.PropertyField(defaultLoadOptions, GUIContent.none);
                    EditorGUI.indentLevel++;
                    //waitForBundles.boolValue = EditorGUILayout.ToggleLeft(new GUIContent(waitForBundles.displayName, waitForBundles.tooltip), waitForBundles.boolValue);
                    //buildAfterLoad.boolValue = EditorGUILayout.ToggleLeft(new GUIContent(buildAfterLoad.displayName, buildAfterLoad.tooltip), buildAfterLoad.boolValue);
                    //just drawing these as propertyFields because the toolTip on toggle left doesn't work
                    EditorGUILayout.PropertyField(waitForBundles);
                    EditorGUI.indentLevel--;
                }
                EditorGUI.indentLevel--;
                if (Application.isPlaying)
                {
                    if (GUILayout.Button("Perform Load"))
                    {
                        thisDCA.DoLoad();
                    }
                }
                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(savePathType);
                if (savePathType.enumValueIndex <= 2)
                {
                    EditorGUILayout.PropertyField(savePath);
                }
                EditorGUILayout.PropertyField(saveFilename);
                EditorGUI.indentLevel++;
                defaultSaveOptions.isExpanded = EditorGUILayout.Foldout(defaultSaveOptions.isExpanded, new GUIContent("Save Options", "The default options for when a character is save to UMATextRecipe asset or a txt. Can be overidden when calling 'DoSave' directly."));
                if (defaultSaveOptions.isExpanded)
                {
                    EditorGUILayout.PropertyField(defaultSaveOptions, GUIContent.none);
                    EditorGUI.indentLevel++;
                    //ensureSharedColors.boolValue = EditorGUILayout.ToggleLeft(new GUIContent(ensureSharedColors.displayName, ensureSharedColors.tooltip), ensureSharedColors.boolValue);
                    //makeUniqueFilename.boolValue = EditorGUILayout.ToggleLeft(new GUIContent(makeUniqueFilename.displayName, makeUniqueFilename.tooltip), makeUniqueFilename.boolValue);
                    //just drawing these as propertyFields because the toolTip on toggle left doesn't work
                    EditorGUILayout.PropertyField(ensureSharedColors);
                    EditorGUILayout.PropertyField(makeUniqueFilename);
                    EditorGUI.indentLevel--;
                }
                EditorGUI.indentLevel--;
                if (Application.isPlaying)
                {
                    if (GUILayout.Button("Perform Save"))
                    {
                        thisDCA.DoSave();
                    }
                }
                EditorGUILayout.Space();
            }
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
            GUILayout.Space(2f);
            //for CharacterEvents
            EditorGUI.BeginChangeCheck();
            SerializedProperty CharacterCreated = serializedObject.FindProperty("CharacterCreated");

            CharacterCreated.isExpanded = EditorGUILayout.Foldout(CharacterCreated.isExpanded, "Character Events");
            if (CharacterCreated.isExpanded)
            {
                SerializedProperty CharacterBegun      = serializedObject.FindProperty("CharacterBegun");
                SerializedProperty CharacterUpdated    = serializedObject.FindProperty("CharacterUpdated");
                SerializedProperty CharacterDestroyed  = serializedObject.FindProperty("CharacterDestroyed");
                SerializedProperty CharacterDnaUpdated = serializedObject.FindProperty("CharacterDnaUpdated");
                SerializedProperty RecipeUpdated       = serializedObject.FindProperty("RecipeUpdated");

                EditorGUILayout.PropertyField(CharacterBegun);
                EditorGUILayout.PropertyField(CharacterCreated);
                EditorGUILayout.PropertyField(CharacterUpdated);
                EditorGUILayout.PropertyField(CharacterDestroyed);
                EditorGUILayout.PropertyField(CharacterDnaUpdated);
                EditorGUILayout.PropertyField(RecipeUpdated);
            }
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
            GUILayout.Space(2f);
            //for AdvancedOptions
            EditorGUI.BeginChangeCheck();
            context.isExpanded = EditorGUILayout.Foldout(context.isExpanded, "Advanced Options");
            if (context.isExpanded)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(serializedObject.FindProperty("hide"));
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
                if (showHelp)
                {
                    EditorGUILayout.HelpBox("Hide: This disables the display of the Avatar without preventing it from being generated. If you want to prevent the character from being generated at all disable the DynamicCharacterAvatar component itself.", MessageType.Info);
                }
                //for _buildCharacterEnabled we want to set the value using the DCS BuildCharacterEnabled property because this actually triggers BuildCharacter
                var buildCharacterEnabled      = serializedObject.FindProperty("_buildCharacterEnabled");
                var buildCharacterEnabledValue = buildCharacterEnabled.boolValue;
                EditorGUI.BeginChangeCheck();
                var buildCharacterEnabledNewValue = EditorGUILayout.Toggle(new GUIContent(buildCharacterEnabled.displayName, "Builds the character on recipe load or race changed. If you want to load multiple recipes into a character you can disable this and enable it when you are done. By default this should be true."), buildCharacterEnabledValue);
                if (EditorGUI.EndChangeCheck())
                {
                    if (buildCharacterEnabledNewValue != buildCharacterEnabledValue)
                    {
                        thisDCA.BuildCharacterEnabled = buildCharacterEnabledNewValue;
                    }
                    serializedObject.ApplyModifiedProperties();
                }
                if (showHelp)
                {
                    EditorGUILayout.HelpBox("Build Character Enabled: Builds the character on recipe load or race changed. If you want to load multiple recipes into a character you can disable this and enable it when you are done. By default this should be true.", MessageType.Info);
                }
                EditorGUILayout.PropertyField(serializedObject.FindProperty("loadBlendShapes"), new GUIContent("Load BlendShapes (experimental)"));
                EditorGUILayout.PropertyField(context);
                EditorGUILayout.PropertyField(umaData);
                EditorGUILayout.PropertyField(umaGenerator);
                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(umaRecipe);
                EditorGUILayout.PropertyField(animationController);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("BoundsOffset"));
            }
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
            GUILayout.Space(2f);
            //for PlaceholderOptions
            EditorGUI.BeginChangeCheck();
            SerializedProperty gizmo          = serializedObject.FindProperty("showPlaceholder");
            SerializedProperty enableGizmo    = serializedObject.FindProperty("showPlaceholder");
            SerializedProperty previewModel   = serializedObject.FindProperty("previewModel");
            SerializedProperty customModel    = serializedObject.FindProperty("customModel");
            SerializedProperty customRotation = serializedObject.FindProperty("customRotation");
            SerializedProperty previewColor   = serializedObject.FindProperty("previewColor");

            gizmo.isExpanded = EditorGUILayout.Foldout(gizmo.isExpanded, "Placeholder Options");
            if (gizmo.isExpanded)
            {
                EditorGUILayout.PropertyField(enableGizmo);
                EditorGUILayout.PropertyField(previewModel);
                if (previewModel.enumValueIndex == 2)
                {
                    EditorGUILayout.PropertyField(customModel);
                    EditorGUILayout.PropertyField(customRotation);
                }
                EditorGUILayout.PropertyField(previewColor);
            }
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            if (Application.isPlaying)
            {
                EditorGUILayout.LabelField("AssetBundles used by Avatar");
                string assetBundlesUsed = "";
                if (thisDCA.assetBundlesUsedbyCharacter.Count == 0)
                {
                    assetBundlesUsed = "None";
                }
                else
                {
                    for (int i = 0; i < thisDCA.assetBundlesUsedbyCharacter.Count; i++)
                    {
                        assetBundlesUsed = assetBundlesUsed + thisDCA.assetBundlesUsedbyCharacter[i];
                        if (i < (thisDCA.assetBundlesUsedbyCharacter.Count - 1))
                        {
                            assetBundlesUsed = assetBundlesUsed + "\n";
                        }
                    }
                }
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.TextArea(assetBundlesUsed);
                EditorGUI.EndDisabledGroup();
            }
        }
 public static void EditorDrawIntProperty(SerializedProperty property)
 {
     property.intValue = EditorGUILayout.DelayedIntField(property.intValue);
 }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            serializedObject.Update();

            ResourceComponent t = (ResourceComponent)target;

            bool isEditorResourceMode = (bool)m_EditorResourceModeFieldInfo.GetValue(target);

            if (isEditorResourceMode)
            {
                EditorGUILayout.HelpBox("Editor resource mode is enabled. Some options are disabled.", MessageType.Warning);
            }

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            {
                if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
                {
                    EditorGUILayout.EnumPopup("Resource Mode", t.ResourceMode);
                }
                else
                {
                    int selectedIndex = EditorGUILayout.Popup("Resource Mode", m_ResourceModeIndex, ResourceModeNames);
                    if (selectedIndex != m_ResourceModeIndex)
                    {
                        m_ResourceModeIndex           = selectedIndex;
                        m_ResourceMode.enumValueIndex = selectedIndex + 1;
                    }
                }

                m_ReadWritePathType.enumValueIndex = (int)(ReadWritePathType)EditorGUILayout.EnumPopup("Read Write Path Type", t.ReadWritePathType);
            }
            EditorGUI.EndDisabledGroup();

            float unloadUnusedAssetsInterval = EditorGUILayout.Slider("Unload Unused Assets Interval", m_UnloadUnusedAssetsInterval.floatValue, 0f, 3600f);

            if (unloadUnusedAssetsInterval != m_UnloadUnusedAssetsInterval.floatValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.UnloadUnusedAssetsInterval = unloadUnusedAssetsInterval;
                }
                else
                {
                    m_UnloadUnusedAssetsInterval.floatValue = unloadUnusedAssetsInterval;
                }
            }
            EditorGUI.BeginDisabledGroup(EditorApplication.isPlaying && isEditorResourceMode);
            {
                float assetAutoReleaseInterval = EditorGUILayout.DelayedFloatField("Asset Auto Release Interval", m_AssetAutoReleaseInterval.floatValue);
                if (assetAutoReleaseInterval != m_AssetAutoReleaseInterval.floatValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.AssetAutoReleaseInterval = assetAutoReleaseInterval;
                    }
                    else
                    {
                        m_AssetAutoReleaseInterval.floatValue = assetAutoReleaseInterval;
                    }
                }

                int assetCapacity = EditorGUILayout.DelayedIntField("Asset Capacity", m_AssetCapacity.intValue);
                if (assetCapacity != m_AssetCapacity.intValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.AssetCapacity = assetCapacity;
                    }
                    else
                    {
                        m_AssetCapacity.intValue = assetCapacity;
                    }
                }

                float assetExpireTime = EditorGUILayout.DelayedFloatField("Asset Expire Time", m_AssetExpireTime.floatValue);
                if (assetExpireTime != m_AssetExpireTime.floatValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.AssetExpireTime = assetExpireTime;
                    }
                    else
                    {
                        m_AssetExpireTime.floatValue = assetExpireTime;
                    }
                }

                int assetPriority = EditorGUILayout.DelayedIntField("Asset Priority", m_AssetPriority.intValue);
                if (assetPriority != m_AssetPriority.intValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.AssetPriority = assetPriority;
                    }
                    else
                    {
                        m_AssetPriority.intValue = assetPriority;
                    }
                }

                float resourceAutoReleaseInterval = EditorGUILayout.DelayedFloatField("Resource Auto Release Interval", m_ResourceAutoReleaseInterval.floatValue);
                if (resourceAutoReleaseInterval != m_ResourceAutoReleaseInterval.floatValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.ResourceAutoReleaseInterval = resourceAutoReleaseInterval;
                    }
                    else
                    {
                        m_ResourceAutoReleaseInterval.floatValue = resourceAutoReleaseInterval;
                    }
                }

                int resourceCapacity = EditorGUILayout.DelayedIntField("Resource Capacity", m_ResourceCapacity.intValue);
                if (resourceCapacity != m_ResourceCapacity.intValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.ResourceCapacity = resourceCapacity;
                    }
                    else
                    {
                        m_ResourceCapacity.intValue = resourceCapacity;
                    }
                }

                float resourceExpireTime = EditorGUILayout.DelayedFloatField("Resource Expire Time", m_ResourceExpireTime.floatValue);
                if (resourceExpireTime != m_ResourceExpireTime.floatValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.ResourceExpireTime = resourceExpireTime;
                    }
                    else
                    {
                        m_ResourceExpireTime.floatValue = resourceExpireTime;
                    }
                }

                int resourcePriority = EditorGUILayout.DelayedIntField("Resource Priority", m_ResourcePriority.intValue);
                if (resourcePriority != m_ResourcePriority.intValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.ResourcePriority = resourcePriority;
                    }
                    else
                    {
                        m_ResourcePriority.intValue = resourcePriority;
                    }
                }

                if (m_ResourceModeIndex == 1)
                {
                    string updatePrefixUri = EditorGUILayout.DelayedTextField("Update Prefix Uri", m_UpdatePrefixUri.stringValue);
                    if (updatePrefixUri != m_UpdatePrefixUri.stringValue)
                    {
                        if (EditorApplication.isPlaying)
                        {
                            t.UpdatePrefixUri = updatePrefixUri;
                        }
                        else
                        {
                            m_UpdatePrefixUri.stringValue = updatePrefixUri;
                        }
                    }

                    int updateFileCacheLength = EditorGUILayout.DelayedIntField("Update File Cache Length", m_UpdateFileCacheLength.intValue);
                    if (updateFileCacheLength != m_UpdateFileCacheLength.intValue)
                    {
                        if (EditorApplication.isPlaying)
                        {
                            t.UpdateFileCacheLength = updateFileCacheLength;
                        }
                        else
                        {
                            m_UpdateFileCacheLength.intValue = updateFileCacheLength;
                        }
                    }

                    int generateReadWriteListLength = EditorGUILayout.DelayedIntField("Generate Read Write List Length", m_GenerateReadWriteListLength.intValue);
                    if (generateReadWriteListLength != m_GenerateReadWriteListLength.intValue)
                    {
                        if (EditorApplication.isPlaying)
                        {
                            t.GenerateReadWriteListLength = generateReadWriteListLength;
                        }
                        else
                        {
                            m_GenerateReadWriteListLength.intValue = generateReadWriteListLength;
                        }
                    }

                    int updateRetryCount = EditorGUILayout.DelayedIntField("Update Retry Count", m_UpdateRetryCount.intValue);
                    if (updateRetryCount != m_UpdateRetryCount.intValue)
                    {
                        if (EditorApplication.isPlaying)
                        {
                            t.UpdateRetryCount = updateRetryCount;
                        }
                        else
                        {
                            m_UpdateRetryCount.intValue = updateRetryCount;
                        }
                    }
                }
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            {
                EditorGUILayout.PropertyField(m_InstanceRoot);

                m_ResourceHelperInfo.Draw();
                m_LoadResourceAgentHelperInfo.Draw();
                m_LoadResourceAgentHelperCount.intValue = EditorGUILayout.IntSlider("Load Resource Agent Helper Count", m_LoadResourceAgentHelperCount.intValue, 1, 64);
            }
            EditorGUI.EndDisabledGroup();

            if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
            {
                EditorGUILayout.LabelField("Read Only Path", t.ReadOnlyPath.ToString());
                EditorGUILayout.LabelField("Read Write Path", t.ReadWritePath.ToString());
                EditorGUILayout.LabelField("Current Variant", t.CurrentVariant ?? "<Unknwon>");
                EditorGUILayout.LabelField("Applicable Game Version", isEditorResourceMode ? "N/A" : t.ApplicableGameVersion ?? "<Unknwon>");
                EditorGUILayout.LabelField("Internal Resource Version", isEditorResourceMode ? "N/A" : t.InternalResourceVersion.ToString());
                EditorGUILayout.LabelField("Asset Count", isEditorResourceMode ? "N/A" : t.AssetCount.ToString());
                EditorGUILayout.LabelField("Resource Count", isEditorResourceMode ? "N/A" : t.ResourceCount.ToString());
                if (m_ResourceModeIndex == 1)
                {
                    EditorGUILayout.LabelField("Update Waiting Count", isEditorResourceMode ? "N/A" : t.UpdateWaitingCount.ToString());
                    EditorGUILayout.LabelField("Updating Count", isEditorResourceMode ? "N/A" : t.UpdatingCount.ToString());
                }
                EditorGUILayout.LabelField("Load Total Agent Count", isEditorResourceMode ? "N/A" : t.LoadTotalAgentCount.ToString());
                EditorGUILayout.LabelField("Load Free Agent Count", isEditorResourceMode ? "N/A" : t.LoadFreeAgentCount.ToString());
                EditorGUILayout.LabelField("Load Working Agent Count", isEditorResourceMode ? "N/A" : t.LoadWorkingAgentCount.ToString());
                EditorGUILayout.LabelField("Load Waiting Task Count", isEditorResourceMode ? "N/A" : t.LoadWaitingTaskCount.ToString());
            }

            serializedObject.ApplyModifiedProperties();

            Repaint();
        }
예제 #20
0
    public override void OnInspectorGUI()
    {
        InspectorLever b = (InspectorLever)target;

        if (b.commonTargets == null)
        {
            b.commonTargets = new List <GameObject>();
        }

        if (b.pastTargets == null)
        {
            b.pastTargets = new List <GameObject>();
        }

        if (b.presentTargets == null)
        {
            b.presentTargets = new List <GameObject>();
        }


        b.areTargetsCommon    = EditorGUILayout.Toggle("Uses common targets: ", b.areTargetsCommon);
        b.leverChangeVelocity = EditorGUILayout.FloatField("Lever velocity", b.leverChangeVelocity);
        EditorGUILayout.Separator();

        if (b.areTargetsCommon)
        {
            int count = Mathf.Max(0, EditorGUILayout.DelayedIntField("Common Targets", b.commonTargets.Count));
            //EditorGUILayout.TextArea("Nejaky to text: " + count);

            while (count < b.commonTargets.Count)
            {
                b.commonTargets.RemoveAt(b.commonTargets.Count - 1);
            }
            while (count > b.commonTargets.Count)
            {
                b.commonTargets.Add(null);
            }

            for (int i = 0; i < b.commonTargets.Count; i++)
            {
#pragma warning disable CS0618 // Type or member is obsolete
                b.commonTargets[i] = (GameObject)EditorGUILayout.ObjectField("Target " + i, b.commonTargets[i], typeof(GameObject));
#pragma warning restore CS0618 // Type or member is obsolete
            }

            EditorGUILayout.Separator();
            b.presentMaterial = (Material)EditorGUILayout.ObjectField("Present Material", b.presentMaterial, typeof(Material));
            b.isPresentActive = EditorGUILayout.Toggle("Is Present Active", b.isPresentActive);


            EditorGUILayout.Separator();
            b.pastMaterial = (Material)EditorGUILayout.ObjectField("Past Material", b.pastMaterial, typeof(Material));
            b.isPastActive = EditorGUILayout.Toggle("Is Past Active", b.isPastActive);
        }
        else
        {
            b.presentMaterial = (Material)EditorGUILayout.ObjectField("Present Material", b.presentMaterial, typeof(Material));
            b.isPresentActive = EditorGUILayout.Toggle("Is Present Active", b.isPresentActive);

            int count = Mathf.Max(0, EditorGUILayout.DelayedIntField("Present Targets", b.presentTargets.Count));
            while (count < b.presentTargets.Count)
            {
                b.presentTargets.RemoveAt(b.presentTargets.Count - 1);
            }
            while (count > b.presentTargets.Count)
            {
                b.presentTargets.Add(null);
            }

            for (int i = 0; i < b.presentTargets.Count; i++)
            {
#pragma warning disable CS0618 // Type or member is obsolete
                b.presentTargets[i] = (GameObject)EditorGUILayout.ObjectField("Target " + i, b.presentTargets[i], typeof(GameObject));
#pragma warning restore CS0618 // Type or member is obsolete
            }

            EditorGUILayout.Space();

            b.pastMaterial = (Material)EditorGUILayout.ObjectField("Past Material", b.pastMaterial, typeof(Material));
            b.isPastActive = EditorGUILayout.Toggle("Is Past Active", b.isPastActive);

            int countPast = Mathf.Max(0, EditorGUILayout.DelayedIntField("Past Targets", b.pastTargets.Count));
            while (countPast < b.pastTargets.Count)
            {
                b.pastTargets.RemoveAt(b.pastTargets.Count - 1);
            }
            while (countPast > b.pastTargets.Count)
            {
                b.pastTargets.Add(null);
            }

            for (int i = 0; i < b.pastTargets.Count; i++)
            {
#pragma warning disable CS0618 // Type or member is obsolete
                b.pastTargets[i] = (GameObject)EditorGUILayout.ObjectField("Target " + i, b.pastTargets[i], typeof(GameObject));
#pragma warning restore CS0618 // Type or member is obsolete
            }
        }
    }
예제 #21
0
        private void _memberInfoDraw(MemberInfo[] fields, BuffInfo buff,
                                     Func <MemberInfo, IBuffDataComponent, object> getValue,
                                     Func <MemberInfo, bool> isSet,
                                     Action <MemberInfo, IBuffDataComponent, object> setValue)
        {
            foreach (var info in fields)
            {
                var infoValue = getValue(info, buff.Buff);

                GUIContent title = new GUIContent($"{info.Name}");

                if (!isSet(info))
                {
                    EditorGUILayout.LabelField($"{info.Name}:{infoValue}");
                    continue;
                }

                GUI.changed = false;

                switch (infoValue)
                {
                case string value:

                    value = EditorGUILayout.DelayedTextField(title, value);

                    if (GUI.changed)
                    {
                        setValue(info, buff.Buff, value);
                        _entityBuff.EntityManager.BuffManager.SetBuffData(_entityBuff.IcSkSEntity, buff.Buff, buff.Index);
                        GUI.changed = false;
                    }

                    continue;

                case int value:
                    value = EditorGUILayout.DelayedIntField(title, value);
                    if (GUI.changed)
                    {
                        setValue(info, buff.Buff, value);
                        _entityBuff.EntityManager.BuffManager.SetBuffData(_entityBuff.IcSkSEntity, buff.Buff, buff.Index);
                        GUI.changed = false;
                    }

                    continue;

                case float value:
                    value = EditorGUILayout.DelayedFloatField(title, value);
                    if (GUI.changed)
                    {
                        setValue(info, buff.Buff, value);
                        _entityBuff.EntityManager.BuffManager.SetBuffData(_entityBuff.IcSkSEntity, buff.Buff, buff.Index);
                        GUI.changed = false;
                    }

                    continue;

                case bool value:
                    value = EditorGUILayout.Toggle(title, value);
                    if (GUI.changed)
                    {
                        setValue(info, buff.Buff, value);
                        _entityBuff.EntityManager.BuffManager.SetBuffData(_entityBuff.IcSkSEntity, buff.Buff, buff.Index);
                        GUI.changed = false;
                    }

                    continue;

                case Enum value:
                    value = EditorGUILayout.EnumPopup(title, value);
                    if (GUI.changed)
                    {
                        setValue(info, buff.Buff, value);
                        _entityBuff.EntityManager.BuffManager.SetBuffData(_entityBuff.IcSkSEntity, buff.Buff, buff.Index);
                        GUI.changed = false;
                    }

                    continue;
                }
            }
        }
예제 #22
0
    private void LayoutItem(SelectedItem item)
    {
        EditorGUIUtility.labelWidth = 60.0f;

        if (GUILayout.Button("X", GUILayout.Width(20)))
        {
            var component = item.Object.GetComponent <MidiController>();
            component.Inputs = component.Inputs.FindAll(i => i != item.Item);
            if (component.Inputs.Count < 1)
            {
                DestroyImmediate(component);
            }
        }

        var selectedGameObj = (GameObject)EditorGUILayout.ObjectField(item.Object, typeof(GameObject), true, GUILayout.Width(_width));

        if (selectedGameObj != null && selectedGameObj != item.Object)
        {
            /* Modifying an object is slightly complicated
             * 1. Add MidiController to the new obj if it doesn't have it
             * 2. Add a new SelectedItem to that MidiController
             * 3. Remove the old SelectedItem from the old MidiController
             * 4. Remove the MidiController component from the old object if SelectedItems are empty
             */

            var oldObject = item.Object;
            if (oldObject == null)
            {
                if (NewMappings.ContainsValue(item))
                {
                    NewMappings.Remove(item.Item.Input.Name);
                }
            }
            else
            {
                var oldComponent = oldObject.GetComponent <MidiController>();
                oldComponent.Inputs = oldComponent.Inputs.FindAll(i => i != item.Item);
                if (oldComponent.Inputs.Count < 1)
                {
                    DestroyImmediate(oldComponent);
                }
            }

            item.Object = selectedGameObj;

            var newComponent = item.Object.GetComponent <MidiController>();
            if (!newComponent)
            {
                newComponent = item.Object.AddComponent <MidiController>();
            }

            // TODO: Properly set item.Item
            item.Components = selectedGameObj.GetComponents <Component>()
                              .Select((m) => m.GetType().Name)
                              .ToList();

            newComponent.Inputs.Add(item.Item);
        }

        EditorGUILayout.BeginVertical();

        if (item.Components.Count > 0)
        {
            var componentIndex = EditorGUILayout.Popup("", item.ComponentIndex, item.Components.ToArray(),
                                                       EditorStyles.popup, GUILayout.Width(_width));
            if (componentIndex != item.ComponentIndex)
            {
                item.SetComponentIndex(componentIndex);
            }
        }

        if (item.Members.Count > 0)
        {
            item.MemberIndex =
                EditorGUILayout.Popup("", item.MemberIndex, item.Members.ToArray(), EditorStyles.popup, GUILayout.Width(_width));
            item.Item.Member = item.Members.ElementAt(item.MemberIndex);

            item.Item.Range = EditorGUILayout.DelayedIntField("Range", item.Item.Range, GUILayout.Width(_width));

            EditorGUILayout.LabelField("Value: ", _getValue(item).ToString());
        }

        EditorGUILayout.EndVertical();
        EditorGUILayout.Space();
    }
예제 #23
0
        // GUI
        //--------------------------------------------------------------
        void OnGUI()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

            if (_editor == null || _editor._portrait == null || _editor._portrait != _portrait)
            {
                return;
            }

            bool isGUIEvent = (Event.current.type == EventType.Repaint || Event.current.type == EventType.Layout);


            EditorGUILayout.BeginVertical();

            Texture2D iconImageAnimation = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Animation);
            Texture2D iconImageCategory  = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_FoldDown);
            Texture2D iconImageAddParam  = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Add);
            Texture2D iconImageLayerUp   = _editor.ImageSet.Get(apImageSet.PRESET.Modifier_LayerUp);
            Texture2D iconImageLayerDown = _editor.ImageSet.Get(apImageSet.PRESET.Modifier_LayerDown);
            Texture2D iconImageRemove    = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_RemoveTransform);

            GUIStyle guiStyleBox = new GUIStyle(GUI.skin.box);

            guiStyleBox.alignment        = TextAnchor.MiddleCenter;
            guiStyleBox.normal.textColor = apEditorUtil.BoxTextColor;

            //"  [ " + _animClip._name + " ] Animation Events"
            GUILayout.Box(new GUIContent(string.Format("  [ {0} ] {1}", _animClip._name, _editor.GetText(TEXT.DLG_AnimationEvents)), iconImageAnimation), guiStyleBox, GUILayout.Width(width - 10), GUILayout.Height(35));

            GUILayout.Space(5);
            //"Range : " + _animClip.StartFrame + " ~ " + _animClip.EndFrame
            EditorGUILayout.LabelField(string.Format("{0} : {1} ~ {2}", _editor.GetText(TEXT.DLG_Range), _animClip.StartFrame, _animClip.EndFrame));

            //"Is Loop Animation : " + _animClip.IsLoop
            EditorGUILayout.LabelField(string.Format("{0} : {1}", _editor.GetText(TEXT.DLG_IsLoopAnimation), _animClip.IsLoop));

            GUILayout.Space(10);

            GUIStyle guiStyle_None = new GUIStyle(GUIStyle.none);

            guiStyle_None.normal.textColor = GUI.skin.label.normal.textColor;
            guiStyle_None.alignment        = TextAnchor.MiddleLeft;

            GUIStyle guiStyle_Selected = new GUIStyle(GUIStyle.none);

            if (EditorGUIUtility.isProSkin)
            {
                guiStyle_Selected.normal.textColor = Color.cyan;
            }
            else
            {
                guiStyle_Selected.normal.textColor = Color.white;
            }
            guiStyle_Selected.alignment = TextAnchor.MiddleLeft;

            GUIStyle guiStyle_Center = new GUIStyle(GUIStyle.none);

            guiStyle_Center.normal.textColor = GUI.skin.label.normal.textColor;
            guiStyle_Center.alignment        = TextAnchor.MiddleCenter;


            int topHeight    = 120;
            int bottomHeight = 380;


            Color prevColor = GUI.backgroundColor;

            GUI.backgroundColor = new Color(0.9f, 0.9f, 0.9f);
            GUI.Box(new Rect(0, topHeight - 26, width, height - (topHeight + bottomHeight)), "");
            GUI.backgroundColor = prevColor;



            _scrollList = EditorGUILayout.BeginScrollView(_scrollList, GUILayout.Width(width), GUILayout.Height(height - (topHeight + bottomHeight)));
            GUILayout.Space(5);
            //"Animation Events"
            GUILayout.Button(new GUIContent(_editor.GetText(TEXT.DLG_AnimationEvents), iconImageCategory), guiStyle_None, GUILayout.Height(20));            //<투명 버튼//

            int nAnimEvents = 0;

            if (_animClip._animEvents != null)
            {
                nAnimEvents = _animClip._animEvents.Count;
            }

            //GUILayout.Space(10);
            apAnimEvent animEvent = null;

            for (int i = 0; i < nAnimEvents; i++)
            {
                GUIStyle curGUIStyle = guiStyle_None;
                animEvent = _animClip._animEvents[i];

                if (animEvent == _curSelectedEvent)
                {
                    Rect lastRect = GUILayoutUtility.GetLastRect();
                    prevColor = GUI.backgroundColor;

                    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);
                    }

                    GUI.Box(new Rect(lastRect.x, lastRect.y + 21, width, 20), "");
                    GUI.backgroundColor = prevColor;

                    curGUIStyle = guiStyle_Selected;
                }


                EditorGUILayout.BeginHorizontal(GUILayout.Width(width - 50));
                GUILayout.Space(15);
                if (GUILayout.Button("[" + i + "] " + animEvent._eventName, curGUIStyle, GUILayout.Width(width - 80), GUILayout.Height(20)))
                {
                    _curSelectedEvent = animEvent;
                }

                if (animEvent._callType == apAnimEvent.CALL_TYPE.Once)
                {
                    if (GUILayout.Button(animEvent._frameIndex.ToString(), curGUIStyle, GUILayout.Width(45), GUILayout.Height(20)))
                    {
                        _curSelectedEvent = animEvent;
                    }
                }
                else
                {
                    if (GUILayout.Button(animEvent._frameIndex + " ~ " + animEvent._frameIndex_End, curGUIStyle, GUILayout.Width(45), GUILayout.Height(20)))
                    {
                        _curSelectedEvent = animEvent;
                    }
                }

                EditorGUILayout.EndHorizontal();
            }

            GUILayout.Space((height - (topHeight + bottomHeight)) + 100);
            EditorGUILayout.EndScrollView();

            EditorGUILayout.EndVertical();

            GUILayout.Space(10);
            EditorGUILayout.BeginHorizontal(GUILayout.Height(30));
            GUILayout.Space(5);

            //"Add Event"
            if (GUILayout.Button(_editor.GetText(TEXT.DLG_AddEvent), GUILayout.Width(width - (10 + 4 + 80)), GUILayout.Height(30)))
            {
                apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_AddEvent, _editor, _animClip._portrait, null, false);

                if (_animClip._animEvents == null)
                {
                    _animClip._animEvents = new List <apAnimEvent>();
                }

                apAnimEvent newEvent = new apAnimEvent();
                //새로운 이름을 찾자
                int    iNewName = 0;
                string newName  = "NewAnimEvent_" + iNewName;

                int cnt = 0;
                while (true)
                {
                    if (cnt > 500)
                    {
                        newName = "NewAnimEvent_Infinity";
                        break;
                    }
                    //중복되는 이름이 있는가
                    newName = "NewAnimEvent_" + iNewName;
                    bool isExist = _animClip._animEvents.Exists(delegate(apAnimEvent a)
                    {
                        return(string.Equals(a._eventName, newName));
                    });
                    if (!isExist)
                    {
                        //중복되지 않는 이름이다.
                        break;
                    }

                    //이름이 중복되는 군염
                    cnt++;
                    iNewName++;
                }

                newEvent._eventName  = newName;
                newEvent._frameIndex = _defaultFrame;

                _animClip._animEvents.Add(newEvent);

                _curSelectedEvent = newEvent;
            }
            //"Sort"
            if (GUILayout.Button(_editor.GetText(TEXT.DLG_Sort), GUILayout.Width(80), GUILayout.Height(30)))
            {
                //프레임 순으로 정렬을 한다.
                if (_animClip._animEvents != null)
                {
                    _animClip._animEvents.Sort(delegate(apAnimEvent a, apAnimEvent b)
                    {
                        if (a._frameIndex == b._frameIndex)
                        {
                            return(string.Compare(a._eventName, b._eventName));
                        }
                        return(a._frameIndex - b._frameIndex);
                    });
                }
            }
            EditorGUILayout.EndHorizontal();

            //선택된 AnimEvent에 대한 설정을 하자
            GUILayout.Space(5);
            apEditorUtil.GUI_DelimeterBoxH(width - 10);
            GUILayout.Space(5);

            //선택이 안되었다면 더미 데이터로 채워야함
            int    curFrameIndex     = 0;
            int    curFrameIndex_End = 0;
            string curName           = "<None>";

            apAnimEvent.CALL_TYPE           curCallType  = apAnimEvent.CALL_TYPE.Once;
            List <apAnimEvent.SubParameter> curSubParams = null;
            int curNumSubParams = 0;

            bool isSelected = _curSelectedEvent != null && _animClip._animEvents.Contains(_curSelectedEvent);

            if (isSelected)
            {
                curFrameIndex     = _curSelectedEvent._frameIndex;
                curFrameIndex_End = _curSelectedEvent._frameIndex_End;
                curName           = _curSelectedEvent._eventName;
                curCallType       = _curSelectedEvent._callType;
                curSubParams      = _curSelectedEvent._subParams;
                curNumSubParams   = curSubParams.Count;
            }

            if (isSelected)
            {
                GUI.backgroundColor = new Color(0.6f, 0.8f, 0.9f, 1.0f);
            }

            //"(Not Selected)"
            GUILayout.Box((isSelected) ? curName : "(" + _editor.GetText(TEXT.DLG_NotSelected) + ")", guiStyleBox, GUILayout.Width(width - 10), GUILayout.Height(25));

            GUI.backgroundColor = prevColor;

            GUILayout.Space(5);

            EditorGUILayout.BeginVertical(GUILayout.Height(90));
            curName     = EditorGUILayout.DelayedTextField(_editor.GetText(TEXT.DLG_EventName), curName);                      //"Event(Function) Name"
            curCallType = (apAnimEvent.CALL_TYPE)EditorGUILayout.EnumPopup(_editor.GetText(TEXT.DLG_CallMethod), curCallType); //"Call Method"
            if (curCallType == apAnimEvent.CALL_TYPE.Once)
            {
                curFrameIndex = EditorGUILayout.DelayedIntField(_editor.GetText(TEXT.DLG_TargetFrame), curFrameIndex);                //"Target Frame"
            }
            else
            {
                curFrameIndex     = EditorGUILayout.DelayedIntField(_editor.GetText(TEXT.DLG_StartFrame), curFrameIndex);            //"Start Frame"
                curFrameIndex_End = EditorGUILayout.DelayedIntField(_editor.GetText(TEXT.DLG_EndFrame), curFrameIndex_End);          //"End Frame"
            }
            EditorGUILayout.EndVertical();

            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Parameters));            //"Parameters"
            GUILayout.Space(5);


            GUI.backgroundColor = new Color(0.9f, 0.9f, 0.9f);
            GUI.Box(new Rect(0, (height - (bottomHeight - 171)) + 22, width, 100), "");
            GUI.backgroundColor = prevColor;

            if (!isSelected)
            {
                if (!isGUIEvent)
                {
                    curNumSubParams = _prevNumSubParams;
                }
            }

            _scrollList_Param = EditorGUILayout.BeginScrollView(_scrollList_Param, GUILayout.Width(width), GUILayout.Height(100));

            GUILayout.Space(5);
            int valueWidth     = width - (10 + 35 + 130 + 36 + 36 + 36 + 20);
            int valueHalfWidth = ((valueWidth / 2) - 10);
            int midWaveWidth   = 20;

            valueWidth += 7;

            GUIStyle guiStyleListBtn = new GUIStyle(GUI.skin.button);

            guiStyleListBtn.margin = GUI.skin.textField.margin;

            apAnimEvent.SubParameter targetSubParam = null;
            bool isLayerUp     = false;
            bool isLayerDown   = false;
            bool isRemoveParam = false;

            //SubParam 리스트를 출력하자
            if (curNumSubParams > 0)
            {
                if (isSelected && curSubParams != null && curSubParams.Count == curNumSubParams)
                {
                    for (int i = 0; i < curNumSubParams; i++)
                    {
                        EditorGUILayout.BeginHorizontal(GUILayout.Width(width - 50), GUILayout.Height(24));
                        GUILayout.Space(15);
                        GUILayout.Label("[" + i + "]", GUILayout.Width(30), GUILayout.Height(20));

                        curSubParams[i]._paramType = (apAnimEvent.PARAM_TYPE)EditorGUILayout.EnumPopup(curSubParams[i]._paramType, GUILayout.Width(120), GUILayout.Height(20));

                        switch (curSubParams[i]._paramType)
                        {
                        case apAnimEvent.PARAM_TYPE.Bool:
                        {
                            bool nextValue = EditorGUILayout.Toggle(curSubParams[i]._boolValue, GUILayout.Width(valueWidth));

                            if (curSubParams[i]._boolValue != nextValue)
                            {
                                apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                                curSubParams[i]._boolValue = nextValue;
                            }
                        }
                        break;

                        case apAnimEvent.PARAM_TYPE.Integer:
                        {
                            if (curCallType == apAnimEvent.CALL_TYPE.Once)
                            {
                                int nextValue = EditorGUILayout.DelayedIntField(curSubParams[i]._intValue, GUILayout.Width(valueWidth));

                                if (curSubParams[i]._intValue != nextValue)
                                {
                                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                                    curSubParams[i]._intValue = nextValue;
                                }
                            }
                            else
                            {
                                int nextValue_Prev = EditorGUILayout.DelayedIntField(curSubParams[i]._intValue, GUILayout.Width(valueHalfWidth));
                                EditorGUILayout.LabelField(" ~ ", GUILayout.Width(midWaveWidth));
                                int nextValue_Next = EditorGUILayout.DelayedIntField(curSubParams[i]._intValue_End, GUILayout.Width(valueHalfWidth));

                                if (curSubParams[i]._intValue != nextValue_Prev ||
                                    curSubParams[i]._intValue_End != nextValue_Next)
                                {
                                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                                    curSubParams[i]._intValue     = nextValue_Prev;
                                    curSubParams[i]._intValue_End = nextValue_Next;
                                }
                            }
                        }
                        break;

                        case apAnimEvent.PARAM_TYPE.Float:
                        {
                            if (curCallType == apAnimEvent.CALL_TYPE.Once)
                            {
                                float nextValue = EditorGUILayout.DelayedFloatField(curSubParams[i]._floatValue, GUILayout.Width(valueWidth));
                                if (curSubParams[i]._floatValue != nextValue)
                                {
                                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                                    curSubParams[i]._floatValue = nextValue;
                                }
                            }
                            else
                            {
                                float nextValue_Prev = EditorGUILayout.DelayedFloatField(curSubParams[i]._floatValue, GUILayout.Width(valueHalfWidth));
                                EditorGUILayout.LabelField(" ~ ", GUILayout.Width(midWaveWidth));
                                float nextVelue_Next = EditorGUILayout.DelayedFloatField(curSubParams[i]._floatValue_End, GUILayout.Width(valueHalfWidth));

                                if (curSubParams[i]._floatValue != nextValue_Prev ||
                                    curSubParams[i]._floatValue_End != nextVelue_Next)
                                {
                                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);

                                    curSubParams[i]._floatValue     = nextValue_Prev;
                                    curSubParams[i]._floatValue_End = nextVelue_Next;
                                }
                            }
                        }
                        break;

                        case apAnimEvent.PARAM_TYPE.Vector2:
                        {
                            if (curCallType == apAnimEvent.CALL_TYPE.Once)
                            {
                                Vector2 nextValue = apEditorUtil.DelayedVector2Field(curSubParams[i]._vec2Value, valueWidth);
                                if (curSubParams[i]._vec2Value.x != nextValue.x ||
                                    curSubParams[i]._vec2Value.y != nextValue.y)
                                {
                                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                                    curSubParams[i]._vec2Value = nextValue;
                                }
                            }
                            else
                            {
                                Vector2 nextValue_Prev = apEditorUtil.DelayedVector2Field(curSubParams[i]._vec2Value, valueHalfWidth);
                                EditorGUILayout.LabelField(" ~ ", GUILayout.Width(midWaveWidth));
                                Vector2 nextValue_Next = apEditorUtil.DelayedVector2Field(curSubParams[i]._vec2Value_End, valueHalfWidth);


                                if (curSubParams[i]._vec2Value.x != nextValue_Prev.x ||
                                    curSubParams[i]._vec2Value.y != nextValue_Prev.y ||
                                    curSubParams[i]._vec2Value_End.x != nextValue_Next.x ||
                                    curSubParams[i]._vec2Value_End.y != nextValue_Next.y)
                                {
                                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);

                                    curSubParams[i]._vec2Value     = nextValue_Prev;
                                    curSubParams[i]._vec2Value_End = nextValue_Next;
                                }
                            }
                        }
                        break;

                        case apAnimEvent.PARAM_TYPE.String:
                        {
                            string nextValue = EditorGUILayout.DelayedTextField(curSubParams[i]._strValue, GUILayout.Width(valueWidth));
                            if (!string.Equals(curSubParams[i]._strValue, nextValue))
                            {
                                apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                                curSubParams[i]._strValue = nextValue;
                            }
                        }
                        break;
                        }

                        if (GUILayout.Button(iconImageLayerUp, guiStyleListBtn, GUILayout.Width(30), GUILayout.Height(20)))
                        {
                            targetSubParam = curSubParams[i];
                            isLayerUp      = true;
                        }
                        if (GUILayout.Button(iconImageLayerDown, guiStyleListBtn, GUILayout.Width(30), GUILayout.Height(20)))
                        {
                            targetSubParam = curSubParams[i];
                            isLayerDown    = true;
                        }
                        if (GUILayout.Button(iconImageRemove, guiStyleListBtn, GUILayout.Width(30), GUILayout.Height(20)))
                        {
                            targetSubParam = curSubParams[i];
                            isRemoveParam  = true;
                        }


                        EditorGUILayout.EndHorizontal();
                    }
                }
                else
                {
                    for (int i = 0; i < curNumSubParams; i++)
                    {
                        EditorGUILayout.BeginHorizontal(GUILayout.Width(width - 50));
                        GUILayout.Space(15);
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width - 50));
            GUILayout.Space(15);
            if (isSelected)
            {
                //" Add Parameter"
                if (GUILayout.Button(new GUIContent(" " + _editor.GetText(TEXT.DLG_AddParameter), iconImageAddParam), guiStyle_None, GUILayout.Height(20)))
                {
                    if (isSelected && curSubParams != null && curSubParams.Count == curNumSubParams)
                    {
                        apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);

                        curSubParams.Add(new apAnimEvent.SubParameter());
                    }
                }
            }
            else
            {
                if (GUILayout.Button("", guiStyle_None, GUILayout.Height(20)))
                {
                }
            }
            EditorGUILayout.EndHorizontal();



            GUILayout.Space(150);

            EditorGUILayout.EndScrollView();

            GUILayout.Space(10);

            EditorGUILayout.BeginVertical(GUILayout.Width(width), GUILayout.Height(40));
            if (isSelected)
            {
                //"Remove Event [" + curName + "]"
                if (GUILayout.Button(string.Format("{0} [{1}]", _editor.GetText(TEXT.DLG_RemoveEvent), curName), GUILayout.Height(20)))
                {
                    if (_curSelectedEvent != null && _animClip._animEvents.Contains(_curSelectedEvent))
                    {
                        apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_RemoveEvent, _editor, _animClip._portrait, null, false);
                        _animClip._animEvents.Remove(_curSelectedEvent);

                        _curSelectedEvent = null;
                        isSelected        = false;
                    }
                }
            }
            else
            {
                if (GUILayout.Button("", guiStyle_None, GUILayout.Height(20)))
                {
                }
            }
            EditorGUILayout.EndVertical();



            if (isSelected && _curSelectedEvent != null)
            {
                //순서를 바꾸거나 SubParam을 삭제하는 요청이 있으면 처리해주자
                if (targetSubParam != null && _curSelectedEvent._subParams.Contains(targetSubParam))
                {
                    if (isLayerUp)
                    {
                        //Index -1

                        int index = _curSelectedEvent._subParams.IndexOf(targetSubParam);
                        if (index > 0)
                        {
                            apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                            _curSelectedEvent._subParams.Remove(targetSubParam);
                            _curSelectedEvent._subParams.Insert(index - 1, targetSubParam);
                        }
                    }
                    else if (isLayerDown)
                    {
                        //Index +1
                        int index = _curSelectedEvent._subParams.IndexOf(targetSubParam);
                        if (index < _curSelectedEvent._subParams.Count - 1)
                        {
                            apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                            _curSelectedEvent._subParams.Remove(targetSubParam);
                            _curSelectedEvent._subParams.Insert(index + 1, targetSubParam);
                        }
                    }
                    else if (isRemoveParam)
                    {
                        //삭제한다.
                        apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                        _curSelectedEvent._subParams.Remove(targetSubParam);
                    }
                }


                if (_curSelectedEvent._frameIndex != curFrameIndex ||
                    _curSelectedEvent._frameIndex_End != curFrameIndex_End ||
                    _curSelectedEvent._eventName != curName ||
                    _curSelectedEvent._callType != curCallType)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);

                    _curSelectedEvent._frameIndex     = curFrameIndex;
                    _curSelectedEvent._frameIndex_End = curFrameIndex_End;
                    _curSelectedEvent._eventName      = curName;
                    _curSelectedEvent._callType       = curCallType;
                }
            }


            EditorGUILayout.BeginHorizontal();
            bool isClose = false;

            //"Close"
            if (GUILayout.Button(_editor.GetText(TEXT.DLG_Close), GUILayout.Height(30)))
            {
                isClose = true;
                apEditorUtil.ReleaseGUIFocus();
            }
            EditorGUILayout.EndHorizontal();


            if (isGUIEvent)
            {
                _prevNumSubParams = curNumSubParams;
            }

            if (isClose)
            {
                CloseDialog();
            }
        }
예제 #24
0
        public override void OnInspectorGUI()
        {
            EditorGUI.BeginChangeCheck();
            var count = EditorGUILayout.DelayedIntField("Number of Animated Sprites",
                                                        tile.m_AnimatedSprites != null ? tile.m_AnimatedSprites.Length : 0);

            if (count < 0)
            {
                count = 0;
            }

            if (tile.m_AnimatedSprites == null || tile.m_AnimatedSprites.Length != count)
            {
                Array.Resize <Sprite>(ref tile.m_AnimatedSprites, count);
            }

            if (count == 0)
            {
                return;
            }

            EditorGUILayout.LabelField("Place sprites shown based on the order of animation.");
            EditorGUILayout.Space();

            for (var i = 0; i < count; i++)
            {
                tile.m_AnimatedSprites[i] = (Sprite)EditorGUILayout.ObjectField("Sprite " + (i + 1),
                                                                                tile.m_AnimatedSprites[i], typeof(Sprite), false, null);
            }

            var minSpeed = EditorGUILayout.FloatField("Minimum Speed", tile.m_MinSpeed);
            var maxSpeed = EditorGUILayout.FloatField("Maximum Speed", tile.m_MaxSpeed);

            if (minSpeed < 0.0f)
            {
                minSpeed = 0.0f;
            }

            if (maxSpeed < 0.0f)
            {
                maxSpeed = 0.0f;
            }

            if (maxSpeed < minSpeed)
            {
                maxSpeed = minSpeed;
            }

            tile.m_MinSpeed = minSpeed;
            tile.m_MaxSpeed = maxSpeed;

            using (new EditorGUI.DisabledScope(0 < tile.m_AnimationStartFrame &&
                                               tile.m_AnimationStartFrame <= tile.m_AnimatedSprites.Length))
            {
                tile.m_AnimationStartTime = EditorGUILayout.FloatField("Start Time", tile.m_AnimationStartTime);
            }

            tile.m_AnimationStartFrame = EditorGUILayout.IntField("Start Frame", tile.m_AnimationStartFrame);

            tile.m_TileColliderType =
                (Tile.ColliderType)EditorGUILayout.EnumPopup("Collider Type", tile.m_TileColliderType);
            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(tile);
            }
        }
예제 #25
0
        //draw the render queue selector
        public static int drawRenderQueueSelector(Shader defaultShader, int customQueueFieldInput)
        {
            EditorGUILayout.BeginHorizontal();
            if (customQueueFieldInput == -1)
            {
                customQueueFieldInput = ThryEditor.currentlyDrawing.materials[0].renderQueue;
            }
            int[]    queueOptionsQueues = new int[] { defaultShader.renderQueue, 2000, 2450, 3000, customQueueFieldInput };
            string[] queueOptions       = new string[] { "From Shader", "Geometry", "Alpha Test", "Transparency" };
            int      queueSelection     = 4;

            if (defaultShader.renderQueue == customQueueFieldInput)
            {
                queueSelection = 0;
            }
            else
            {
                string customOption = null;
                int    q            = customQueueFieldInput;
                if (q < 2000)
                {
                    customOption = queueOptions[1] + "-" + (2000 - q);
                }
                else if (q < 2450)
                {
                    if (q > 2000)
                    {
                        customOption = queueOptions[1] + "+" + (q - 2000);
                    }
                    else
                    {
                        queueSelection = 1;
                    }
                }
                else if (q < 3000)
                {
                    if (q > 2450)
                    {
                        customOption = queueOptions[2] + "+" + (q - 2450);
                    }
                    else
                    {
                        queueSelection = 2;
                    }
                }
                else if (q < 5001)
                {
                    if (q > 3000)
                    {
                        customOption = queueOptions[3] + "+" + (q - 3000);
                    }
                    else
                    {
                        queueSelection = 3;
                    }
                }
                if (customOption != null)
                {
                    queueOptions = new string[] { "From Shader", "Geometry", "Alpha Test", "Transparency", customOption }
                }
                ;
            }
            EditorGUILayout.LabelField("Render Queue", GUILayout.ExpandWidth(true));
            int newQueueSelection = EditorGUILayout.Popup(queueSelection, queueOptions, GUILayout.MaxWidth(100));
            int newQueue          = queueOptionsQueues[newQueueSelection];

            if (queueSelection != newQueueSelection)
            {
                customQueueFieldInput = newQueue;
            }
            int  newCustomQueueFieldInput = EditorGUILayout.DelayedIntField(customQueueFieldInput, GUILayout.MaxWidth(65));
            bool isInput = customQueueFieldInput != newCustomQueueFieldInput || queueSelection != newQueueSelection;

            customQueueFieldInput = newCustomQueueFieldInput;
            foreach (Material m in ThryEditor.currentlyDrawing.materials)
            {
                if (customQueueFieldInput != m.renderQueue && isInput)
                {
                    m.renderQueue = customQueueFieldInput;
                }
            }
            if (customQueueFieldInput != ThryEditor.currentlyDrawing.materials[0].renderQueue && !isInput)
            {
                customQueueFieldInput = ThryEditor.currentlyDrawing.materials[0].renderQueue;
            }
            EditorGUILayout.EndHorizontal();
            return(customQueueFieldInput);
        }
예제 #26
0
        public override void OnInspectorGUI()
        {
            var changed = false;

            EditorGUI.BeginChangeCheck();
            serializedObject.Update();
            base.OnInspectorGUI();
            serializedObject.ApplyModifiedProperties();
            changed = EditorGUI.EndChangeCheck();

            ValidateEditorData();

            if (!useRenderer)
            {
                m_MultiMaterialData.Update();
                EditorGUI.BeginChangeCheck();
                m_Materials.arraySize = EditorGUILayout.DelayedIntField("Size",
                                                                        m_Materials.arraySize);
                m_MultiMaterialData.ApplyModifiedProperties();
                if (EditorGUI.EndChangeCheck())
                {
                    if (m_MultiMaterial.multiMaterialData != null)
                    {
                        m_MultiMaterialData = new SerializedObject(m_MultiMaterial.multiMaterialData);
                    }
                    ValidateEditorData();
                    changed = true;
                }
            }
            else if (m_Renderer != null)
            {
                if (CreateMultiMaterialDataButton(false))
                {
                    if (m_MultiMaterial.multiMaterialData != null)
                    {
                        m_MultiMaterialData = new SerializedObject(m_MultiMaterial.multiMaterialData);
                    }
                    ValidateEditorData();
                }
            }

            if (!useRenderer || m_Renderer != null)
            {
                MaterialArrayDrawers.OnInspectorGUI(m_MultiMaterialData, materialArray,
                                                    ref m_MaterialEditors, changed, m_MaterialProperties);

                if (m_Renderer == null && MaterialArrayDrawers.AddSelectedButtons(m_MultiMaterialData, materialArray))
                {
                    MaterialArrayDrawers.RebuildMaterialEditors(ref m_MaterialEditors, materialArray);
                    return;
                }

                if (GUILayout.Button("Select Materials"))
                {
                    if (materialArray != null && materialArray.materials != null &&
                        materialArray.materials.Length > 0)
                    {
                        Selection.objects = materialArray.materials;
                    }
                }
            }
        }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            serializedObject.Update();

            UIComponent t = (UIComponent)target;

            EditorGUILayout.PropertyField(m_EnableOpenUIFormSuccessEvent);
            EditorGUILayout.PropertyField(m_EnableOpenUIFormFailureEvent);
            EditorGUILayout.PropertyField(m_EnableOpenUIFormUpdateEvent);
            EditorGUILayout.PropertyField(m_EnableOpenUIFormDependencyAssetEvent);
            EditorGUILayout.PropertyField(m_EnableCloseUIFormCompleteEvent);

            float instanceAutoReleaseInterval = EditorGUILayout.DelayedFloatField("Instance Auto Release Interval", m_InstanceAutoReleaseInterval.floatValue);

            if (instanceAutoReleaseInterval != m_InstanceAutoReleaseInterval.floatValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.InstanceAutoReleaseInterval = instanceAutoReleaseInterval;
                }
                else
                {
                    m_InstanceAutoReleaseInterval.floatValue = instanceAutoReleaseInterval;
                }
            }

            int instanceCapacity = EditorGUILayout.DelayedIntField("Instance Capacity", m_InstanceCapacity.intValue);

            if (instanceCapacity != m_InstanceCapacity.intValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.InstanceCapacity = instanceCapacity;
                }
                else
                {
                    m_InstanceCapacity.intValue = instanceCapacity;
                }
            }

            float instanceExpireTime = EditorGUILayout.DelayedFloatField("Instance Expire Time", m_InstanceExpireTime.floatValue);

            if (instanceExpireTime != m_InstanceExpireTime.floatValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.InstanceExpireTime = instanceExpireTime;
                }
                else
                {
                    m_InstanceExpireTime.floatValue = instanceExpireTime;
                }
            }

            int instancePriority = EditorGUILayout.DelayedIntField("Instance Priority", m_InstancePriority.intValue);

            if (instancePriority != m_InstancePriority.intValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.InstancePriority = instancePriority;
                }
                else
                {
                    m_InstancePriority.intValue = instancePriority;
                }
            }

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            {
                EditorGUILayout.PropertyField(m_InstanceRoot);
                m_UIFormHelperInfo.Draw();
                m_UIGroupHelperInfo.Draw();
                EditorGUILayout.PropertyField(m_UIGroups, true);
            }
            EditorGUI.EndDisabledGroup();

            if (EditorApplication.isPlaying)
            {
                EditorGUILayout.LabelField("UI Group Count", t.UIGroupCount.ToString());
            }

            serializedObject.ApplyModifiedProperties();

            Repaint();
        }
        public override void OnInspectorGUI()
        {
            foreach (var categoryProperties in _resourceManager.CategoryProperties)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(FoldoutSpace);
                var foldout = EditorGUILayout.Foldout(
                    _resourceManager.CategoryFoldouts[categoryProperties.Category],
                    categoryProperties.Category);
                GUILayout.EndHorizontal();

                _resourceManager.CategoryFoldouts[categoryProperties.Category] = foldout;
                if (foldout)
                {
                    foreach (var property in categoryProperties.Properties)
                    {
                        var propertyType = property.Type;

                        GUILayout.BeginHorizontal();
                        GUILayout.Space(FoldoutSpace);
                        GUILayout.Label(new GUIContent(property.DisplayName, property.Description));
                        GUILayout.FlexibleSpace();

                        switch (property.PropertyKind)
                        {
                        case PropertyKind.Undefined:
                            if (propertyType == typeof(Color))
                            {
                                property.SetValue(EditorGUILayout.ColorField(property.GetValue <Color>()));
                            }
                            else if (propertyType == typeof(float))
                            {
                                property.SetValue(
                                    EditorGUILayout.DelayedFloatField(
                                        property.GetValue <float>()));
                            }
                            else if (propertyType == typeof(string))
                            {
                                property.SetValue(
                                    EditorGUILayout.DelayedTextField(
                                        property.GetValue <string>()));
                            }
                            else if (propertyType == typeof(int))
                            {
                                property.SetValue(EditorGUILayout.DelayedIntField(property.GetValue <int>()));
                            }
                            else if (propertyType == typeof(long))
                            {
                                property.SetValue(EditorGUILayout.LongField(property.GetValue <long>()));
                            }
                            else if (propertyType == typeof(double))
                            {
                                property.SetValue(EditorGUILayout.DoubleField(property.GetValue <double>()));
                            }
                            else if (propertyType == typeof(bool))
                            {
                                property.SetValue(EditorGUILayout.Toggle(
                                                      GUIContent.none,
                                                      property.GetValue <bool>()));
                            }
                            else if (propertyType == typeof(Vector2))
                            {
                                property.SetValue(EditorGUILayout.Vector2Field(GUIContent.none,
                                                                               property.GetValue <Vector2>()));
                            }
                            else if (propertyType == typeof(Vector3))
                            {
                                property.SetValue(EditorGUILayout.Vector3Field(
                                                      GUIContent.none,
                                                      property.GetValue <Vector3>()));
                            }
                            else if (propertyType == typeof(Bounds))
                            {
                                property.SetValue(EditorGUILayout.BoundsField(property.GetValue <Bounds>()));
                            }
                            else if (propertyType == typeof(Rect))
                            {
                                property.SetValue(EditorGUILayout.RectField(property.GetValue <Rect>()));
                            }
                            else if (propertyType.IsEnum)
                            {
                                var flagsAttribute = propertyType.GetCustomAttributes(typeof(FlagsAttribute), false)
                                                     .Cast <FlagsAttribute>()
                                                     .FirstOrDefault();

                                property.SetValue(flagsAttribute != null
                                        ? EditorGUILayout.EnumMaskField(property.GetValue <Enum>())
                                        : EditorGUILayout.EnumPopup(property.GetValue <Enum>()));
                            }
                            else if (typeof(UnityEngine.Object).IsAssignableFrom(propertyType))
                            {
                                property.SetValue(EditorGUILayout.ObjectField(
                                                      property.GetValue <UnityEngine.Object>(),
                                                      propertyType,
                                                      true));
                            }
                            break;

                        case PropertyKind.Tag:
                            property.SetValue(EditorGUILayout.TagField(property.GetValue <string>()));
                            break;

                        case PropertyKind.Layer:
                            property.SetValue(EditorGUILayout.LayerField(property.GetValue <int>()));
                            break;

                        case PropertyKind.Passwort:
                            property.SetValue(EditorGUILayout.PasswordField(property.GetValue <string>()));
                            break;

                        default:
                            throw new NotSupportedException(string.Format(
                                                                "The property kind '{0}' is not supported.",
                                                                property.PropertyKind));
                        }

                        GUILayout.EndHorizontal();
                    }
                }
            }
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUI.BeginChangeCheck();

            m_WaterArea.pointPerUnits = EditorGUILayout.DelayedIntField("Point per unit", m_WaterArea.pointPerUnits);

            EditorGUI.BeginChangeCheck();

            Vector2 newOffsetValue = EditorGUILayout.Vector2Field("Offset", m_OffsetProp.vector2Value);

            if (newOffsetValue.x > 0f && newOffsetValue.y > 0f)
            {
                m_OffsetProp.vector2Value = newOffsetValue;
            }
            Vector2 newSizeValue = EditorGUILayout.Vector2Field("Size", m_SizeProp.vector2Value);

            if (newSizeValue.x > 0f && newSizeValue.y > 0f)
            {
                m_SizeProp.vector2Value = newSizeValue;
            }

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                m_WaterArea.AdjustComponentSizes();
                m_WaterArea.RecomputeMesh();
                EditorUtility.SetDirty(target);
            }

            m_WaterArea.dampening         = EditorGUILayout.FloatField("Dampening", m_WaterArea.dampening);
            m_WaterArea.tension           = EditorGUILayout.FloatField("Tension", m_WaterArea.tension);
            m_WaterArea.neighbourTransfer =
                EditorGUILayout.FloatField("Neighbour Transfer", m_WaterArea.neighbourTransfer);

            if (EditorGUI.EndChangeCheck() || (m_WaterArea.boxCollider2D != null &&
                                               (m_PrevSize != m_WaterArea.boxCollider2D.size ||
                                                m_PrevOffset != m_WaterArea.boxCollider2D.offset)))
            {
                m_WaterArea.RecomputeMesh();
                EditorUtility.SetDirty(target);
            }

            EditorGUI.BeginChangeCheck();
            int sortLayer = EditorGUILayout.Popup("Sorting Layer", m_CurrentLayer, m_SortingLayers);

            if (sortLayer != m_CurrentLayer)
            {
                m_WaterArea.sortingLayerID = SortingLayer.NameToID(m_SortingLayers[sortLayer]);
                m_CurrentLayer             = sortLayer;
            }

            EditorGUILayout.PropertyField(m_SortingLayerOrderProp);

            if (EditorGUI.EndChangeCheck())
            {
                m_WaterArea.SetSortingLayer();
                EditorUtility.SetDirty(target);
            }

            EditorGUILayout.PropertyField(m_SplashPlayerPrefabProp);

            serializedObject.ApplyModifiedProperties();

            m_PrevSize   = m_WaterArea.boxCollider2D.size;
            m_PrevOffset = m_WaterArea.boxCollider2D.offset;
        }
    public override void OnInspectorGUI()
    {
        quest_stuff qst = (quest_stuff)target;

        if (qst.replacements == null)
        {
            qst.replacements = new List <mat_replacement>();
        }

        if (qst.objs == null)
        {
            qst.objs = new List <obj_toggly>();
        }

        for (int i = 0; i < qst.replacements.Count; i++)
        {
            mat_replacement replacement = qst.replacements[i];

            replacement.shown = EditorGUILayout.Foldout(replacement.shown, replacement.name, true, EditorStyles.foldout);

            if (replacement.shown)
            {
                EditorGUI.indentLevel++;
                replacement.name = EditorGUILayout.DelayedTextField(replacement.name);

                if (GUILayout.Button("delete"))
                {
                    qst.replacements.RemoveAt(i);
                    continue;
                }

                int newCount = Mathf.Max(0, EditorGUILayout.DelayedIntField("size", replacement.materials.Count));
                while (newCount < replacement.materials.Count)
                {
                    replacement.materials.RemoveAt(replacement.materials.Count - 1);
                }
                while (newCount > replacement.materials.Count)
                {
                    replacement.materials.Add(null);
                }

                replacement.shader_default = (Shader)EditorGUILayout.ObjectField(replacement.shader_default, typeof(Shader), false);
                replacement.shader_quest   = (Shader)EditorGUILayout.ObjectField(replacement.shader_quest, typeof(Shader), false);

                for (int j = 0; j < replacement.materials.Count; j++)
                {
                    replacement.materials[j] = (Material)EditorGUILayout.ObjectField(replacement.materials[j], typeof(Material), false);
                }
                EditorGUI.indentLevel--;
            }
        }

        if (GUILayout.Button("add shader replacement"))
        {
            mat_replacement replacement = new mat_replacement();
            replacement.materials = new List <Material>();
            qst.replacements.Add(replacement);
        }



        for (int i = 0; i < qst.objs.Count; i++)
        {
            obj_toggly toggle = qst.objs[i];

            toggle.shown = EditorGUILayout.Foldout(toggle.shown, toggle.name, true, EditorStyles.foldout);

            if (toggle.shown)
            {
                EditorGUI.indentLevel++;
                toggle.name = EditorGUILayout.DelayedTextField(toggle.name);

                if (GUILayout.Button("delete"))
                {
                    qst.objs.RemoveAt(i);
                    continue;
                }

                int newCount = Mathf.Max(0, EditorGUILayout.DelayedIntField("size", toggle.objs.Count));
                while (newCount < toggle.objs.Count)
                {
                    toggle.objs.RemoveAt(toggle.objs.Count - 1);
                }
                while (newCount > toggle.objs.Count)
                {
                    toggle.objs.Add(null);
                }

                EditorGUILayout.BeginHorizontal();
                toggle.pc    = EditorGUILayout.Toggle("PC", toggle.pc);
                toggle.quest = EditorGUILayout.Toggle("Quest", toggle.quest);
                EditorGUILayout.EndHorizontal();

                for (int j = 0; j < toggle.objs.Count; j++)
                {
                    toggle.objs[j] = (GameObject)EditorGUILayout.ObjectField(toggle.objs[j], typeof(GameObject), true);
                }
                EditorGUI.indentLevel--;
            }
        }

        if (GUILayout.Button("add toggle"))
        {
            obj_toggly toggle = new obj_toggly();
            toggle.objs = new List <GameObject>();
            qst.objs.Add(toggle);
        }

        EditorGUILayout.BeginHorizontal();

        bool change    = false;
        bool target_pc = true;

        if (GUILayout.Button("Set PC"))
        {
            change = true;
        }

        if (GUILayout.Button("Set Quest"))
        {
            target_pc = false;
            change    = true;
        }

        if (change)
        {
            for (int i = 0; i < qst.replacements.Count; i++)
            {
                mat_replacement replacement = qst.replacements[i];

                if (replacement.shader_default == null || replacement.shader_quest == null)
                {
                    continue;
                }

                for (int j = 0; j < replacement.materials.Count; j++)
                {
                    if (replacement.materials[j] != null)
                    {
                        replacement.materials[j].shader = target_pc? replacement.shader_default: replacement.shader_quest;
                    }
                }
            }

            for (int i = 0; i < qst.objs.Count; i++)
            {
                obj_toggly toggle = qst.objs[i];
                for (int j = 0; j < toggle.objs.Count; j++)
                {
                    if (toggle.objs[j] != null)
                    {
                        toggle.objs[j].SetActive(toggle.pc == target_pc || toggle.quest == !target_pc);
                    }
                }
            }
        }

        EditorGUILayout.EndHorizontal();


        if (GUI.changed)
        {
            serializedObject.ApplyModifiedProperties();
            EditorUtility.SetDirty(qst);
        }
    }