Vector2 scrollPosition;                  //to initialize the value of scroll position for the scroll bar outside the display update loop to avoid reinitializing it constantly

    public override void OnInspectorGUI()    //graphical UI in the inspector for our custom terrain editor (display update loop)
    {
        serializedObject.Update();           //updates all serialized values between this script and terrain script

        TerrainS terrain = (TerrainS)target; //links target variable to the other script/class that this script is linked to (on line 7) to allow us to access Terrain vars and methods easily

        //SCROLLBAR CODE
        Rect rect = EditorGUILayout.BeginVertical();                                                                                 //amount of space in the inspector to shove UI data of script into

        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Width(rect.width), GUILayout.Width(rect.height)); //create the scroll bar using the dimensions set for the UI (made at the script component) and adjust the scroll bar accordingly
        EditorGUI.indentLevel++;                                                                                                     //increase indents in the inspector; mainly at the script component (scroll bar goes over foldout triangles so this helps make them completely visible again).

        EditorGUILayout.PropertyField(resetBeforeApply);                                                                             //tick-box in UI to allow user to choose between applying changes to the terrain after reseting it or applying changes to the terrain with the previous existing data on it

        //set up UI in foldout for random heights function
        randomEnabled = EditorGUILayout.Foldout(randomEnabled, "Random Heights");
        if (randomEnabled)                                                       //open if clicked
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);           //horizontal separation
            GUILayout.Label("Set Random Heights Range", EditorStyles.boldLabel); //instruction label
            EditorGUILayout.PropertyField(randomHeightRange);                    //allows for adjusting the random heights range values in the UI

            if (GUILayout.Button("Produce Random Heights"))                      //if apply button is pressed
            {
                terrain.ProcessRandomTerrain();                                  //call corresponding function
            }
        }

        //set up UI in foldout for loading heightmaps function
        heightsLoadingEnabled = EditorGUILayout.Foldout(heightsLoadingEnabled, "Load Heightmap");
        if (heightsLoadingEnabled)                                                    //open if clicked
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);                //horizontal separation
            GUILayout.Label("Load Heights from Texture Map", EditorStyles.boldLabel); //text label
            EditorGUILayout.PropertyField(heightMapImg);                              //allows for adding in the 2D texture map in the UI (cool online resource for heightmaps is terrain.party)
            EditorGUILayout.PropertyField(heightMapSize);                             //allows for adjusting the heightmap size in the UI in case the height map loaded in is bigger (if it's smaller it won't look good)

            if (GUILayout.Button("Load Texture"))                                     //if apply button is pressed
            {
                terrain.ProcessHeightMap();                                           //call corresponding function
            }
        }

        //set up UI in foldout for applying fractalBrownianMotion function
        perlinNoiseEnabled = EditorGUILayout.Foldout(perlinNoiseEnabled, "Fractal Brownian Motion - Perlin Noise");
        if (perlinNoiseEnabled)                                                                             //open if clicked
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);                                      //horizontal separation
            GUILayout.Label("Perlin Noise", EditorStyles.boldLabel);                                        //text label
            EditorGUILayout.Slider(perlinFrequency, 0, 1, new GUIContent("Frequency"));                     //allows to adjust frequency values (from 0 to 1)
            EditorGUILayout.Slider(perlinAmplitude, 0, 1, new GUIContent("Amplitude"));                     //allows to adjust amplitude values (from 0 to 1)
            //for intSlider -> increment the offsets in single int values as the coordinates for the heightmap are also in integers;
            EditorGUILayout.IntSlider(perlinFrequencyOffset, 0, 10000, new GUIContent("Offset Frequency")); //allows to adjust amplitude offset values
            EditorGUILayout.IntSlider(perlinAmplitudeOffset, 0, 10000, new GUIContent("Offset Amplitude")); //allows to adjust amplitude offset values; adjusting the offset can result in various different terrain structures
            EditorGUILayout.IntSlider(octaves, 1, 10, new GUIContent("Octaves"));                           //adjust how many Perlin Noise curves (values) are created and combined
            EditorGUILayout.Slider(persistance, 0.1f, 10, new GUIContent("Persistance"));                   //to adjust the amount of change between each octave
            EditorGUILayout.Slider(fractalBrownianMotionSize, 0, 1, new GUIContent("Scale"));               //to adjust the size

            if (GUILayout.Button("Apply fractal Brownian Motion"))                                          //if apply button is pressed
            {
                terrain.ApplyPerlinNoise();                                                                 //call corresponding function
            }
        }

        //set up UI in foldout for applying multipleFractalBrownianMotion function
        multipleFractalBrownianMotionEnabled = EditorGUILayout.Foldout(multipleFractalBrownianMotionEnabled, "Multiple Fractal Brownian Motion (BUG)");
        if (multipleFractalBrownianMotionEnabled)                                        //open if clicked
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);                   //horizontal separation
            GUILayout.Label("Multiple Fractal Brownian Motion", EditorStyles.boldLabel); //text label
            //create table to store list of fractalBrownianMotionParams
            fractalBrownianMotionParamsTable = GUITableLayout.DrawTable(fractalBrownianMotionParamsTable, fractalBrownianMotionParams);
            EditorGUILayout.BeginHorizontal(); //adding plus/minus buttons next to each other in one block/cell
            if (GUILayout.Button("+"))         //pressing plus adds a FractalBrownianMotion with its params to adjust
            {
                terrain.addFractalBrownianMotion();
            }
            if (GUILayout.Button("-")) //pressing minus removes the existing FractalBrownianMotion in the list (if there's more than one)
            {
                terrain.removeFractalBrownianMotion();
            }
            EditorGUILayout.EndHorizontal();                                //ensuring only buttons are added next to one another

            if (GUILayout.Button("Apply Multiple Fractal Brownian Motion")) //if apply button is pressed
            {
                terrain.ApplyMultiplePerlinNoise();                         //call corresponding function
            }
        }

        //set up UI in foldout for applying voronoiTesselation function
        voronoiTessellationEnabled = EditorGUILayout.Foldout(voronoiTessellationEnabled, "Voronoi Tessellation");
        if (voronoiTessellationEnabled)                                                                       //open if clicked
        {
            EditorGUILayout.IntSlider(voronoiNumberOfSeeds, 1, 10, new GUIContent("Number of Seeds"));        //to determine how many seeds are added onto the terrain (how many mountains)
            EditorGUILayout.Slider(voronoiTessellationSlopeFallOff, 0, 10, new GUIContent("Slope Fall Off")); //adjust slope fall off
            EditorGUILayout.Slider(voronoiTessellationSlopeDropOff, 0, 10, new GUIContent("Slope Drop Off")); //adjust slope drop off
            EditorGUILayout.Slider(voronoiTessellationMinHeight, 0, 1, new GUIContent("Max Height"));         //determine the highest point seeds can be
            EditorGUILayout.Slider(voronoiTessellationMaxHeight, 0, 1, new GUIContent("Min Height"));         //determine the lowest point seeds can be
            EditorGUILayout.PropertyField(voronoiTessellationAlgorithmType);                                  //determine the type of algorithm that will be used


            if (GUILayout.Button("Apply Voronoi"))  //if apply button is pressed
            {
                terrain.ApplyVoronoiTessellation(); //call corresponding function
            }
        }

        //set up UI in foldout for applying diamond square function
        diamondSquareEnabled = EditorGUILayout.Foldout(diamondSquareEnabled, "Diamond Square");
        if (diamondSquareEnabled) //open if clicked
        {
            EditorGUILayout.PropertyField(diamondSquareMinHeight);
            EditorGUILayout.PropertyField(diamondSquareMaxHeight);
            EditorGUILayout.PropertyField(diamondSquareHeightControlPower);
            EditorGUILayout.PropertyField(diamondSquareRoughnessControl);

            if (GUILayout.Button("Apply Diamond Square")) //if apply button is pressed
            {
                terrain.ApplyDiamondSquare();             //call corresponding function
            }
        }

        //set up UI in foldout for applying textures
        splatEnabled = EditorGUILayout.Foldout(splatEnabled, "Splat Texturing");
        if (splatEnabled)                                              //open if clicked
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); //horizontal separation
            GUILayout.Label("Splat Map", EditorStyles.boldLabel);      //text label

            //create table to store list of splatsByAltitude
            splatMapPropetiesTable = GUITableLayout.DrawTable(splatMapPropetiesTable, splatsByAltitude);

            EditorGUILayout.BeginHorizontal(); //adding plus/minus buttons next to each other in one block/cell
            if (GUILayout.Button("+"))         //pressing plus adds a FractalBrownianMotion with its params to adjust
            {
                terrain.addSplatMap();
            }
            if (GUILayout.Button("-")) //pressing minus removes the existing FractalBrownianMotion in the list (if there's more than one)
            {
                terrain.removeSplatMap();
            }
            EditorGUILayout.EndHorizontal(); //ensuring only buttons are added next to one another


            if (GUILayout.Button("Apply Textures")) //if apply button is pressed
            {
                terrain.ApplySplatTexturing();      //call corresponding function
            }
        }

        //set up UI in foldout for generating vegetation
        vegetationEnabled = EditorGUILayout.Foldout(vegetationEnabled, "Vegetation (WORKING PROGRESS)"); //if foldout clicked
        if (vegetationEnabled)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);                            //horizontal separation
            GUILayout.Label("Vegetation", EditorStyles.boldLabel);                                //text label
            EditorGUILayout.IntSlider(maxVegetation, 1, 10000, new GUIContent("Trees Max"));      //to determine how many trees or vegetation to generate
            EditorGUILayout.IntSlider(vegetationSpacing, 1, 20, new GUIContent("Trees Spacing")); //to determine how much space to have between trees or vegetation

            //create table to store list of splatsByAltitude
            vegetationsMapTable = GUITableLayout.DrawTable(vegetationsMapTable, vegetations);

            EditorGUILayout.BeginHorizontal(); //adding plus/minus buttons next to each other in one block/cell
            if (GUILayout.Button("+"))         //pressing plus adds a Vegetation type with its params to adjust
            {
                terrain.AddNewVegetation();
            }
            if (GUILayout.Button("-")) //pressing minus removes the existing Vegetation objects in the list (if there's more than one)
            {
                terrain.RemoveVegetation();
            }
            EditorGUILayout.EndHorizontal(); //ensuring only buttons are added next to one another


            if (GUILayout.Button("Apply Vegetation")) //if apply button is pressed
            {
                terrain.ApplyVegetation();            //call corresponding function
            }
        }

        //set up UI in foldout for applying smoothing function
        smoothEnabled = EditorGUILayout.Foldout(smoothEnabled, "Smooth Function"); //if foldout clicked
        if (smoothEnabled)
        {
            EditorGUILayout.IntSlider(smoothIterationCount, 1, 10, new GUIContent("Smoothing Strength")); //to determine how many iteration of the smooth function is called

            if (GUILayout.Button("Apply Smooth"))                                                         //if apply button is pressed
            {
                terrain.ApplySmooth();                                                                    //call corresponding function
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalScrollbar); //putting a line to separate the sections in the UI

        //creating a button for resetting the terain here
        if (GUILayout.Button("Reset Terrain")) //if apply button is pressed
        {
            terrain.ResetTerrain();            //call corresponding function
        }

        showHeightMapEnabled = EditorGUILayout.Foldout(showHeightMapEnabled, "Display Terrain HeightMap"); //if foldout clicked
        if (showHeightMapEnabled)
        {
            //set up UI
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            int heightMapTextureSize = (int)(EditorGUIUtility.currentViewWidth - 100);
            GUILayout.Label(heightMapTexture, GUILayout.Width(heightMapTextureSize), GUILayout.Height(heightMapTextureSize));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            //on refresh, process and load the heightmap
            if (GUILayout.Button("Refresh", GUILayout.Width(heightMapTextureSize)))
            {
                float[,] heightMap = terrain.tData.GetHeights(0, 0, terrain.tData.heightmapWidth, terrain.tData.heightmapHeight); //get heightmap data

                //go through all points
                for (int h = 0; h < terrain.tData.heightmapHeight; h++)
                {
                    for (int w = 0; w < terrain.tData.heightmapWidth; w++)
                    {
                        heightMapTexture.SetPixel(w, h, new Color(heightMap[w, h], heightMap[w, h], heightMap[w, h], 1));  //set the pixels for all channels and 1 for alpha
                    }
                }

                heightMapTexture.Apply(); //apply changes
            }

            //additional UI setup
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }

        //CLEAN-UP FOR SCROLLBAR CODE
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();

        serializedObject.ApplyModifiedProperties(); //applies any changes that are made (changes applied instantly in display loop)
    }
예제 #2
0
    void DrawEffect(int id)
    {
        if (!(id < mData.AnimationSkillList.Count))
        {
            return;
        }

        for (int i = 0; i < mData.AnimationSkillList[id].EffectStructList.Count; i++)
        {
            EffectStruct _eff = mData.AnimationSkillList[id].EffectStructList[i];

            EditorGUI.indentLevel++;
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            string _titleName = _eff.Effect ? _eff.Effect.name : "Effect" + (i + 1).ToString();
            EditorGUILayout.BeginHorizontal();
            //此子特效的界面折叠
            _eff.isFoldout = EditorGUILayout.Foldout(_eff.isFoldout, _titleName);
            GUILayout.FlexibleSpace();
            //此子特效是否可用
            _eff.isEnabled = EditorGUILayout.Toggle("", _eff.isEnabled);

            if (GUILayout.Button("DELETE"))
            {
                mData.AnimationSkillList[id].EffectStructList.Remove(_eff);
                return;
            }

            EditorGUILayout.EndHorizontal();

            mData.AnimationSkillList[id].EffectStructList[i] = _eff;

            if (_eff.isFoldout)
            {
                EditorGUI.BeginDisabledGroup(!_eff.isEnabled);
                _eff.Effect = (GameObject)EditorGUILayout.ObjectField("Effect", _eff.Effect, typeof(GameObject), true);

                string[] _nameArry = mData.VirtualPointList.ToArray();
                _eff.VirtualPointID   = EditorGUILayout.Popup("Virtual Point", _eff.VirtualPointID, _nameArry);
                _eff.VirtualPointName = _nameArry[_eff.VirtualPointID];

                _eff.Offset    = EditorGUILayout.Vector3Field("Offset", _eff.Offset);
                _eff.Rotate    = EditorGUILayout.Vector3Field("Rotate", _eff.Rotate);
                _eff.IsFollow  = EditorGUILayout.Toggle("Is Follow", _eff.IsFollow);
                _eff.DelayTime = EditorGUILayout.FloatField("Delay Time", _eff.DelayTime);
                _eff.LifeTime  = EditorGUILayout.FloatField("Life Time", _eff.LifeTime);

                if (_eff.DelayTime > mData.AnimationSkillList[id].fTime)
                {
                    _eff.DelayTime = mData.AnimationSkillList [id].fTime;
                }

                mData.AnimationSkillList[id].EffectStructList[i] = _eff;
            }
            EditorGUI.EndDisabledGroup();


            EditorGUILayout.EndVertical();
            EditorGUI.indentLevel--;
        }
    }
    /// <summary>
    /// Draw the UI for this tool.
    /// </summary>

    void OnGUI()
    {
        string prefabPath = "";
        string matPath    = "";

        if (NGUISettings.font != null && NGUISettings.font.name == NGUISettings.fontName)
        {
            prefabPath = AssetDatabase.GetAssetPath(NGUISettings.font.gameObject.GetInstanceID());
            if (NGUISettings.font.material != null)
            {
                matPath = AssetDatabase.GetAssetPath(NGUISettings.font.material.GetInstanceID());
            }
        }

        // Assume default values if needed
        if (string.IsNullOrEmpty(NGUISettings.fontName))
        {
            NGUISettings.fontName = "New Font";
        }
        if (string.IsNullOrEmpty(prefabPath))
        {
            prefabPath = NGUIEditorTools.GetSelectionFolder() + NGUISettings.fontName + ".prefab";
        }
        if (string.IsNullOrEmpty(matPath))
        {
            matPath = NGUIEditorTools.GetSelectionFolder() + NGUISettings.fontName + ".mat";
        }

        NGUIEditorTools.SetLabelWidth(80f);
        NGUIEditorTools.DrawHeader("Input", true);
        NGUIEditorTools.BeginContents();

        GUILayout.BeginHorizontal();
        mType = (FontType)EditorGUILayout.EnumPopup("Type", mType);
        GUILayout.Space(18f);
        GUILayout.EndHorizontal();
        int create = 0;

        if (mType == FontType.Dynamic)
        {
            NGUISettings.dynamicFont = EditorGUILayout.ObjectField("Font TTF", NGUISettings.dynamicFont, typeof(Font), false) as Font;

            GUILayout.BeginHorizontal();
            NGUISettings.dynamicFontSize  = EditorGUILayout.IntField("Font Size", NGUISettings.dynamicFontSize, GUILayout.Width(120f));
            NGUISettings.dynamicFontStyle = (FontStyle)EditorGUILayout.EnumPopup(NGUISettings.dynamicFontStyle);
            GUILayout.Space(18f);
            GUILayout.EndHorizontal();
            NGUIEditorTools.EndContents();

            if (NGUISettings.dynamicFont != null)
            {
                NGUIEditorTools.DrawHeader("Output", true);

                NGUIEditorTools.BeginContents();
                GUILayout.BeginHorizontal();
                GUILayout.Label("Font Name", GUILayout.Width(76f));
                GUI.backgroundColor   = Color.white;
                NGUISettings.fontName = GUILayout.TextField(NGUISettings.fontName);

#if !UNITY_3_5
                if (NGUISettings.dynamicFont != null)
                {
                    GameObject go = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;

                    if (go != null)
                    {
                        if (go.GetComponent <UIFont>() != null)
                        {
                            GUI.backgroundColor = Color.red;
                            if (GUILayout.Button("Replace", GUILayout.Width(70f)))
                            {
                                create = 1;
                            }
                        }
                        else
                        {
                            GUI.backgroundColor = Color.grey;
                            GUILayout.Button("Rename", GUILayout.Width(70f));
                        }
                    }
                    else
                    {
                        GUI.backgroundColor = Color.green;
                        if (GUILayout.Button("Create", GUILayout.Width(70f)))
                        {
                            create = 1;
                        }
                    }

                    GUI.backgroundColor = Color.white;
                }
#endif
                GUILayout.EndHorizontal();
                NGUIEditorTools.EndContents();
            }

#if UNITY_3_5
            EditorGUILayout.HelpBox("Dynamic fonts require Unity 4.0 or higher.", MessageType.Error);
#else
            // Helpful info
            if (NGUISettings.dynamicFont == null)
            {
                EditorGUILayout.HelpBox("Dynamic font creation happens right in Unity. Simply specify the TrueType font to be used as source.", MessageType.Info);
            }
            EditorGUILayout.HelpBox("Please note that dynamic fonts can't be made a part of an atlas, and using dynamic fonts will result in at least one extra draw call.", MessageType.Warning);
#endif
        }
        else
        {
            NGUISettings.fontData    = EditorGUILayout.ObjectField("Font Data", NGUISettings.fontData, typeof(TextAsset), false) as TextAsset;
            NGUISettings.fontTexture = EditorGUILayout.ObjectField("Texture", NGUISettings.fontTexture, typeof(Texture2D), false) as Texture2D;
            NGUIEditorTools.EndContents();

            // Draw the atlas selection only if we have the font data and texture specified, just to make it easier
            if (NGUISettings.fontData != null && NGUISettings.fontTexture != null)
            {
                NGUIEditorTools.DrawHeader("Output", true);
                NGUIEditorTools.BeginContents();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Font Name", GUILayout.Width(76f));
                GUI.backgroundColor   = Color.white;
                NGUISettings.fontName = GUILayout.TextField(NGUISettings.fontName);
                GUILayout.EndHorizontal();

                ComponentSelector.Draw <UIFont>("Select", NGUISettings.font, OnSelectFont);
                ComponentSelector.Draw <UIAtlas>(NGUISettings.atlas, OnSelectAtlas);
                NGUIEditorTools.EndContents();
            }

            // Helpful info
            if (NGUISettings.fontData == null)
            {
                EditorGUILayout.HelpBox("The bitmap font creation mostly takes place outside of Unity. You can use BMFont on " +
                                        "Windows or your choice of Glyph Designer or the less expensive bmGlyph on the Mac.\n\n" +
                                        "Either of these tools will create a FNT file for you that you will drag & drop into the field above.", MessageType.Info);
            }
            else if (NGUISettings.fontTexture == null)
            {
                EditorGUILayout.HelpBox("When exporting your font, you should get two files: the TXT, and the texture. Only one texture can be used per font.", MessageType.Info);
            }
            else if (NGUISettings.atlas == null)
            {
                EditorGUILayout.HelpBox("You can create a font that doesn't use a texture atlas. This will mean that the text " +
                                        "labels using this font will generate an extra draw call, and will need to be sorted by " +
                                        "adjusting the Z instead of the Depth.\n\nIf you do specify an atlas, the font's texture will be added to it automatically.", MessageType.Info);

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.backgroundColor = Color.red;
                if (GUILayout.Button("Create a Font without an Atlas", GUILayout.Width(200f)))
                {
                    create = 2;
                }
                GUI.backgroundColor = Color.white;
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                GameObject go = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;

                if (go != null)
                {
                    if (go.GetComponent <UIFont>() != null)
                    {
                        GUI.backgroundColor = Color.red;
                        if (GUILayout.Button("Replace the Font", GUILayout.Width(140f)))
                        {
                            create = 3;
                        }
                    }
                    else
                    {
                        GUI.backgroundColor = Color.grey;
                        GUILayout.Button("Rename Your Font", GUILayout.Width(140f));
                    }
                }
                else
                {
                    GUI.backgroundColor = Color.green;
                    if (GUILayout.Button("Create the Font", GUILayout.Width(140f)))
                    {
                        create = 3;
                    }
                }
                GUI.backgroundColor = Color.white;
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
        }

        if (create != 0)
        {
            GameObject go = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;

            if (go == null || EditorUtility.DisplayDialog("Are you sure?", "Are you sure you want to replace the contents of the " +
                                                          NGUISettings.fontName + " font with the currently selected values? This action can't be undone.", "Yes", "No"))
            {
                // Try to load the material
                Material mat = null;

                // Non-atlased font
                if (create == 2)
                {
                    mat = AssetDatabase.LoadAssetAtPath(matPath, typeof(Material)) as Material;

                    // If the material doesn't exist, create it
                    if (mat == null)
                    {
                        Shader shader = Shader.Find("Unlit/Transparent Colored");
                        mat = new Material(shader);

                        // Save the material
                        AssetDatabase.CreateAsset(mat, matPath);
                        AssetDatabase.Refresh();

                        // Load the material so it's usable
                        mat = AssetDatabase.LoadAssetAtPath(matPath, typeof(Material)) as Material;
                    }
                    mat.mainTexture = NGUISettings.fontTexture;
                }
                else if (create != 1)
                {
                    UIAtlasMaker.AddOrUpdate(NGUISettings.atlas, NGUISettings.fontTexture);
                }

                // Font doesn't exist yet
                if (go == null || go.GetComponent <UIFont>() == null)
                {
                    // Create a new prefab for the atlas
                    Object prefab = PrefabUtility.CreateEmptyPrefab(prefabPath);

                    // Create a new game object for the font
                    go = new GameObject(NGUISettings.fontName);
                    NGUISettings.font = go.AddComponent <UIFont>();
                    CreateFont(NGUISettings.font, create, mat);

                    // Update the prefab
                    PrefabUtility.ReplacePrefab(go, prefab);
                    DestroyImmediate(go);
                    AssetDatabase.Refresh();

                    // Select the atlas
                    go = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;
                    NGUISettings.font = go.GetComponent <UIFont>();
                }
                else
                {
                    NGUISettings.font = go.GetComponent <UIFont>();
                    CreateFont(NGUISettings.font, create, mat);
                }
                MarkAsChanged();
            }
        }
    }
예제 #4
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            if (m_groupSizeByte == null)
            {
                return;
            }

            EditorGUILayout.HelpBox("Grouping by size: Create group of assets by size.", MessageType.Info);
            editor.UpdateNodeName(node);

            GUILayout.Space(10f);

            //Show target configuration tab
            editor.DrawPlatformSelector(node);
            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                var disabledScope = editor.DrawOverrideTargetToggle(node, m_groupSizeByte.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) => {
                    using (new RecordUndoScope("Remove Target Grouping Size Settings", node, true)){
                        if (enabled)
                        {
                            m_groupSizeByte[editor.CurrentEditingGroup]   = m_groupSizeByte.DefaultValue;
                            m_groupingType[editor.CurrentEditingGroup]    = m_groupingType.DefaultValue;
                            m_groupNameFormat[editor.CurrentEditingGroup] = m_groupNameFormat.DefaultValue;
                        }
                        else
                        {
                            m_groupSizeByte.Remove(editor.CurrentEditingGroup);
                            m_groupingType.Remove(editor.CurrentEditingGroup);
                            m_groupNameFormat.Remove(editor.CurrentEditingGroup);
                        }
                        onValueChanged();
                    }
                });

                using (disabledScope) {
                    var newType = (GroupingType)EditorGUILayout.EnumPopup("Grouping Type", (GroupingType)m_groupingType[editor.CurrentEditingGroup]);
                    if (newType != (GroupingType)m_groupingType[editor.CurrentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Grouping Type", node, true)){
                            m_groupingType[editor.CurrentEditingGroup] = (int)newType;
                            onValueChanged();
                        }
                    }

                    var newSizeText = EditorGUILayout.TextField("Size(KB)", m_groupSizeByte[editor.CurrentEditingGroup].ToString());
                    int newSize     = 0;
                    Int32.TryParse(newSizeText, out newSize);

                    if (newSize != m_groupSizeByte[editor.CurrentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Grouping Size", node, true)){
                            m_groupSizeByte[editor.CurrentEditingGroup] = newSize;
                            onValueChanged();
                        }
                    }

                    var newGroupNameFormat = EditorGUILayout.TextField("Group Name Format", m_groupNameFormat [editor.CurrentEditingGroup]);
                    EditorGUILayout.HelpBox(
                        "You can customize group name. You can use variable {OldGroup} for old group name and {NewGroup} for current matching name.",
                        MessageType.Info);

                    if (newGroupNameFormat != m_groupNameFormat [editor.CurrentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Group Name", node, true)) {
                            m_groupNameFormat [editor.CurrentEditingGroup] = newGroupNameFormat;
                            onValueChanged();
                        }
                    }
                }
            }

            var newFreezeGroups = EditorGUILayout.ToggleLeft("Freeze group on build", m_freezeGroups);

            if (newFreezeGroups != m_freezeGroups)
            {
                using (new RecordUndoScope("Change Freeze Groups", node, true)){
                    m_freezeGroups = newFreezeGroups;
                    onValueChanged();
                }
            }
            EditorGUILayout.HelpBox("Freezing group will save group when build is performed, and any new asset from there will be put into new group.",
                                    MessageType.Info);
            using (new GUILayout.HorizontalScope()) {
                GUILayout.Label("Group setting");
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Import"))
                {
                    if (ImportGroupsWithGUI(node))
                    {
                        onValueChanged();
                    }
                }
                if (GUILayout.Button("Export"))
                {
                    ExportGroupsWithGUI(node);
                }
                if (GUILayout.Button("Reset"))
                {
                    if (EditorUtility.DisplayDialog("Do you want to reset group setting?", "This will erase current saved group setting.", "OK", "Cancel"))
                    {
                        m_savedGroups = null;
                        onValueChanged();
                    }
                }
            }
            GUILayout.Space(8f);

            if (m_groupViewController != null)
            {
                m_groupViewController.OnGroupViewGUI();
            }
        }
        static void OnPostHeaderGUI(Editor editor)
        {
            var aaSettings = AddressableAssetSettingsDefaultObject.Settings;
            AddressableAssetEntry entry = null;

            if (editor.targets.Length > 0)
            {
                int  addressableCount = 0;
                bool foundValidAsset  = false;
                bool foundAssetGroup  = false;
                foreach (var t in editor.targets)
                {
                    foundAssetGroup |= t is AddressableAssetGroup;
                    foundAssetGroup |= t is AddressableAssetGroupSchema;
                    if (AddressableAssetUtility.GetPathAndGUIDFromTarget(t, out var path, out var guid, out var mainAssetType))
                    {
                        // Is asset
                        if (!BuildUtility.IsEditorAssembly(mainAssetType.Assembly))
                        {
                            foundValidAsset = true;

                            if (aaSettings != null)
                            {
                                entry = aaSettings.FindAssetEntry(guid);
                                if (entry != null && !entry.IsSubAsset)
                                {
                                    addressableCount++;
                                }
                            }
                        }
                    }
                }

                if (foundAssetGroup)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Profile: " + AddressableAssetSettingsDefaultObject.GetSettings(true).profileSettings.
                                    GetProfileName(AddressableAssetSettingsDefaultObject.GetSettings(true).activeProfileId));

                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("System Settings", "MiniButton"))
                    {
                        EditorGUIUtility.PingObject(AddressableAssetSettingsDefaultObject.Settings);
                        Selection.activeObject = AddressableAssetSettingsDefaultObject.Settings;
                    }
                    GUILayout.EndHorizontal();
                }

                if (!foundValidAsset)
                {
                    return;
                }

                if (addressableCount == 0)
                {
                    if (GUILayout.Toggle(false, s_AddressableAssetToggleText, GUILayout.ExpandWidth(false)))
                    {
                        SetAaEntry(AddressableAssetSettingsDefaultObject.GetSettings(true), editor.targets, true);
                    }
                }
                else if (addressableCount == editor.targets.Length)
                {
                    GUILayout.BeginHorizontal();
                    if (!GUILayout.Toggle(true, s_AddressableAssetToggleText, GUILayout.ExpandWidth(false)))
                    {
                        SetAaEntry(aaSettings, editor.targets, false);
                        GUIUtility.ExitGUI();
                    }

                    if (editor.targets.Length == 1 && entry != null)
                    {
                        string newAddress = EditorGUILayout.DelayedTextField(entry.address, GUILayout.ExpandWidth(true));
                        if (newAddress != entry.address)
                        {
                            if (newAddress.Contains("[") && newAddress.Contains("]"))
                            {
                                Debug.LogErrorFormat("Rename of address '{0}' cannot contain '[ ]'.", entry.address);
                            }
                            else
                            {
                                entry.address = newAddress;
                                AddressableAssetUtility.OpenAssetIfUsingVCIntegration(entry.parentGroup, true);
                            }
                        }
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    if (s_ToggleMixed == null)
                    {
                        s_ToggleMixed = new GUIStyle("ToggleMixed");
                    }
                    if (GUILayout.Toggle(false, s_AddressableAssetToggleText, s_ToggleMixed, GUILayout.ExpandWidth(false)))
                    {
                        SetAaEntry(AddressableAssetSettingsDefaultObject.GetSettings(true), editor.targets, true);
                    }
                    EditorGUILayout.LabelField(addressableCount + " out of " + editor.targets.Length + " assets are addressable.");
                    GUILayout.EndHorizontal();
                }
            }
        }
예제 #6
0
    void OnGUI()
    {
        GUI.skin = customSkin;

        if (showSpecials)
        {
            GUI.skin.label.fontSize = 14;
        }
        else
        {
            GUI.skin.label.fontSize = 20;
        }

        if (showControls && UFE.isPaused())
        {
            GUI.BeginGroup(new Rect(Screen.width / 2 - 250, Screen.height / 2 - 200, 500, 400)); {
                GUI.Box(new Rect(0, 0, 500, 400), "Options");
                GUI.BeginGroup(new Rect(15, 0, 480, 400)); {
                    GUILayoutUtility.GetRect(1, 25, GUILayout.Width(470));
                    if (showSpecials)
                    {
                        GUILayout.Label("Fireball - Down, Forward, Punch (any)");
                        GUILayout.Label("Dragon Punch - Forward, Down, Forward, Punch (any)");
                        GUILayout.Label("Super Fireball - Down, Forward, Down, Forward, Light Punch");
                        GUILayout.Label("Super Dragon Punch - Down, Forward, Down, Forward, Medium Punch");
                        GUILayout.Label("Custom Combo 1:");
                        GUILayout.Label("Light Punch, Light Kick, Medium Kick, Heavy Kick");
                        GUILayout.Label("Custom Combo 2:");
                        GUILayout.Label("Light Punch, Heavy Dragon Punch");
                        GUILayout.Label("Custom Combo 3:");
                        GUILayout.Label("Crouching Light Punch, Crouching Light Kick, Crouching Medium Punch,");
                        GUILayout.Label("Crouching Medium Kick, Crouching Heavy Kick");
                        GUILayout.Label("Custom Combo 4:");
                        GUILayout.Label("Crouching Medium Kick, Crouching Heavy Punch, Jump, Medium Kick,");
                        GUILayout.Label("Medium Punch, (land) Crouching Heavy Punch, Super Fireball");
                    }
                    else
                    {
                        GUILayout.BeginHorizontal(); {
                            GUILayout.Label("Player 1");
                            GUILayout.FlexibleSpace();
                            GUILayout.Label("Player 2");
                        } GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal(); {
                            GUILayout.Label("Controls - W A S D");
                            GUILayout.FlexibleSpace();
                            GUILayout.Label("Controls - Arrow Keys");
                        } GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(); {
                            GUILayout.Label("Light Punch - T");
                            GUILayout.FlexibleSpace();
                            GUILayout.Label("Light Punch - Insert");
                        } GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(); {
                            GUILayout.Label("Light Kick - G");
                            GUILayout.FlexibleSpace();
                            GUILayout.Label("Light Kick - Delete");
                        } GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(); {
                            GUILayout.Label("Medium Punch - Y");
                            GUILayout.FlexibleSpace();
                            GUILayout.Label("Medium Punch - Home");
                        } GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(); {
                            GUILayout.Label("Medium Kick - H");
                            GUILayout.FlexibleSpace();
                            GUILayout.Label("Medium Kick - End");
                        } GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(); {
                            GUILayout.Label("Heavy Punch - U");
                            GUILayout.FlexibleSpace();
                            GUILayout.Label("Heavy Punch - Page Up");
                        } GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(); {
                            GUILayout.Label("Heavy Kick - J");
                            GUILayout.FlexibleSpace();
                            GUILayout.Label("Heavy Kick - Page Down");
                        } GUILayout.EndHorizontal();
                    }

                    GUILayoutUtility.GetRect(1, 5);
                    GUILayout.BeginHorizontal(); {
                        if (showSpecials)
                        {
                            if (GUILayout.Button("Controls"))
                            {
                                showSpecials = false;
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("Specials"))
                            {
                                showSpecials = true;
                            }
                        }
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Back"))
                        {
                            showControls = false;
                        }
                    } GUILayout.EndHorizontal();
                } GUI.EndGroup();
            } GUI.EndGroup();
        }
        else if (!showEndMenu && UFE.isPaused())
        {
            GUI.BeginGroup(new Rect(Screen.width / 2 - 200, Screen.height / 2 - 130, 400, 260)); {
                GUI.Box(new Rect(0, 0, 400, 260), "Options");
                GUI.BeginGroup(new Rect(15, 0, 380, 260)); {
                    GUILayoutUtility.GetRect(1, 45);

                    GUILayout.BeginHorizontal(); {
                        GUILayout.Label("Music", GUILayout.Width(240));
                        if (UFE.GetMusic())
                        {
                            if (GUILayout.Button("On", GUILayout.Width(120)))
                            {
                                UFE.SetMusic(false);
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("Off", GUILayout.Width(120)))
                            {
                                UFE.SetMusic(true);
                            }
                        }
                    } GUILayout.EndHorizontal();

                    if (UFE.GetMusic())
                    {
                        GUILayout.BeginHorizontal(); {
                            GUILayout.Label("Music Volume", GUILayout.Width(240));
                            UFE.SetVolume(GUILayout.HorizontalSlider(UFE.GetVolume(), 0, 1, GUILayout.Width(120)));
                        } GUILayout.EndHorizontal();
                    }
                    else
                    {
                        GUILayoutUtility.GetRect(1, 34);
                    }

                    GUILayout.BeginHorizontal(); {
                        GUILayout.Label("Sound FX", GUILayout.Width(240));
                        if (UFE.GetSoundFX())
                        {
                            if (GUILayout.Button("On", GUILayout.Width(120)))
                            {
                                UFE.SetSoundFX(false);
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("Off", GUILayout.Width(120)))
                            {
                                UFE.SetSoundFX(true);
                            }
                        }
                    } GUILayout.EndHorizontal();

                    GUILayoutUtility.GetRect(1, 30);

                    GUILayout.BeginHorizontal(); {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Controls", GUILayout.Width(200)))
                        {
                            showControls = true;
                        }
                        GUILayout.FlexibleSpace();
                    } GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(); {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Special Moves", GUILayout.Width(200)))
                        {
                            showSpecials = true;
                            showControls = true;
                        }
                        GUILayout.FlexibleSpace();
                    } GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(); {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Main Menu", GUILayout.Width(200)))
                        {
                            UFE.StartIntro(2);
                            showEndMenu = false;
                            Destroy(mainAlertGO);
                        }
                        GUILayout.FlexibleSpace();
                    } GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(); {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Close"))
                        {
                            UFE.PauseGame(false);
                        }
                        GUILayout.FlexibleSpace();
                    } GUILayout.EndHorizontal();
                } GUI.EndGroup();
            } GUI.EndGroup();
        }

        if (showEndMenu)
        {
            GUI.BeginGroup(new Rect(Screen.width / 2 - 100, Screen.height / 2 + 20, 200, 130)); {
                GUI.Box(new Rect(0, 0, 200, 100), ""); {
                    GUILayoutUtility.GetRect(1, 2);

                    /*GUILayout.BeginHorizontal();{ // Not functional
                     *      GUILayout.FlexibleSpace();
                     *      if (GUILayout.Button("Rematch", GUILayout.Width(200))) {
                     *              UFE.StartGame(2);
                     *              showMenu = false;
                     *              Destroy(mainAlertGO);
                     *      }
                     *      GUILayout.FlexibleSpace();
                     * }GUILayout.EndHorizontal();*/

                    GUILayoutUtility.GetRect(1, 20);
                    GUILayout.BeginHorizontal(); {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Character Select", GUILayout.Width(200)))
                        {
                            UFE.StartCharacterSelect(2);
                            showEndMenu = false;
                            Destroy(mainAlertGO);
                        }
                        GUILayout.FlexibleSpace();
                    } GUILayout.EndHorizontal();

                    GUILayoutUtility.GetRect(1, 20);
                    GUILayout.BeginHorizontal(); {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Main Menu", GUILayout.Width(200)))
                        {
                            UFE.StartIntro(2);
                            showEndMenu = false;
                            Destroy(mainAlertGO);
                        }
                        GUILayout.FlexibleSpace();
                    } GUILayout.EndHorizontal();
                }
            } GUI.EndGroup();
        }

        if (!isRunning)
        {
            return;
        }
        // Draw the lifebars and gauge bars using the data stored in UFE.config.guiOptions
        DrawBar(UFE.config.guiOptions.lifeBarOptions1, Side.Left, player1TargetLife, player1TotalLife, true);
        DrawBar(UFE.config.guiOptions.lifeBarOptions2, Side.Right, player2TargetLife, player2TotalLife, true);

        DrawBar(UFE.config.guiOptions.gaugeBarOptions1, Side.Left,
                UFE.config.player1Character.currentGaugePoints, UFE.config.player2Character.maxGaugePoints, false);
        DrawBar(UFE.config.guiOptions.gaugeBarOptions1, Side.Right,
                UFE.config.player2Character.currentGaugePoints, UFE.config.player2Character.maxGaugePoints, false);
    }
예제 #7
0
    public override void OnInspectorGUI()
    {
        this.serializedObject.Update();
        Object[] targetObjs = this.serializedObject.targetObjects;

        WaitForAlignmentModifier curEditTarget;

        GUIContent content;

        EditorGUIUtility.labelWidth = PGEditorUtils.CONTROLS_DEFAULT_LABEL_WIDTH;

        EditorGUI.indentLevel = 0;


        EditorGUI.BeginChangeCheck();
        content = new GUIContent
                  (
            "Origin",
            "The transform used to determine alignment. If not used, this will be the transform " +
            "of the GameObject this component is attached to."
                  );
        EditorGUILayout.PropertyField(this.origin, content);

        // If changed, trigger the property setter for all objects being edited
        if (EditorGUI.EndChangeCheck())
        {
            for (int i = 0; i < targetObjs.Length; i++)
            {
                curEditTarget = (WaitForAlignmentModifier)targetObjs[i];

                Undo.RecordObject(curEditTarget, targetObjs[0].GetType() + " origin");

                curEditTarget.origin = (Transform)this.origin.objectReferenceValue;
            }
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUIUtility.labelWidth = 106;

        content = new GUIContent
                  (
            "Angle Tolerance",
            "If waitForAlignment is true: If the emitter is pointing towards " +
            "the target within this angle in degrees, the target can be fired on."
                  );
        EditorGUILayout.PropertyField(this.angleTolerance, content);
        EditorGUIUtility.labelWidth = PGEditorUtils.CONTROLS_DEFAULT_LABEL_WIDTH;


        content = new GUIContent
                  (
            "Flat Comparison",
            "If false the actual angles will be compared for alignment. " +
            "(More precise. Emitter must point at target.)\n" +
            "If true, only the direction matters. " +
            "(Good when turning in a direction but perfect alignment isn't needed.)"
                  );
        PGEditorUtils.ToggleButton(this.flatAngleCompare, content, 88);

        EditorGUILayout.EndHorizontal();

        if (this.flatAngleCompare.boolValue)
        {
            EditorGUI.indentLevel += 1;
            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();              // To make the rest of the row right-justified

            content = new GUIContent
                      (
                "Flatten Axis",
                "The axis to flatten when comparing angles to see if alignment has occurred. " +
                "For example, for a 2D game, this should be Z. For a 3D game that wants to " +
                "ignore altitude, set this to Y."
                      );

            EditorGUILayout.PropertyField(this.flatCompareAxis, content, GUILayout.Width(228));

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


        GUILayout.Space(4);

        content = new GUIContent
                  (
            "Debug Level", "Set it higher to see more verbose information."
                  );
        EditorGUILayout.PropertyField(this.debugLevel, content);

        serializedObject.ApplyModifiedProperties();

        // Flag Unity to save the changes to to the prefab to disk
        //   This is needed to make the gizmos update immediatly.
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
예제 #8
0
        /// <summary>
        /// On GUI draw call.
        /// </summary>
        protected virtual void OnGUI()
        {
            // Label style
            labelFormat           = new GUIStyle();
            labelFormat.alignment = TextAnchor.MiddleCenter;
            labelFormat.fontSize  = 12;

            // Label error style
            errorFormat = new GUIStyle(labelFormat);
            errorFormat.normal.textColor = Color.red;

            // Input style
            inputFormat             = new GUIStyle(GUI.skin.textField);
            inputFormat.alignment   = TextAnchor.LowerCenter;
            inputFormat.fontSize    = 12;
            inputFormat.fixedHeight = 20;

            // Button style
            buttonFormat            = new GUIStyle(GUI.skin.button);
            buttonFormat.alignment  = TextAnchor.MiddleCenter;
            buttonFormat.fixedWidth = 100;


            // Name
            GUILayout.Space(10f);
            EditorGUILayout.LabelField("Enter a name for this controller:", labelFormat);
            GUILayout.Space(10f);

            // Input
            tempName = EditorGUILayout.TextField(tempName, inputFormat);
            GUILayout.Space(14f);

            // Error
            EditorGUILayout.LabelField(errorString, errorFormat);
            GUILayout.Space(20f);

            // Buttons
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            // Cancel button
            if (GUILayout.Button("Cancel", buttonFormat))
            {
                NewControllerWindow.window.Close();
            }

            GUILayout.FlexibleSpace();

            // Create new controller
            if (GUILayout.Button("OK", buttonFormat))
            {
                // Check length
                if (tempName.Length >= 3)
                {
                    // Check for special chars
                    if (!namingConventions.Match(tempName).Success)
                    {
                        JObject controller = new JObject();
                        controller.Add("name", tempName);
                        controller.Add("views", new JObject());

                        FileManager.WriteJSON(controller, String.Format("{0:G}{1:G}/data/controller/{2:G}.json", Application.dataPath, Config.WebServerPath, tempName));

                        // Fire controller created event
                        if (ControllerCreated != null)
                        {
                            ControllerCreated(tempName);
                        }

                        NewControllerWindow.window.Close();
                    }
                    else
                    {
                        errorString = "The controller name must not have any special characters\nwith the exception of '-' and '_'.";
                    }
                }
                else
                {
                    errorString = "The controller name must be at least three characters long.";
                }
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }
예제 #9
0
    void DrawField(vlbField field)
    {
        if (field.type == vlbFieldType.Unknown)
        {
            return;
        }

        switch (field.type)
        {
        case vlbFieldType.HzBegin: GUILayout.BeginHorizontal();          break;

        case vlbFieldType.HzEnd: GUILayout.EndHorizontal();            break;

        case vlbFieldType.VtBegin: GUILayout.BeginVertical();            break;

        case vlbFieldType.VtEnd: GUILayout.EndVertical();              break;

        case vlbFieldType.Space: GUILayout.Space((float)field.value);  break;

        case vlbFieldType.FlexibleSpace: GUILayout.FlexibleSpace();            break;

        case vlbFieldType.Int: {
            var val    = (int)field.value;
            var newVal = EditorGUILayout.IntField(field.title, val);
            if (val != newVal)
            {
                EditorPrefs.SetInt(formId + "." + field.varName, newVal);
            }

            field.value = newVal;
        }
        break;

        case vlbFieldType.Bool:
            field.value = EditorGUILayout.ToggleLeft(field.title, (bool)field.value, GUILayout.Width(data.titleWidth));
            break;

        case vlbFieldType.Float:
            field.value = EditorGUILayout.FloatField(field.title, (float)field.value);
            break;

        case vlbFieldType.String:
            field.value = EditorGUILayout.TextField(field.title, (string)field.value);
            break;

        case vlbFieldType.Color:
            field.value = EditorGUILayout.ColorField(field.title, (Color)field.value);
            break;

        case vlbFieldType.Vector2:
            field.value = EditorGUILayout.Vector2Field(field.title, (Vector2)field.value);
            break;

        case vlbFieldType.Vector3:
            field.value = EditorGUILayout.Vector3Field(field.title, (Vector3)field.value);
            break;

        case vlbFieldType.Rect:
            field.value = EditorGUILayout.RectField(field.title, (Rect)field.value);
            break;

        case vlbFieldType.Enum:
            field.value = EditorGUILayout.EnumPopup(field.title, (Enum)field.value);
            break;
        }
    }
    //This is the Main view with all shader controlls
    private void MainView(MaterialEditor materialEditor)
    {
        CheckIsShadowy(_matTarget);

        GUILayout.Space(5f);

        switch (_setPanel)
        {
        case SettingsMode.Sprites:
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            ButtonOpenUrl(_btnHelp, "http://wiki.next-gen-sprites.com/doku.php?id=shaders:feature:sprite");
            GUILayout.Space(10f);
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5f);

            materialEditor.TextureProperty(_mainSprite, "Sprite", scaleOffset: false);

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

            GUILayout.BeginHorizontal();
            materialEditor.ColorProperty(_mainSpriteTint, "Tint");
            if (GUILayout.Button("Reset Tint"))
            {
                _matTarget.SetColor(ShaderColor.Sprite.GetString(), Color.white);
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(15f);

            ToggleFeature(_matTarget, "Hue Shift", ShaderFeature.HueShift, disableGroup: true);

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            ButtonOpenUrl(_btnHelp, "http://wiki.next-gen-sprites.com/doku.php?id=shaders:feature:sprite#hue_shift");
            GUILayout.Space(10f);
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(5f);

            var hsbcTemp = _HSBC.vectorValue;

            hsbcTemp.x = EditorGUILayout.Slider("Hue", hsbcTemp.x, 0f, 1f);
            hsbcTemp.y = EditorGUILayout.Slider("Saturation", hsbcTemp.y, 0f, 1f);
            hsbcTemp.z = EditorGUILayout.Slider("Brightness", hsbcTemp.z, 0f, 1f);
            hsbcTemp.w = EditorGUILayout.Slider("Contrast", hsbcTemp.w, 0f, 1f);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Reset Hue"))
            {
                hsbcTemp = new Vector4(0f, 0.5f, 0.5f, 0.5f);
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            _HSBC.vectorValue = hsbcTemp;

            EditorGUI.EndDisabledGroup();

            ToggleFeature(_matTarget, "Main Layer Scrolling", ShaderFeature.SpriteScrolling);
            GUILayout.Space(5f);
            materialEditor.RangeProperty(_spriteLayer1ScrollingX, "X-Axis");
            materialEditor.RangeProperty(_spriteLayer1ScrollingY, "Y-Axis");
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Reset Scrolling"))
            {
                _matTarget.SetFloat(ShaderFloat.SpriteLayer0ScrollingX.GetString(), 0f);
                _matTarget.SetFloat(ShaderFloat.SpriteLayer0ScrollingY.GetString(), 0f);
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            EditorGUI.EndDisabledGroup();


            GUILayout.Space(5f);

            DrawWideBox();
            GUILayout.Space(5f);
            ToggleFeature(_matTarget, "Multi Layer", ShaderFeature.SpriteMultiLayer, disableGroup: false);
            if (_matTarget.IsKeywordEnabled(ShaderFeature.SpriteMultiLayer.GetString()))
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                ButtonOpenUrl(_btnHelp, "http://wiki.next-gen-sprites.com/doku.php?id=shaders:feature:sprite#multi_layer");
                GUILayout.Space(10f);
                EditorGUILayout.EndHorizontal();

                ToggleFeature(_matTarget, "Stencil Mask", ShaderFeature.SpriteStencil, disableGroup: true);
                materialEditor.TextureProperty(_spriteLayerStencil, "Stencil Mask");
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                EditorGUILayout.HelpBox("Red: Layer 1# | Green: Layer 2# | Blue: Layer 3#", MessageType.None);
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
                DrawWideBox();
                EditorGUI.EndDisabledGroup();

                GUILayout.Box("Layer 1#", EditorStyles.miniButton);
                materialEditor.TextureProperty(_spriteLayer2Tex, "Sprite");
                GUILayout.Space(10f);
                materialEditor.RangeProperty(_spriteLayer2Opacity, "Opacity");
                materialEditor.ColorProperty(_spriteLayer2Color, "Tint");
                materialEditor.RangeProperty(_spriteLayer2ScrollingX, "Scrolling X-Axis");
                materialEditor.RangeProperty(_spriteLayer2ScrollingY, "Scrolling Y-Axis");

                GUILayout.Space(10f);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Reset"))
                {
                    _matTarget.SetFloat(ShaderFloat.SpriteLayer1Opacity.GetString(), 1f);
                    _matTarget.SetColor(ShaderColor.SpriteLayer1.GetString(), Color.white);
                    _matTarget.SetFloat(ShaderFloat.SpriteLayer1ScrollingX.GetString(), 0f);
                    _matTarget.SetFloat(ShaderFloat.SpriteLayer1ScrollingY.GetString(), 0f);
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(10f);

                DrawWideBox();
                GUILayout.Box("Layer 2#", EditorStyles.miniButton);
                materialEditor.TextureProperty(_spriteLayer3Tex, "Sprite");
                GUILayout.Space(10f);
                materialEditor.RangeProperty(_spriteLayer3Opacity, "Opacity");
                materialEditor.ColorProperty(_spriteLayer3Color, "Tint");
                materialEditor.RangeProperty(_spriteLayer3ScrollingX, "Scrolling X-Axis");
                materialEditor.RangeProperty(_spriteLayer3ScrollingY, "Scrolling Y-Axis");

                GUILayout.Space(10f);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Reset"))
                {
                    _matTarget.SetFloat(ShaderFloat.SpriteLayer2Opacity.GetString(), 1f);
                    _matTarget.SetColor(ShaderColor.SpriteLayer2.GetString(), Color.white);
                    _matTarget.SetFloat(ShaderFloat.SpriteLayer2ScrollingX.GetString(), 0f);
                    _matTarget.SetFloat(ShaderFloat.SpriteLayer2ScrollingY.GetString(), 0f);
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(10f);

                DrawWideBox();
                GUILayout.Box("Layer 3#", EditorStyles.miniButton);
                materialEditor.TextureProperty(_spriteLayer4Tex, "Sprite");
                GUILayout.Space(10f);
                materialEditor.RangeProperty(_spriteLayer4Opacity, "Opacity");
                materialEditor.ColorProperty(_spriteLayer4Color, "Tint");
                materialEditor.RangeProperty(_spriteLayer4ScrollingX, "Scrolling X-Axis");
                materialEditor.RangeProperty(_spriteLayer4ScrollingY, "Scrolling Y-Axis");

                GUILayout.Space(10f);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Reset"))
                {
                    _matTarget.SetFloat(ShaderFloat.SpriteLayer3Opacity.GetString(), 1f);
                    _matTarget.SetColor(ShaderColor.SpriteLayer3.GetString(), Color.white);
                    _matTarget.SetFloat(ShaderFloat.SpriteLayer3ScrollingX.GetString(), 0f);
                    _matTarget.SetFloat(ShaderFloat.SpriteLayer3ScrollingY.GetString(), 0f);
                }
                GUILayout.EndHorizontal();
            }
            break;

        case SettingsMode.Curvature:
            GUILayout.BeginHorizontal();
            ToggleFeature(_matTarget, "Curvature", ShaderFeature.Curvature);
            GUILayout.FlexibleSpace();
            ButtonOpenUrl(_btnHelp, "http://wiki.next-gen-sprites.com/doku.php?id=shaders:feature:curvature");
            GUILayout.Space(10f);
            GUILayout.EndHorizontal();

            GUILayout.Space(5f);

            materialEditor.TextureProperty(_curvatureMap, "Curvature Map");
            GUILayout.Space(10f);
            DrawWideBox();
            GUILayout.Space(10f);

            materialEditor.ColorProperty(_curvatureHighlight, "Highlight Tint");
            GUILayout.Space(10f);

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

            materialEditor.RangeProperty(_curvatureDepth, "Depth");
            GUILayout.Space(10f);

            materialEditor.RangeProperty(_curvatureGloss, "Surface Glossiness");
            GUILayout.Space(10f);

            DrawWideBox();
            GUILayout.Space(5f);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Reset Properties"))
            {
                _matTarget.SetFloat(ShaderFloat.CurvatureDepth.GetString(), 0.5f);
                _matTarget.SetColor(ShaderColor.Curvature.GetString(), Color.gray);
                _matTarget.SetFloat(ShaderFloat.CurvatureGloss.GetString(), 0.5f);
            }
            GUILayout.EndHorizontal();

            EditorGUI.EndDisabledGroup();
            break;

        case SettingsMode.Reflection:
            GUILayout.BeginHorizontal();
            ToggleFeature(_matTarget, "Reflection", ShaderFeature.Reflection);
            GUILayout.FlexibleSpace();
            ButtonOpenUrl(_btnHelp, "http://wiki.next-gen-sprites.com/doku.php?id=shaders:feature:reflection");
            GUILayout.Space(10f);
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);

            materialEditor.TextureProperty(_reflectionScreenMap, "Reflection");
            EditorGUILayout.HelpBox("Texture should have Wrap Mode set to Repeat.", MessageType.None);

            DrawWideBox();
            materialEditor.RangeProperty(_reflectionStrength, "Reflection Strength");
            GUILayout.Space(5f);
            materialEditor.RangeProperty(_reflectionBlur, "Blur");
            GUILayout.Space(5f);

            DrawWideBox();
            materialEditor.RangeProperty(_reflectionScrollingX, "Scrolling speed X");
            GUILayout.Space(10f);
            materialEditor.RangeProperty(_reflectionScrollingY, "Scrolling speed Y");
            DrawWideBox();

            GUILayout.Space(5f);

            materialEditor.TextureProperty(_reflectionMask, "Mask");

            DrawWideBox();
            GUILayout.Space(5f);

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

            if (GUILayout.Button("Reset Properties"))
            {
                _matTarget.SetFloat(ShaderFloat.ReflectionScrollSpeedX.GetString(), 0.25f);
                _matTarget.SetFloat(ShaderFloat.ReflectionScrollSpeedY.GetString(), 0.25f);
                _matTarget.SetFloat(ShaderFloat.ReflectionStrength.GetString(), 0f);
                _matTarget.SetFloat(ShaderFloat.ReflectionBlur.GetString(), 0f);
            }
            GUILayout.EndHorizontal();

            EditorGUI.EndDisabledGroup();
            break;

        case SettingsMode.Emission:
            var animationOn = _matTarget.IsKeywordEnabled(ShaderFeature.EmissionPulse.GetString());

            GUILayout.BeginHorizontal();
            ToggleFeature(_matTarget, "Emission", ShaderFeature.Emission);
            GUILayout.FlexibleSpace();
            ButtonOpenUrl(_btnHelp, "http://wiki.next-gen-sprites.com/doku.php?id=shaders:feature:emission");
            GUILayout.Space(10f);
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);

            GUILayout.BeginHorizontal();
            EditorGUILayout.HelpBox("Mask Channels\n\nRed: Layer 1#\nGreen: Layer 2#\nBlue: Layer 3#", MessageType.None);
            materialEditor.TextureProperty(_emissionMask, "Emission Mask");
            GUILayout.EndHorizontal();

            GUILayout.Space(5f);
            DrawWideBox();
            GUILayout.Box("Layer 1# - Mask Channel Red", EditorStyles.miniButton);
            GUILayout.Space(10f);
            materialEditor.RangeProperty(_emissionStrength, "Intensity");
            GUILayout.Space(10f);
            materialEditor.ColorProperty(_emissionTint, "Tint");
            GUILayout.Space(5f);

            EditorGUI.BeginDisabledGroup(!animationOn);
            materialEditor.RangeProperty(_emissionLayer1AninSpeed, "Pulse Speed");
            materialEditor.RangeProperty(_emissionLayer1AninBlend, "Blend Animation");
            EditorGUI.EndDisabledGroup();
            GUILayout.Space(5f);

            DrawWideBox();
            GUILayout.Box("Layer 2# - Mask Channel Green", EditorStyles.miniButton);
            GUILayout.Space(10f);
            materialEditor.RangeProperty(_emissionLayer2Strength, "Intensity");
            GUILayout.Space(10f);
            materialEditor.ColorProperty(_emissionLayer2Tint, "Tint");
            GUILayout.Space(5f);

            EditorGUI.BeginDisabledGroup(!animationOn);
            materialEditor.RangeProperty(_emissionLayer2AninSpeed, "Pulse Speed");
            materialEditor.RangeProperty(_emissionLayer2AninBlend, "Blend Animation");
            EditorGUI.EndDisabledGroup();
            GUILayout.Space(5f);

            DrawWideBox();
            GUILayout.Box("Layer 3# - Mask Channel Blue", EditorStyles.miniButton);
            GUILayout.Space(10f);
            materialEditor.RangeProperty(_emissionLayer3Strength, "Intensity");
            GUILayout.Space(10f);
            materialEditor.ColorProperty(_emissionLayer3Tint, "Tint");
            GUILayout.Space(5f);
            EditorGUI.BeginDisabledGroup(!animationOn);
            materialEditor.RangeProperty(_emissionLayer3AninSpeed, "Pulse Speed");
            materialEditor.RangeProperty(_emissionLayer3AninBlend, "Blend Animation");
            EditorGUI.EndDisabledGroup();
            GUILayout.Space(5f);

            DrawWideBox();
            GUILayout.Space(5f);
            GUILayout.BeginHorizontal();
            ToggleFeature(_matTarget, "Pulse Animation", ShaderFeature.EmissionPulse, disableGroup: false);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Reset Properties"))
            {
                _matTarget.SetFloat(ShaderFloat.EmissionIntensity.GetString(), 0f);
                _matTarget.SetColor(ShaderColor.Emission.GetString(), Color.white);
                _matTarget.SetFloat(ShaderFloat.EmissionLayer1BlendAnimation.GetString(), 1f);
                _matTarget.SetFloat(ShaderFloat.EmissionLayer1PulseSpeed.GetString(), 0f);
                _matTarget.SetFloat(ShaderFloat.EmissionLayer2Intensity.GetString(), 0f);
                _matTarget.SetColor(ShaderColor.EmissionLayer2.GetString(), Color.white);
                _matTarget.SetFloat(ShaderFloat.EmissionLayer2BlendAnimation.GetString(), 1f);
                _matTarget.SetFloat(ShaderFloat.EmissionLayer2PulseSpeed.GetString(), 0f);
                _matTarget.SetFloat(ShaderFloat.EmissionLayer3Intensity.GetString(), 0f);
                _matTarget.SetColor(ShaderColor.EmissionLayer3.GetString(), Color.white);
                _matTarget.SetFloat(ShaderFloat.EmissionLayer3BlendAnimation.GetString(), 1f);
                _matTarget.SetFloat(ShaderFloat.EmissionLayer3PulseSpeed.GetString(), 0f);
            }
            GUILayout.EndHorizontal();
            break;

        case SettingsMode.Translucency:
            GUILayout.BeginHorizontal();
            ToggleFeature(_matTarget, "Transmission", ShaderFeature.Transmission);
            GUILayout.FlexibleSpace();
            ButtonOpenUrl(_btnHelp, "http://wiki.next-gen-sprites.com/doku.php?id=shaders:feature:transmission");
            GUILayout.Space(10f);
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);

            materialEditor.TextureProperty(_transmissionMap, "Texture");
            GUILayout.Space(10f);
            DrawWideBox();
            GUILayout.Space(10f);

            materialEditor.RangeProperty(_transmissionDensity, "Density");
            EditorGUI.EndDisabledGroup();
            break;

        case SettingsMode.Dissolve:
            GUILayout.BeginHorizontal();
            ToggleFeature(_matTarget, "Dissolve", ShaderFeature.Dissolve);
            GUILayout.FlexibleSpace();
            ButtonOpenUrl(_btnHelp, "http://wiki.next-gen-sprites.com/doku.php?id=shaders:feature:dissolve");
            GUILayout.Space(10f);
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);

            materialEditor.TextureProperty(_dissolveMap, "Dissolve Pattern", scaleOffset: false);
            DrawWideBox();
            GUILayout.Space(15f);
            materialEditor.RangeProperty(_dissolveBlend, "Blending");
            GUILayout.Space(10f);
            materialEditor.RangeProperty(_dissolveBorderWidth, "Border Width");
            GUILayout.Space(10f);
            materialEditor.RangeProperty(_dissolveGlowStrength, "Border Glow");
            GUILayout.Space(10f);
            materialEditor.ColorProperty(_dissolveGlowColor, "Glow Color");

            EditorGUI.EndDisabledGroup();
            break;

        case SettingsMode.Extras:
            ShaderLightingSelection(_matTarget, materialEditor);

            GUILayout.Space(5f);
            //check Shader Keywords for Pixel Snapping
            GUILayout.BeginHorizontal();
            ToggleFeature(_matTarget, "Pixel Snapping", ShaderFeature.PixelSnap, disableGroup: false, height: 30f);
            ToggleFeature(_matTarget, "Doublesided", ShaderFeature.DoubleSided, disableGroup: false, height: 30f);
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);

            DrawWideBox();
            GUILayout.Space(5f);

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

            if (GUILayout.Button(_btnWiki, GUILayout.Height(64f), GUILayout.MaxWidth(140f)))
            {
                EditorApplication.delayCall += () => { Application.OpenURL("http://wiki.next-gen-sprites.com/"); }
            }
            ;

            if (GUILayout.Button(_btnWidget, GUILayout.Height(64f), GUILayout.MaxWidth(140f)))
            {
                EditorApplication.delayCall += () => { EditorApplication.ExecuteMenuItem("Window/NextGenSprites/Widget"); }
            }
            ;

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

            GUILayout.Space(10f);

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

            if (GUILayout.Button(_btnSaveCollection, GUILayout.Height(64f), GUILayout.MaxWidth(140f)))
            {
                EditorApplication.delayCall += () => { EditorApplication.ExecuteMenuItem("Assets/Create/NextGenSprites/Properties Collection from selection"); }
            }
            ;

            if (GUILayout.Button(_btnLoadCollection, GUILayout.Height(64f), GUILayout.MaxWidth(140f)))
            {
                EditorApplication.delayCall += () => { EditorApplication.ExecuteMenuItem("GameObject/NextGenSprites/Apply Properties Collection to selection"); }
            }
            ;

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

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

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditorGUILayout.HelpBox("Version 1.3.4", MessageType.None);
            EditorGUILayout.HelpBox("Copyright 2016 Ruben de la Torre", MessageType.None);
            EditorGUILayout.EndHorizontal();
            break;
        }
    }
예제 #11
0
        protected override void DrawLeftColumnHeader()
        {
            using (new GUILayout.VerticalScope())
            {
                GUILayout.Space(10);

                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Space(10);
                    GUILayout.Label("<size=16><b>Search scope</b></size>", UIHelpers.richLabel);
                    GUILayout.FlexibleSpace();

                    using (new GUILayout.VerticalScope())
                    {
                        /*GUILayout.Space(-3);*/
                        //if (UIHelpers.ImageButton(null, CSIcons.HelpOutline, GUILayout.ExpandWidth(false)))
                        if (UIHelpers.IconButton(CSIcons.HelpOutline, GUILayout.ExpandWidth(false)))
                        {
                            // TODO: update
                            EditorUtility.DisplayDialog(ReferencesFinder.ModuleName + " scopes help",
                                                        "Use " + projectTab.Caption.text + " scope to figure out where any specific asset is referenced in whole project.\n\n" +
                                                        "Use " + hierarchyTab.Caption.text + " scope to figure out where any specific Game Object or component is referenced in active scene or opened prefab.",
                                                        "OK");
                        }
                    }
                    GUILayout.Space(10);
                }

                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Space(10);
                    UIHelpers.Separator();
                    GUILayout.Space(10);
                }

                GUILayout.Space(10);

                EditorGUI.BeginChangeCheck();
                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Space(10);
                    currentTab = (ReferenceFinderTab)GUILayout.SelectionGrid((int)currentTab, tabsCaptions, 1,
                                                                             GUILayout.Height(56), GUILayout.ExpandWidth(true));
                    GUILayout.Space(10);
                }

                if (EditorGUI.EndChangeCheck())
                {
                    UserSettings.Instance.referencesFinder.selectedTab = currentTab;
                    Refresh(false);
                }

                switch (currentTab)
                {
                case ReferenceFinderTab.Project:
                    projectTab.DrawLeftColumnHeader();
                    break;

                case ReferenceFinderTab.Scene:
                    hierarchyTab.DrawLeftColumnHeader();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            base.DrawLeftColumnHeader();
        }
        /// <summary>
        /// Show the list of current loadouts
        /// </summary>
        /// <param name="thumbSize">Size of the preview texture</param>
        internal void DrawLoadoutList(int thumbSize)
        {
            SyncLoadoutWithPalettes();

            int count = m_CurrentLoadouts.Count;

            PolyGUILayout.Label(Styles.brushLoadoutLabel);

            Rect backGroundRect = EditorGUILayout.BeginVertical(PrefabPaletteEditor.paletteStyle);

            backGroundRect.width = EditorGUIUtility.currentViewWidth;
            if (count == 0)
            {
                var r = EditorGUILayout.BeginVertical(GUILayout.Height(thumbSize + 4));
                EditorGUI.DrawRect(r, EditorGUIUtility.isProSkin ? PolyGUI.k_BoxBackgroundDark : PolyGUI.k_BoxBackgroundLight);
                GUILayout.FlexibleSpace();
                GUILayout.Label("Select items from the Palette below", EditorStyles.centeredGreyMiniLabel);
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();
                EditorGUILayout.EndVertical();
                return;
            }

            const int pad  = 4;
            int       size = thumbSize + pad;

            backGroundRect.x += 8;
            backGroundRect.y += 4;
            // The backgroundRect is currently as wide as the current view.
            // Adjust it to take the size of the vertical scrollbar and padding into account.
            backGroundRect.width -= (20 + (int)GUI.skin.verticalScrollbar.fixedWidth);
            // size variable will not take into account the padding to the right of all the thumbnails,
            // therefore it needs to be substracted from the width.
            int container_width = ((int)Mathf.Floor(backGroundRect.width) - (pad + 1));
            int columns         = (int)Mathf.Floor(container_width / size);

            if (columns == 0)
            {
                columns = 1;
            }
            int rows = count / columns + (count % columns == 0 ? 0 : 1);

            if (rows < 1)
            {
                rows = 1;
            }

            backGroundRect.height = 8 + rows * thumbSize + (rows - 1) * pad;
            EditorGUI.DrawRect(backGroundRect, EditorGUIUtility.isProSkin ? PolyGUI.k_BoxBackgroundDark : PolyGUI.k_BoxBackgroundLight);

            int currentIndex = 0;

            for (int i = 0; i < rows; i++)
            {
                var horizontalRect = EditorGUILayout.BeginHorizontal();
                for (int j = 0; j < columns; j++)
                {
                    LoadoutInfo         loadoutInfo  = m_CurrentLoadouts[currentIndex];
                    PrefabPaletteEditor prefabEditor = prefabPaletteEditors[loadoutInfo.palette];
                    SerializedProperty  prefabs      = prefabEditor.prefabs;
                    SerializedProperty  prefab       = prefabs.GetArrayElementAtIndex(loadoutInfo.palette.FindIndex(loadoutInfo.prefab));

                    var previewRectXPos = pad + j * size + horizontalRect.x;
                    DrawSingleLoadout(prefab, thumbSize, loadoutInfo, previewRectXPos, horizontalRect.y);
                    if (j != columns - 1)
                    {
                        GUILayout.Space(pad);
                    }
                    currentIndex++;
                    if (currentIndex >= count)
                    {
                        break;
                    }
                }
                EditorGUILayout.EndHorizontal();
                GUILayout.Space(4);
            }
            EditorGUILayout.EndVertical();

            if (toUnload != null)
            {
                RemovePrefabFromLoadout(toUnload);
                toUnload = null;
                SaveUserCurrentLoadouts();
            }
        }
예제 #13
0
        void OnGUI()
        {
            bool execBuild = false;

            if (_config == null)
            {
                _config = LoadAssetAtPath <AssetBundleBuildConfig>(savePath);
                if (_config == null)
                {
                    _config = new AssetBundleBuildConfig();
                }
            }

            if (_list == null)
            {
                _list = new ReorderableList(_config.filters, typeof(AssetBundleFilter));
                _list.drawElementCallback = OnListElementGUI;
                _list.drawHeaderCallback  = OnListHeaderGUI;
                _list.draggable           = true;
                _list.elementHeight       = 22;
            }

            //tool bar
            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            {
                if (GUILayout.Button("Add", EditorStyles.toolbarButton))
                {
                    _config.filters.Add(new AssetBundleFilter());
                }
                if (GUILayout.Button("Save", EditorStyles.toolbarButton))
                {
                    Save();
                }
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Build", EditorStyles.toolbarButton))
                {
                    execBuild = true;
                }
            }
            GUILayout.EndHorizontal();

            //context
            GUILayout.BeginVertical();

            //format
            GUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("DepInfoFileFormat");
                _config.depInfoFileFormat = (AssetBundleBuildConfig.Format)EditorGUILayout.EnumPopup(_config.depInfoFileFormat);
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            _list.DoLayoutList();
            GUILayout.EndVertical();

            //set dirty
            if (GUI.changed)
            {
                EditorUtility.SetDirty(_config);
            }

            if (execBuild)
            {
                Build();
            }
        }
        private void OnGUI()
        {
            GUILayout.Space(10);

            EditorGUILayout.BeginHorizontal(headerSkin.box);
            GUILayout.FlexibleSpace();

            GUILayout.Label("Setup Scene for Climbing", headerSkin.label);

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

            EditorGUILayout.BeginVertical(windowSkin.box);
            EditorGUI.indentLevel++;

            EditorGUILayout.Space();

            EditorGUILayout.HelpBox("Click on the settings you want to add to your scene", MessageType.Info);

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Setup the Camera", windowSkin.button))
            {
                if (SetCamera())
                {
                    setupLabel  = "Camera State Driven was added to your scene";
                    messageType = MessageType.Info;
                }
                else
                {
                    setupLabel  = "Camera State Driven was not added because your scene already has it.";
                    messageType = MessageType.Warning;
                }
            }

            EditorGUILayout.Space();

            if (GUILayout.Button("Create the Game Controller", windowSkin.button))
            {
                if (CreateGameController())
                {
                    setupLabel  = "Game Controller was created and added to your scene";
                    messageType = MessageType.Info;
                }
                else
                {
                    setupLabel  = "Game Controller was not created because your scene already has a Game Controller.";
                    messageType = MessageType.Warning;
                }
            }

            EditorGUILayout.Space();

            if (GUILayout.Button("Add Canvas UI", windowSkin.button))
            {
                if (SetUI())
                {
                    setupLabel  = "Canvas UI was added to your scene";
                    messageType = MessageType.Info;
                }
                else
                {
                    setupLabel  = "Canvas UI was not added because your scene already has a Canvas UI.";
                    messageType = MessageType.Warning;
                }
            }

            EditorGUILayout.Space();

            if (GUILayout.Button("Set Level To Mobile", windowSkin.button))
            {
                if (SetMobile())
                {
                    setupLabel  = "Mobile Buttons were added to the Scene";
                    messageType = MessageType.Info;
                }
                else
                {
                    setupLabel  = "Mobile Buttons were not added because your scene already has Mobile Buttons.";
                    messageType = MessageType.Warning;
                }
            }

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

            EditorGUILayout.Space();

            if (setupLabel != string.Empty)
            {
                EditorGUILayout.HelpBox(setupLabel, messageType);
            }

            EditorGUILayout.Space();

            EditorGUI.indentLevel--;
            EditorGUILayout.EndVertical();

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

            if (GUILayout.Button("Close", windowSkin.button))
            {
                Close();
            }
            ///

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }
예제 #15
0
        void DisplayLogEntryWindow(int id)
        {
            //Log.Info("DisplayLogEntryWindow");
            if (utils.le == null)
            {
                return;
            }

            //
            // Check escapePressed here because otherwise the event is swallowed by Unity
            //

//if (Event.current.type == UnityEngine.EventType.KeyDown)
//    escapePressed = (Event.current.keyCode == KeyCode.Escape);

#if false
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            labelStyle.normal.textColor = Color.red;
            GUILayout.Label("Hit Escape to close", labelStyle);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
#endif
            GUILayout.BeginHorizontal();
            GUILayout.Label("Vessel: ");
            GUILayout.TextField(utils.le.vesselName);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Situation: ");
            GUILayout.TextField(utils.le.displayVesselSituation());
            GUILayout.FlexibleSpace();
            GUILayout.Label("Event: ");
            GUILayout.TextField(utils.le.displayEventString());
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            notesScrollVector = GUILayout.BeginScrollView(notesScrollVector);
            // Configurable font size, independent from the skin.

            notesText = GUILayout.TextArea(notesText, GUILayout.ExpandHeight(true));
            GUILayout.EndScrollView();
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            if (manualEntry)
            {
                if (GUILayout.Button("Add Image", GUILayout.Width(90)))
                {
                    EnableImageSelectionFor(ImageSelectionFor.LogEntry);
                }
                GUILayout.FlexibleSpace();
            }
            if (utils.le.crewList.Count > 0)
            {
                if (GUILayout.Button("Add Crew", GUILayout.Width(90)))
                {
                    notesText += utils.getCurrentCrew(utils.le.crewList);
                }
            }
            GUILayout.FlexibleSpace();
            var cancelPressed = GUILayout.Button("Cancel", GUILayout.Width(90));

            if (cancelPressed)
            {
                Log.Info("CancelPressed");
                DisplayLogEntryExitCleanup(2);

                ToggleToolbarButton();

                toolbarControl.SetFalse();
                cancelManualEntry = true;
                notesText         = "";
                //escapePressed = false;
            }
            if (editItem == null)
            {
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Clear", GUILayout.Width(90)))
                {
                    notesText = "";
                }
            }
            GUILayout.FlexibleSpace();

            var okPressed = GUILayout.Button("OK", GUILayout.Width(120));

            if (okPressed)
            {
                Log.Info("okPressed");
                if (editItem != null)
                {
                    SaveEditItem();
                }
                else
                {
                    if (notesText != "")
                    {
                        utils.le.notes = notesText;

                        if (utils.le.eventScreenshot != ScreenshotOptions.No_Screenshot)
                        {
                            if (utils.le.screenshotName == null || utils.le.screenshotName == "")
                            {
                                Log.Info("queueScreenshot 1");
                                utils.queueScreenshot(ref utils.le);
                            }
                        }

                        lastPauseTime = Planetarium.GetUniversalTime();
                        lastNoteTime  = Planetarium.GetUniversalTime() + HighLogic.CurrentGame.Parameters.CustomParams <KL_11>().minTime;
                    }
                }

                DisplayLogEntryExitCleanup(3);

                if (visibleByToolbar)
                {
                    ToggleToolbarButton();
                    toolbarControl.SetFalse();
                }
            }
            GUILayout.EndHorizontal();
            GUI.DragWindow();
        }
예제 #16
0
    private void OnGUI()
    {
        if (skin == null)
        {
            skin                 = Object.Instantiate(GUI.skin) as GUISkin;
            skin.font            = font;
            skin.toggle.fontSize = 10;
        }

        GUI.skin = skin;

        Rect   fullScreenRect = new Rect(0, 0, Screen.width, Screen.height);
        string title          = string.Empty;

        if (rss != null)
        {
            RSS.Item item = rss.channel.items[showIndexLarge];
            title = "Loading...";
            if (item.large)
            {
                title = item.title;
                GUI.DrawTexture(fullScreenRect, item.large, ScaleMode.ScaleToFit);
            }
        }

        float traySize   = 75f;
        float trayGutter = 10f;
        Rect  trayRect   = new Rect(Screen.width - traySize + ((1f - showTray) * (traySize - trayGutter)), 0, traySize, Screen.height);

        // Swipe instructions
        Rect hintRect = trayRect;

        hintRect.width = swipeLeft.width;
        hintRect.x    -= swipeLeft.width;
        GUILayout.BeginArea(hintRect);
        GUILayout.FlexibleSpace();
        Texture2D swipeIcon = showTray < 1f ? swipeLeft : swipeRight;

        GUILayout.Label(swipeIcon, GUIStyle.none);
        GUILayout.FlexibleSpace();
        GUILayout.EndArea();

        // Image thumbnails
        GUILayout.BeginArea(trayRect);
        GUILayout.Space(-trayOffset);
        if (rss != null)
        {
            trayHeight = 0f;
            for (int i = 0; i < rss.channel.items.Count; i++)
            {
                RSS.Item  item = rss.channel.items[i];
                Texture2D tex  = item.small;
                if (tex)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(tex, GUIStyle.none);
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    // Draw border for selected image
                    if (index == i)
                    {
                        Rect  rect        = GUILayoutUtility.GetLastRect();
                        float borderWidth = 4.0f;
                        GUI.color = Color.yellow;
                        GUI.DrawTexture(new Rect(rect.xMin, rect.yMin, rect.width, borderWidth), whiteTex);
                        GUI.DrawTexture(new Rect(rect.xMax - borderWidth, rect.yMin, borderWidth, rect.height), whiteTex);
                        GUI.DrawTexture(new Rect(rect.xMin, rect.yMin, borderWidth, rect.height), whiteTex);
                        GUI.DrawTexture(new Rect(rect.xMin, rect.yMax - borderWidth, rect.width, borderWidth), whiteTex);
                        GUI.color = Color.white;


                        if (showTray >= 1f)
                        {
                            Rect tapRect = rect;
                            tapRect.width  = singleTap.width;
                            tapRect.height = singleTap.height;
                            GUI.DrawTexture(tapRect, singleTap);
                        }
                    }

                    trayHeight += tex.height;
                }
            }
        }
        GUILayout.EndArea();

        GUILayout.BeginArea(fullScreenRect);
        GUILayout.Label("Public Flickr Feed - " + title);
        GUILayout.Space(-10f);
        GUILayout.Label("(Draw a Circle to Refresh)");
        GUILayout.FlexibleSpace();
        GUILayout.BeginHorizontal();
        GUILayout.Label("Experiment #3: Swipes and Gestures");
        GUILayout.FlexibleSpace();
        GUILayout.Label(logo, GUIStyle.none);
        GUILayout.EndHorizontal();
        GUILayout.Space(10f);
        GUILayout.EndArea();

        if (showRefreshPrompt)
        {
            GUI.color = new Color(0f, 0f, 0f, 0.5f);
            GUI.DrawTexture(fullScreenRect, whiteTex);

            GUI.color = Color.white;
            GUILayout.BeginArea(fullScreenRect);
            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("Draw a circle again to refresh the Flickr feed");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(swipeLeft, GUIStyle.none);
            GUILayout.Label(swipeRight, GUIStyle.none);
            GUILayout.Label("to Cancel");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            GUILayout.EndArea();
        }
    }
        public override void OnInspectorGUI()
        {
            if (m_EditorUserSettings != null && !m_EditorUserSettings.targetObject)
            {
                LoadEditorUserSettings();
            }

            serializedObject.Update();

            // GUI.enabled hack because we don't want some controls to be disabled if the EditorSettings.asset is locked
            // since some of the controls are not dependent on the Editor Settings asset. Unfortunately, this assumes
            // that the editor will only be disabled because of version control locking which may change in the future.
            var editorEnabled = GUI.enabled;

            ShowUnityRemoteGUI(editorEnabled);

            GUILayout.Space(10);
            bool collabEnabled = Collab.instance.IsCollabEnabledForCurrentProject();
            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label(Content.versionControl, EditorStyles.boldLabel);

                ExternalVersionControl selvc = EditorSettings.externalVersionControl;
                CreatePopupMenuVersionControl(Content.mode.text, vcPopupList, selvc, SetVersionControlSystem);
                GUI.enabled = editorEnabled && !collabEnabled;
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Version Control not available when using Collaboration feature.", MessageType.Warning);
            }

            if (VersionControlSystemHasGUI())
            {
                GUI.enabled = true;
                bool hasRequiredFields = false;

                if (EditorSettings.externalVersionControl == ExternalVersionControl.Generic ||
                    EditorSettings.externalVersionControl == ExternalVersionControl.Disabled)
                {
                    // no specific UI for these VCS types
                }
                else
                {
                    ConfigField[] configFields = Provider.GetActiveConfigFields();

                    hasRequiredFields = true;

                    foreach (ConfigField field in configFields)
                    {
                        string newVal;
                        string oldVal = EditorUserSettings.GetConfigValue(field.name);
                        if (field.isPassword)
                        {
                            newVal = EditorGUILayout.PasswordField(field.label, oldVal);
                            if (newVal != oldVal)
                                EditorUserSettings.SetPrivateConfigValue(field.name, newVal);
                        }
                        else
                        {
                            newVal = EditorGUILayout.TextField(field.label, oldVal);
                            if (newVal != oldVal)
                                EditorUserSettings.SetConfigValue(field.name, newVal);
                        }

                        if (field.isRequired && string.IsNullOrEmpty(newVal))
                            hasRequiredFields = false;
                    }
                }

                // Log level popup
                string logLevel = EditorUserSettings.GetConfigValue("vcSharedLogLevel");
                int idx = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                if (idx == -1)
                {
                    logLevel = "notice";
                    idx = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                    if (idx == -1)
                    {
                        idx = 0;
                    }
                    logLevel = logLevelPopupList[idx];
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevel);
                }
                int newIdx = EditorGUILayout.Popup(Content.logLevel, idx, logLevelPopupList);
                if (newIdx != idx)
                {
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevelPopupList[newIdx].ToLower());
                }

                GUI.enabled = editorEnabled;

                string osState = "Connected";
                if (Provider.onlineState == OnlineState.Updating)
                    osState = "Connecting...";
                else if (Provider.onlineState == OnlineState.Offline)
                    osState = "Disconnected";
                else if (EditorUserSettings.WorkOffline)
                    osState = "Work Offline";

                EditorGUILayout.LabelField(Content.status.text, osState);

                if (Provider.onlineState != OnlineState.Online && !string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.enabled = false;
                    GUILayout.TextArea(Provider.offlineReason);
                    GUI.enabled = editorEnabled;
                }

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.enabled = hasRequiredFields && Provider.onlineState != OnlineState.Updating;
                if (GUILayout.Button("Connect", EditorStyles.miniButton))
                    Provider.UpdateSettings();
                GUILayout.EndHorizontal();

                EditorUserSettings.AutomaticAdd = EditorGUILayout.Toggle(Content.automaticAdd, EditorUserSettings.AutomaticAdd);

                if (Provider.requiresNetwork)
                {
                    bool workOfflineNew = EditorGUILayout.Toggle(Content.workOffline, EditorUserSettings.WorkOffline); // Enabled has a slightly different behaviour
                    if (workOfflineNew != EditorUserSettings.WorkOffline)
                    {
                        // On toggling on show a warning
                        if (workOfflineNew && !EditorUtility.DisplayDialog("Confirm working offline", "Working offline and making changes to your assets means that you will have to manually integrate changes back into version control using your standard version control client before you stop working offline in Unity. Make sure you know what you are doing.", "Work offline", "Cancel"))
                        {
                            workOfflineNew = false; // User cancelled working offline
                        }
                        EditorUserSettings.WorkOffline = workOfflineNew;
                        EditorApplication.RequestRepaintAllViews();
                    }

                    EditorUserSettings.allowAsyncStatusUpdate = EditorGUILayout.Toggle(Content.allowAsyncUpdate, EditorUserSettings.allowAsyncStatusUpdate);
                }

                if (Provider.hasCheckoutSupport)
                {
                    EditorUserSettings.showFailedCheckout = EditorGUILayout.Toggle(Content.showFailedCheckouts, EditorUserSettings.showFailedCheckout);
                    EditorUserSettings.overwriteFailedCheckoutAssets = EditorGUILayout.Toggle(Content.overwriteFailedCheckoutAssets, EditorUserSettings.overwriteFailedCheckoutAssets);
                }

                var newOverlayIcons = EditorGUILayout.Toggle(Content.overlayIcons, EditorUserSettings.overlayIcons);
                if (newOverlayIcons != EditorUserSettings.overlayIcons)
                {
                    EditorUserSettings.overlayIcons = newOverlayIcons;
                    EditorApplication.RequestRepaintAllViews();
                }

                GUI.enabled = editorEnabled;

                // Semantic merge popup
                EditorUserSettings.semanticMergeMode = (SemanticMergeMode)EditorGUILayout.Popup(Content.smartMerge, (int)EditorUserSettings.semanticMergeMode, semanticMergePopupList);

                DrawOverlayDescriptions();
            }

            GUILayout.Space(10);

            int index = (int)EditorSettings.serializationMode;
            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label(Content.assetSerialization, EditorStyles.boldLabel);
                GUI.enabled = editorEnabled && !collabEnabled;


                CreatePopupMenu("Mode", serializationPopupList, index, SetAssetSerializationMode);
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Asset Serialization is forced to Text when using Collaboration feature.", MessageType.Warning);
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.defaultBehaviorMode, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.defaultBehaviorMode, 0, behaviorPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, behaviorPopupList, index, SetDefaultBehaviorMode);

            {
                var wasEnabled = GUI.enabled;
                GUI.enabled = true;

                DoAssetPipelineSettings();

                if (m_AssetPipelineMode.intValue == (int)AssetPipelineMode.Version2)
                    DoCacheServerSettings();

                GUI.enabled = wasEnabled;
            }
            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label("Prefab Editing Environments", EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            {
                EditorGUI.BeginChangeCheck();
                SceneAsset scene = EditorSettings.prefabRegularEnvironment;
                scene = (SceneAsset)EditorGUILayout.ObjectField("Regular Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                    EditorSettings.prefabRegularEnvironment = scene;
            }
            {
                EditorGUI.BeginChangeCheck();
                SceneAsset scene = EditorSettings.prefabUIEnvironment;
                scene = (SceneAsset)EditorGUILayout.ObjectField("UI Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                    EditorSettings.prefabUIEnvironment = scene;
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.graphics, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            EditorGUI.BeginChangeCheck();
            bool showRes = LightmapVisualization.showResolution;
            showRes = EditorGUILayout.Toggle(Content.showLightmapResolutionOverlay, showRes);
            if (EditorGUI.EndChangeCheck())
                LightmapVisualization.showResolution = showRes;

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.spritePacker, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.spritePackerMode, 0, spritePackerPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, spritePackerPopupList, index, SetSpritePackerMode);

            if (EditorSettings.spritePackerMode == SpritePackerMode.AlwaysOn
                || EditorSettings.spritePackerMode == SpritePackerMode.BuildTimeOnly)
            {
                index = Mathf.Clamp((int)(EditorSettings.spritePackerPaddingPower - 1), 0, 2);
                CreatePopupMenu("Padding Power (Legacy Sprite Packer)", spritePackerPaddingPowerPopupList, index, SetSpritePackerPaddingPower);
            }

            DoProjectGenerationSettings();
            DoEtcTextureCompressionSettings();
            DoLineEndingsSettings();
            DoStreamingSettings();
            DoShaderCompilationSettings();
            DoEnterPlayModeSettings();

            serializedObject.ApplyModifiedProperties();
            m_EditorUserSettings.ApplyModifiedProperties();
        }
예제 #18
0
        public static void FolderField(EditorWindowFolder folder, LanguageTemplate lang, Action <EditorWindowFolder> OnDrop, Action AllIn, Action RemoveSelf, Action <EditorWindowFolder> DropSubFolder, Action <EditorWindowFolder> OnSelect)
        {
            var defaultColor = GUI.backgroundColor;

            if (folder.Selected)
            {
                GUI.backgroundColor = Color.gray;
            }

            var e = Event.current;

            Rect itemRect;

            using (var scope = new EditorGUILayout.VerticalScope(GUI.skin.box))
            {
                using (new EditorGUILayout.HorizontalScope())
                {
                    if (folder.ParentFolder is null)
                    {
                        if (folder.NameEdittable)
                        {
                            folder.Name = EditorGUILayout.TextField(folder.Name);

                            if ((GUILayout.Button(lang.ok, GUILayout.Width(50f)) ||
                                 e.Equals(Event.KeyboardEvent("return"))) &&
                                !string.IsNullOrEmpty(folder.Name))
                            {
                                folder.NameEdittable = false;
                                GUI.changed          = true;
                            }
                        }
                        else
                        {
                            EditorGUILayout.LabelField(folder.Name, EditorStyles.boldLabel);
                        }
                    }
                    else
                    {
                        folder.Foldout = EditorGUILayout.Foldout(folder.Foldout, folder.Name);

                        if (GUILayout.Button(lang.drop))
                        {
                            DropSubFolder(folder);
                        }
                    }
                }

                using (var itemsScope = new EditorGUILayout.VerticalScope())
                {
                    itemRect = itemsScope.rect;

                    if (folder.Foldout || folder.ParentFolder is null)
                    {
                        foreach (var editorWindowfolder in folder.EditorWindowFolderList.ToArray())
                        {
                            FolderField(editorWindowfolder, lang, OnDrop, AllIn, RemoveSelf, DropSubFolder, OnSelect);
                        }

                        foreach (var editorWindowInfo in folder.EditorWindowList.ToList())
                        {
                            FileField(editorWindowInfo, lang);
                        }
                    }
                }

                if (!folder.EditorWindowFolderList.Any() && !folder.EditorWindowList.Any())
                {
                    using (new EditorGUI.DisabledScope(folder.NameEdittable))
                    {
                        if (GUILayout.Button(lang.allIn))
                        {
                            AllIn();
                        }
                    }

                    if (GUILayout.Button(lang.remove))
                    {
                        RemoveSelf();
                    }
                }

                GUI.backgroundColor = defaultColor;

                if (folder.ParentFolder is null)
                {
                    GUILayout.FlexibleSpace();
                }

                if (scope.rect.Contains(e.mousePosition) && !itemRect.Contains(e.mousePosition))
                {
                    if (e.type == EventType.MouseDown)
                    {
                        GUI.changed = true;
                        OnSelect(folder);
                        Highlighter.Stop();
                    }
                    else if (e.type == EventType.MouseUp)
                    {
                        GUI.changed = true;
                        OnDrop(folder);
                        Highlighter.Stop();
                        GUIUtility.ExitGUI();
                    }
                    else if (e.type == EventType.MouseDrag)
                    {
                        GUI.changed = true;
                        // TODO: 本当はFolder全体が囲まれるようにしたい
                        // Highlighter.HighlightIdentifierはうまくいかない
                        Highlighter.Highlight(nameof(MenuSimplifier), folder.Name);
                        GUIUtility.ExitGUI();
                    }
                }
            }
        }
예제 #19
0
    void OnGUI()
    {
        bool execBuild = false;

        if (config == null)
        {
            config = AssetDatabase.LoadAssetAtPath <AssetBundleBuildConfig>(savePath);
            if (config == null)
            {
                config = new AssetBundleBuildConfig();
            }
        }

        UpdateStyles();
        //tool bar
        GUILayout.BeginHorizontal(Styles.toolbar);
        {
            if (GUILayout.Button("Add", Styles.toolbarButton))
            {
                config.filters.Add(new AssetBundleFilter());
            }
            if (GUILayout.Button("Save", Styles.toolbarButton))
            {
                Save();
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Build", Styles.toolbarButton))
            {
                execBuild = true;
            }
        }
        GUILayout.EndHorizontal();

        //context
        GUILayout.BeginVertical();

        //format
        GUILayout.BeginHorizontal();
        {
            EditorGUILayout.PrefixLabel("DepInfoFileFormat");
            config.depInfoFileFormat = (AssetBundleBuildConfig.Format)EditorGUILayout.EnumPopup(config.depInfoFileFormat);
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(10);

        for (int i = 0; i < config.filters.Count; i++)
        {
            AssetBundleFilter filter = config.filters[i];
            GUILayout.BeginHorizontal();
            {
                filter.valid = GUILayout.Toggle(filter.valid, "", GUILayout.ExpandWidth(false));
                filter.path  = GUILayout.TextField(filter.path, GUILayout.ExpandWidth(true));
                if (GUILayout.Button("Select", GUILayout.ExpandWidth(false)))
                {
                    string dataPath     = Application.dataPath;
                    string selectedPath = EditorUtility.OpenFolderPanel("Path", dataPath, "");
                    if (!string.IsNullOrEmpty(selectedPath))
                    {
                        if (selectedPath.StartsWith(dataPath))
                        {
                            filter.path = "Assets/" + selectedPath.Substring(dataPath.Length + 1);
                        }
                        else
                        {
                            ShowNotification(new GUIContent("不能在Assets目录之外!"));
                        }
                    }
                }
                filter.filter = GUILayout.TextField(filter.filter, GUILayout.Width(200));
                if (GUILayout.Button("X", GUILayout.ExpandWidth(false)))
                {
                    config.filters.RemoveAt(i);
                    i--;
                }
            }
            GUILayout.EndHorizontal();
        }
        GUILayout.EndVertical();

        //set dirty
        if (GUI.changed)
        {
            EditorUtility.SetDirty(config);
        }

        if (execBuild)
        {
            Build();
        }
    }
        private void DrawCodeGenerationOptions()
        {
            var previousWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 180;

            GUILayout.Label(CodeGeneratorLabel, EditorStyles.boldLabel);
            GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);

            using (new EditorGUIUtility.IconSizeScope(new Vector2(12, 12)))
                using (new EditorGUI.IndentLevelScope())
                {
                    toolsConfig.VerboseLogging = EditorGUILayout.Toggle(VerboseLoggingLabel, toolsConfig.VerboseLogging);

                    toolsConfig.CodegenLogOutputDir =
                        EditorGUILayout.TextField(CodegenLogOutputDirLabel, toolsConfig.CodegenLogOutputDir);

                    toolsConfig.CodegenOutputDir =
                        EditorGUILayout.TextField(CodegenOutputDirLabel, toolsConfig.CodegenOutputDir);

                    toolsConfig.CodegenEditorOutputDir = EditorGUILayout.TextField(CodegenEditorOutputDirLabel,
                                                                                   toolsConfig.CodegenEditorOutputDir);

                    toolsConfig.DescriptorOutputDir =
                        EditorGUILayout.TextField(DescriptorOutputDirLabel, toolsConfig.DescriptorOutputDir);

                    EditorGUILayout.LabelField($"{SchemaSourceDirsLabel}", EditorStyles.boldLabel);
                    using (new EditorGUI.IndentLevelScope())
                    {
                        for (var i = 0; i < toolsConfig.SchemaSourceDirs.Count; i++)
                        {
                            using (new EditorGUILayout.HorizontalScope())
                            {
                                toolsConfig.SchemaSourceDirs[i] =
                                    EditorGUILayout.TextField($"Schema path [{i}]", toolsConfig.SchemaSourceDirs[i]);

                                if (GUILayout.Button(RemoveSchemaDirButton, EditorStyles.miniButton,
                                                     GUILayout.ExpandWidth(false)))
                                {
                                    toolsConfig.SchemaSourceDirs.RemoveAt(i);
                                }
                            }
                        }

                        using (new EditorGUILayout.HorizontalScope())
                        {
                            GUILayout.FlexibleSpace();

                            if (GUILayout.Button(AddSchemaDirButton, EditorStyles.miniButton))
                            {
                                toolsConfig.SchemaSourceDirs.Add(string.Empty);
                            }
                        }
                    }
                }

            GUILayout.Label(DevAuthTokenSectionLabel, EditorStyles.boldLabel);
            using (new EditorGUI.IndentLevelScope())
            {
                toolsConfig.DevAuthTokenLifetimeDays =
                    EditorGUILayout.IntSlider(DevAuthTokenLifetimeLabel, toolsConfig.DevAuthTokenLifetimeDays, 1, 90);

                toolsConfig.SaveDevAuthTokenToFile = EditorGUILayout.Toggle("Save token to file", toolsConfig.SaveDevAuthTokenToFile);
                using (new EditorGUI.DisabledScope(!toolsConfig.SaveDevAuthTokenToFile))
                {
                    toolsConfig.DevAuthTokenDir = EditorGUILayout.TextField(DevAuthTokenDirLabel, toolsConfig.DevAuthTokenDir);
                    GUILayout.Label($"Token filepath: {Path.GetFullPath(toolsConfig.DevAuthTokenFilepath)}", EditorStyles.helpBox);
                }
            }

            EditorGUIUtility.labelWidth = previousWidth;
        }
예제 #21
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        WorkshopBase item = ( WorkshopBase)target;

        //
        // Tools Area
        //
        {
            GUILayout.Space(16);

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

            if (GUILayout.Button("Preview In Scene"))
            {
                item.StartPreview();
            }
        }

        GUILayout.FlexibleSpace();

        //
        // Workshop Area
        //
        {
            GUILayout.Label("Workshop", EditorStyles.boldLabel);

            EditorGUILayout.HelpBox("When you press the button below changes will be made to your workshop items.", MessageType.Info);

            bool canUpload = true;
            //if ( changeNotes.Length <= 1 ) { EditorGUILayout.HelpBox( "Enter a note in the box below to let people know what you're changing", MessageType.Error ); canUpload = false; }
            if (item.title.Length <= 1)
            {
                EditorGUILayout.HelpBox("Your title is too short", MessageType.Error); canUpload = false;
            }
            if (item.description.Length <= 1)
            {
                EditorGUILayout.HelpBox("Your title is too short", MessageType.Error); canUpload = false;
            }
            if (item.previewImage == null)
            {
                EditorGUILayout.HelpBox("You don't have a preview image set", MessageType.Error); canUpload = false;
            }

            EditorGUILayout.LabelField("Change Notes:");
            changeNotes = EditorGUILayout.TextArea(changeNotes, GUILayout.Height(64));

            EditorGUILayout.BeginHorizontal();

            if (item.itemID > 0)
            {
                if (GUILayout.Button("VIEW ONLINE", GUILayout.ExpandWidth(false)))
                {
                    Application.OpenURL("http://steamcommunity.com/sharedfiles/filedetails/?id=489329801");
                }
            }

            EditorGUILayout.Space();

            GUI.enabled = canUpload;
            if (GUILayout.Button(item.itemID == 0 ? "Create & Upload" : "Upload Changes", GUILayout.ExpandWidth(false)))
            {
                Steamworks.SteamAPI.Init();
                UploadToWorkshop(item);
                Steamworks.SteamAPI.Shutdown();
                UnityEditor.EditorUtility.ClearProgressBar();
            }
            GUI.enabled = true;

            EditorGUILayout.EndHorizontal();
        }
    }
        public override void OnGUI(string searchContext)
        {
            EditorGUILayout.Space();
            var contentWidth = GUILayoutUtility.GetLastRect().width * 0.5f;

            EditorGUIUtility.labelWidth = contentWidth;
            EditorGUIUtility.fieldWidth = contentWidth;
            GUILayout.BeginVertical(Styles.Group);
            GUILayout.Label("Enabled Readers", EditorStyles.boldLabel);
            GUILayout.Label("You can disable file formats you don't use here");
            EditorGUILayout.Space();
            var changed = false;

            foreach (var importerOption in _importerOptions)
            {
                var value    = importerOption.PluginImporter.GetCompatibleWithAnyPlatform();
                var newValue = EditorGUILayout.Toggle(importerOption, value);
                if (newValue != value)
                {
                    importerOption.PluginImporter.SetCompatibleWithAnyPlatform(newValue);
                    changed = true;
                }
            }
            if (changed)
            {
                string usings     = null;
                string extensions = null;
                string findReader = null;
                foreach (var importerOption in _importerOptions)
                {
                    if (importerOption.PluginImporter.GetCompatibleWithAnyPlatform())
                    {
                        extensions += $"\n\t\t\t\textensions.AddRange({importerOption.text}.GetExtensions());";
                        usings     += $"using {importerOption.Namespace};\n";
                        findReader += $"\n\t\t\tif (((IList) {importerOption.text}.GetExtensions()).Contains(extension))\n\t\t\t{{\n\t\t\t\treturn new {importerOption.text}();\n\t\t\t}}";
                    }
                }
                var text      = string.Format(ReadersFileTemplate, usings, extensions, findReader);
                var textAsset = AssetDatabase.LoadAssetAtPath <TextAsset>(_readersFilePath);
                File.WriteAllText(_readersFilePath, text);
                EditorUtility.SetDirty(textAsset);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
            EditorGUILayout.Space();
            GUILayout.Label("Material Mappers", EditorStyles.boldLabel);
            GUILayout.Label("Select the Material Mappers according your project rendering pipeline");
            EditorGUILayout.Space();
            foreach (var materialMapperName in MaterialMapper.RegisteredMappers)
            {
                var value    = TriLibSettings.GetBool(materialMapperName);
                var newValue = EditorGUILayout.Toggle(materialMapperName, value);
                if (newValue != value)
                {
                    TriLibSettings.SetBool(materialMapperName, newValue);
                }
            }
            CheckMappers.Initialize();
            EditorGUILayout.Space();
            GUILayout.Label("Misc Options", EditorStyles.boldLabel);
            GUILayout.Label("Advanced Options");
            EditorGUILayout.Space();
            ShowConditionalToggle("Enable GLTF Draco Decompression (Experimental)", "TRILIB_DRACO");
            ShowConditionalToggle("Force synchronous loading", "TRILIB_FORCE_SYNC");
            ShowConditionalToggle("Change Thread names (Debug purposes only)", "TRILIB_USE_THREAD_NAMES");
            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Version Notes"))
            {
                TriLibVersionNotes.ShowWindow();
            }
            if (GUILayout.Button("API Reference"))
            {
                Application.OpenURL("https://ricardoreis.net/trilib/trilib2/docs/");
            }
            if (GUILayout.Button("Support"))
            {
                Application.OpenURL("mailto:[email protected]");
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            base.OnGUI(searchContext);
        }
예제 #23
0
        private void DoToolbarGUI()
        {
            GameViewSizes.instance.RefreshStandaloneAndRemoteDefaultSizes();

            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            {
                var availableTypes = GetAvailableWindowTypes();
                if (availableTypes.Count > 1)
                {
                    var typeNames = availableTypes.Values.ToList();
                    var types     = availableTypes.Keys.ToList();
                    int viewIndex = EditorGUILayout.Popup(typeNames.IndexOf(titleContent.text), typeNames.ToArray(),
                                                          EditorStyles.toolbarPopup,
                                                          GUILayout.Width(90));
                    EditorGUILayout.Space();
                    if (types[viewIndex] != typeof(GameView))
                    {
                        SwapMainWindow(types[viewIndex]);
                    }
                }

                if (ModuleManager.ShouldShowMultiDisplayOption())
                {
                    int display = EditorGUILayout.Popup(targetDisplay, DisplayUtility.GetDisplayNames(), EditorStyles.toolbarPopupLeft, GUILayout.Width(80));
                    if (display != targetDisplay)
                    {
                        targetDisplay = display;
                        UpdateZoomAreaAndParent();
                    }
                }
                EditorGUILayout.GameViewSizePopup(currentSizeGroupType, selectedSizeIndex, this, EditorStyles.toolbarPopup, GUILayout.Width(160f));

                DoZoomSlider();
                // If the previous platform and current does not match, update the scale
                if ((int)currentSizeGroupType != prevSizeGroupType)
                {
                    UpdateZoomAreaAndParent();
                    // Update the platform to the recent one
                    prevSizeGroupType = (int)currentSizeGroupType;
                }

                if (FrameDebuggerUtility.IsLocalEnabled())
                {
                    GUILayout.FlexibleSpace();
                    Color oldCol = GUI.color;
                    // This has nothing to do with animation recording.  Can we replace this color with something else?
                    GUI.color *= AnimationMode.recordedPropertyColor;
                    GUILayout.Label(Styles.frameDebuggerOnContent, EditorStyles.toolbarLabel);
                    GUI.color = oldCol;
                    // Make frame debugger windows repaint after each time game view repaints.
                    // We want them to always display the latest & greatest game view
                    // rendering state.
                    if (Event.current.type == EventType.Repaint)
                    {
                        FrameDebuggerWindow.RepaintAll();
                    }
                }

                GUILayout.FlexibleSpace();

                if (RenderDoc.IsLoaded())
                {
                    using (new EditorGUI.DisabledScope(!RenderDoc.IsSupported()))
                    {
                        if (GUILayout.Button(Styles.renderdocContent, EditorStyles.toolbarButton))
                        {
                            m_Parent.CaptureRenderDocScene();
                            GUIUtility.ExitGUI();
                        }
                    }
                }

                // Allow the user to select how the XR device will be rendered during "Play In Editor"
                if (PlayerSettings.virtualRealitySupported)
                {
                    int selectedRenderMode = EditorGUILayout.Popup(m_XRRenderMode, Styles.xrRenderingModes, EditorStyles.toolbarPopup, GUILayout.Width(80));
                    SetXRRenderMode(selectedRenderMode);
                }

                maximizeOnPlay = GUILayout.Toggle(maximizeOnPlay, Styles.maximizeOnPlayContent, EditorStyles.toolbarButton);

                EditorUtility.audioMasterMute = GUILayout.Toggle(EditorUtility.audioMasterMute, Styles.muteContent, EditorStyles.toolbarButton);

                m_Stats = GUILayout.Toggle(m_Stats, Styles.statsContent, EditorStyles.toolbarButton);

                if (EditorGUILayout.DropDownToggle(ref m_Gizmos, Styles.gizmosContent, EditorStyles.toolbarDropDownToggleRight))
                {
                    Rect rect = GUILayoutUtility.topLevel.GetLast();
                    if (AnnotationWindow.ShowAtPosition(rect, true))
                    {
                        GUIUtility.ExitGUI();
                    }
                }
            }
            GUILayout.EndHorizontal();
        }
예제 #24
0
        void OnGUI()
        {
            if (!ShowLog)
            {
                return;
            }
            if (!ShowInEditor && Application.isEditor)
            {
                return;
            }

            if (AdvancedButtons && (buttonWidth == null || buttonHeight == null))
            {
                buttonWidth  = GUILayout.Width(25f);
                buttonHeight = GUILayout.Height(25f);
            }

            float w = (Screen.width - 2 * Margin) * Width;
            float h = (Screen.height - 2 * Margin) * Height;
            float x = 1, y = 1;

            switch (AnchorPosition)
            {
            case LogAnchor.BottomLeft:
                x = Margin;
                y = Margin + (Screen.height - 2 * Margin) * (1 - Height);
                break;

            case LogAnchor.BottomRight:
                x = Margin + (Screen.width - 2 * Margin) * (1 - Width);
                y = Margin + (Screen.height - 2 * Margin) * (1 - Height);
                break;

            case LogAnchor.TopLeft:
                x = Margin;
                y = Margin;
                break;

            case LogAnchor.TopRight:
                x = Margin + (Screen.width - 2 * Margin) * (1 - Width);
                y = Margin;
                break;
            }

            GUILayout.BeginArea(new Rect((int)x, (int)y, w, h), styleContainer);

            if (AdvancedButtons)
            {
                GUILayout.BeginHorizontal();
                GUILayout.BeginVertical(buttonWidth);

                if (GUILayout.Button(ScrollToTop, buttonHeight))
                {
                    manuallyScroll   = true;
                    scrollPosition.y = 0;
                }

                GUILayout.Space(10f);

                if (GUILayout.RepeatButton(ScrollUp, buttonHeight))
                {
                    manuallyScroll    = true;
                    scrollPosition.y -= ScrollSpeed;
                }

                GUILayout.FlexibleSpace();

                if (GUILayout.RepeatButton(ScrollDown, buttonHeight))
                {
                    manuallyScroll    = true;
                    scrollPosition.y += ScrollSpeed;
                }

                GUILayout.Space(10f);

                if (GUILayout.Button(ScrollToBottom, buttonHeight))
                {
                    manuallyScroll = false;
                }

                if (!manuallyScroll)
                {
                    scrollPosition.y = int.MaxValue;
                }

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

            scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false);

            var started = false;

            foreach (LogMessage m in queue)
            {
                switch (m.Type)
                {
                case LogType.Warning:
                    styleText.normal.textColor = WarningColor;
                    break;

                case LogType.Log:
                    styleText.normal.textColor = MessageColor;
                    break;

                case LogType.Assert:
                case LogType.Exception:
                case LogType.Error:
                    styleText.normal.textColor = ErrorColor;
                    break;

                default:
                    styleText.normal.textColor = MessageColor;
                    break;
                }

                if (!m.Message.StartsWith(Space) && started)
                {
                    GUILayout.Space(FontSize);
                }

                GUILayout.Label(m.Message, styleText);
                started = true;
            }

            GUILayout.EndScrollView();

            if (AdvancedButtons)
            {
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();

                if (GUILayout.Button(ClearView, buttonHeight))
                {
                    queue.Clear();
                }
            }

            GUILayout.EndArea();
        }
예제 #25
0
        void OnGUI()
        {
            GUILayout.Space(15);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical("Box");
            var style = new GUIStyle(EditorStyles.boldLabel)
            {
                alignment = TextAnchor.MiddleCenter
            };

            EditorGUILayout.LabelField(new GUIContent(SettingsIcon), style, GUILayout.ExpandWidth(true), GUILayout.Height(32));
            EditorGUILayout.LabelField("Emerald AI Setup Manager", style, GUILayout.ExpandWidth(true));
            EditorGUILayout.HelpBox("The Emerald AI Setup Manager applies all needed settings and components to automatically create an AI on the applied object. Be aware that closing the Emerald Setup Manager will lose all references you've entered below. Make sure you select 'Setup AI' before closing, if you'd like your changes to be applied.", MessageType.None, true);
            GUILayout.Space(4);

            var HelpButtonStyle = new GUIStyle(GUI.skin.button);

            HelpButtonStyle.normal.textColor = Color.white;
            HelpButtonStyle.fontStyle        = FontStyle.Bold;

            GUI.backgroundColor = new Color(1f, 1, 0.25f, 0.25f);
            EditorGUILayout.LabelField("For a detailed tutorial on setting up an AI from start to finish, please see the Getting Started Tutorial below.", EditorStyles.helpBox);
            GUI.backgroundColor = new Color(0, 0.65f, 0, 0.8f);
            if (GUILayout.Button("See the Getting Started Tutorial", HelpButtonStyle, GUILayout.Height(20)))
            {
                Application.OpenURL("https://github.com/Black-Horizon-Studios/Emerald-AI/wiki/Creating-a-New-AI");
            }
            GUI.backgroundColor = Color.white;
            GUILayout.Space(10);

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

            GUILayout.Space(15);

            EditorGUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Space(25);
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

            EditorGUILayout.BeginVertical("Box");

            GUI.backgroundColor = new Color(0.2f, 0.2f, 0.2f, 0.25f);
            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Setup Settings", EditorStyles.boldLabel);
            GUI.backgroundColor = Color.white;
            EditorGUILayout.EndVertical();
            GUI.backgroundColor = Color.white;

            GUILayout.Space(15);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.19f);
            EditorGUILayout.HelpBox("The object that the Emerald AI system will be added to.", MessageType.None, true);
            GUI.backgroundColor = Color.white;
            if (ObjectToSetup == null)
            {
                GUI.backgroundColor = new Color(10f, 0.0f, 0.0f, 0.25f);
                EditorGUILayout.LabelField("This field cannot be left blank.", EditorStyles.helpBox);
                GUI.backgroundColor = Color.white;
            }
            ObjectToSetup = (GameObject)EditorGUILayout.ObjectField("AI Object", ObjectToSetup, typeof(GameObject), true);
            GUILayout.Space(10);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.19f);
            EditorGUILayout.HelpBox("The Unity Tag that will be applied to your AI. Note: Untagged cannot be used.", MessageType.None, true);
            GUI.backgroundColor = Color.white;
            AITag = EditorGUILayout.TagField("Tag for AI", AITag);
            GUILayout.Space(10);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.19f);
            EditorGUILayout.HelpBox("The Unity Layer that will be applied to your AI. Note: Default cannot be used.", MessageType.None, true);
            GUI.backgroundColor = Color.white;
            AILayer             = EditorGUILayout.LayerField("Layer for AI", AILayer);
            GUILayout.Space(10);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.19f);
            EditorGUILayout.HelpBox("The Behavior that will be applied to this AI.", MessageType.None, true);
            GUI.backgroundColor = Color.white;
            AIBehaviorRef       = (AIBehavior)EditorGUILayout.EnumPopup("AI's Behavior", AIBehaviorRef);
            GUILayout.Space(10);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.19f);
            EditorGUILayout.HelpBox("The Confidence that will be applied to this AI.", MessageType.None, true);
            GUI.backgroundColor = Color.white;
            ConfidenceRef       = (ConfidenceType)EditorGUILayout.EnumPopup("AI's Confidence", ConfidenceRef);
            GUILayout.Space(10);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.19f);
            EditorGUILayout.HelpBox("The Wander Type  that will be applied to this AI.", MessageType.None, true);
            GUI.backgroundColor = Color.white;
            WanderTypeRef       = (WanderType)EditorGUILayout.EnumPopup("AI's Wander Type", WanderTypeRef);
            GUILayout.Space(10);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.19f);
            EditorGUILayout.HelpBox("Would you like the Setup Manager to automatically setup Emerald's optimization settings? This allows Emerald to be deactivated when an AI is culled or not visible which will help improve performance.", MessageType.None, true);
            GUI.backgroundColor          = Color.white;
            SetupOptimizationSettingsRef = (SetupOptimizationSettings)EditorGUILayout.EnumPopup("Auto Optimize", SetupOptimizationSettingsRef);
            GUILayout.Space(10);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.19f);
            EditorGUILayout.HelpBox("The Weapon Type this AI will use.", MessageType.None, true);
            GUI.backgroundColor = Color.white;
            WeaponTypeRef       = (WeaponType)EditorGUILayout.EnumPopup("Weapon Type", WeaponTypeRef);
            GUILayout.Space(10);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.19f);
            EditorGUILayout.HelpBox("Controls whether this AI will play an animation on death or transition to a ragdoll state.", MessageType.None, true);
            GUI.backgroundColor = Color.white;
            DeathTypeRef        = (DeathType)EditorGUILayout.EnumPopup("Death Type", DeathTypeRef);
            GUILayout.Space(10);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.19f);
            EditorGUILayout.HelpBox("Controls whether this AI will use Root Motion or NavMesh for its movement and speed.", MessageType.None, true);
            GUI.backgroundColor = Color.white;
            AnimatorType        = (AnimatorTypeState)EditorGUILayout.EnumPopup("Animator Type", AnimatorType);
            GUILayout.Space(30);

            if (ObjectToSetup == null)
            {
                GUI.backgroundColor = new Color(10f, 0.0f, 0.0f, 0.25f);
                EditorGUILayout.LabelField("You must have an object applied to the AI Object slot before you can complete the setup process.", EditorStyles.helpBox);
                GUI.backgroundColor = Color.white;
            }

            EditorGUI.BeginDisabledGroup(ObjectToSetup == null);
            if (GUILayout.Button("Setup AI"))
            {
                if (EditorUtility.DisplayDialog("Emerald AI Setup Manager", "Are you sure you'd like to setup an AI on this object?", "Setup", "Cancel"))
                {
                    #if UNITY_2018_3_OR_NEWER
                    PrefabAssetType m_AssetType = PrefabUtility.GetPrefabAssetType(ObjectToSetup);

                    //Only unpack prefab if the ObjectToSetup is a prefab.
                    if (m_AssetType != PrefabAssetType.NotAPrefab)
                    {
                        PrefabUtility.UnpackPrefabInstance(ObjectToSetup, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
                    }
                    #else
                    PrefabUtility.DisconnectPrefabInstance(ObjectToSetup);
                    #endif
                    AssignEmeraldAIComponents();
                    startVal = EditorApplication.timeSinceStartup;
                }
            }
            GUILayout.Space(25);
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
            GUILayout.Space(25);
            GUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();


            GUILayout.Space(30);

            if (secs > 0)
            {
                progress = EditorApplication.timeSinceStartup - startVal;

                if (progress < secs)
                {
                    EditorUtility.DisplayProgressBar("Emerald AI Setup Manager", "Setting up AI...", (float)(progress / secs));
                }
                else
                {
                    EditorUtility.ClearProgressBar();

                    if (DisplayConfirmation && !DontShowDisplayConfirmation)
                    {
                        if (EditorUtility.DisplayDialog("Emerald AI Setup Manager - Success", "Your AI has been successfully created! You will still need to create an Animator Controller, " +
                                                        "apply your AI's Animations, and assign the AI's Head Transform from within the Emerald AI Editor. You may also need to adjust the generated Box Collider's " +
                                                        "position and size to properly fit your AI's model.", "Okay", "Okay, Don't Show Again"))
                        {
                            DisplayConfirmation = false;
                        }
                        else
                        {
                            DisplayConfirmation         = false;
                            DontShowDisplayConfirmation = true;
                        }
                    }
                }
            }
        }
예제 #26
0
        public void OnGUI()
        {
            if (AssetStoreLoginWindow.styles == null)
            {
                AssetStoreLoginWindow.styles = new AssetStoreLoginWindow.Styles();
            }
            AssetStoreLoginWindow.LoadLogos();
            if (AssetStoreClient.LoginInProgress() || AssetStoreClient.LoggedIn())
            {
                GUI.enabled = false;
            }
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Space(10f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(5f);
            GUILayout.Label(AssetStoreLoginWindow.s_AssetStoreLogo, GUIStyle.none, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(false)
            });
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(6f);
            GUILayout.Label(this.m_LoginReason, EditorStyles.wordWrappedLabel, new GUILayoutOption[0]);
            Rect lastRect = GUILayoutUtility.GetLastRect();

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(6f);
            Rect lastRect2 = new Rect(0f, 0f, 0f, 0f);

            if (this.m_LoginRemoteMessage != null)
            {
                Color color = GUI.color;
                GUI.color = Color.red;
                GUILayout.Label(this.m_LoginRemoteMessage, EditorStyles.wordWrappedLabel, new GUILayoutOption[0]);
                GUI.color = color;
                lastRect2 = GUILayoutUtility.GetLastRect();
            }
            float num = lastRect.height + lastRect2.height + 110f;

            if (Event.current.type == EventType.Repaint && num != base.position.height)
            {
                base.position = new Rect(base.position.x, base.position.y, base.position.width, num);
                base.Repaint();
            }
            GUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUI.SetNextControlName("username");
            this.m_Username = EditorGUILayout.TextField("Username", this.m_Username, new GUILayoutOption[0]);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            this.m_Password = EditorGUILayout.PasswordField("Password", this.m_Password, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true)
            });
            if (GUILayout.Button(new GUIContent("Forgot?", "Reset your password"), AssetStoreLoginWindow.styles.link, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(false)
            }))
            {
                Application.OpenURL("https://accounts.unity3d.com/password/new");
            }
            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
            GUILayout.EndHorizontal();
            bool rememberSession = AssetStoreClient.RememberSession;
            bool flag            = EditorGUILayout.Toggle("Remember me", rememberSession, new GUILayoutOption[0]);

            if (flag != rememberSession)
            {
                AssetStoreClient.RememberSession = flag;
            }
            GUILayout.EndVertical();
            GUILayout.Space(5f);
            GUILayout.EndHorizontal();
            GUILayout.Space(8f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (GUILayout.Button("Create account", new GUILayoutOption[0]))
            {
                AssetStore.Open("createuser/");
                this.m_LoginRemoteMessage = "Cancelled - create user";
                base.Close();
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Cancel", new GUILayoutOption[0]))
            {
                this.m_LoginRemoteMessage = "Cancelled";
                base.Close();
            }
            GUILayout.Space(5f);
            if (GUILayout.Button("Login", new GUILayoutOption[0]))
            {
                this.DoLogin();
                base.Repaint();
            }
            GUILayout.Space(5f);
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.EndVertical();
            if (Event.current.Equals(Event.KeyboardEvent("return")))
            {
                this.DoLogin();
                base.Repaint();
            }
            if (this.m_Username == string.Empty)
            {
                EditorGUI.FocusTextInControl("username");
            }
        }
예제 #27
0
    void DrawBullet(int id)
    {
        if (!(id < mData.AnimationSkillList.Count))
        {
            return;
        }

        for (int i = 0; i < mData.AnimationSkillList[id].BulletStructList.Count; i++)
        {
            BulletStruct _eff = mData.AnimationSkillList[id].BulletStructList[i];

            EditorGUI.indentLevel++;
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            string _titleName = _eff.Bullet ? _eff.Bullet.name : "Bullet" + (i + 1).ToString();
            EditorGUILayout.BeginHorizontal();
            //此子特效的界面折叠
            _eff.isFoldout = EditorGUILayout.Foldout(_eff.isFoldout, _titleName);
            GUILayout.FlexibleSpace();
            //此子特效是否可用
            _eff.isEnabled = EditorGUILayout.Toggle("", _eff.isEnabled);

            if (GUILayout.Button("DELETE"))
            {
                mData.AnimationSkillList[id].BulletStructList.Remove(_eff);
                return;
            }

            EditorGUILayout.EndHorizontal();

            mData.AnimationSkillList[id].BulletStructList[i] = _eff;

            if (_eff.isFoldout)
            {
                EditorGUI.BeginDisabledGroup(!_eff.isEnabled);
                _eff.Bullet    = (GameObject)EditorGUILayout.ObjectField("Bullet", _eff.Bullet, typeof(GameObject), true);
                _eff.DelayTime = EditorGUILayout.FloatField("Delay Time", _eff.DelayTime);
                if (_eff.DelayTime > mData.AnimationSkillList[id].fTime)
                {
                    _eff.DelayTime = mData.AnimationSkillList [id].fTime;
                }

                string[] _nameArry = mData.VirtualPointList.ToArray();
                _eff.FirePointID   = EditorGUILayout.Popup("Fire Point", _eff.FirePointID, _nameArry);
                _eff.FirePointName = _nameArry[_eff.FirePointID];
                _eff.Offset        = EditorGUILayout.Vector3Field("Fire Offset", _eff.Offset);

                _eff.StartAudio       = (AudioClip)EditorGUILayout.ObjectField("StartAudio", _eff.StartAudio, typeof(AudioClip), true);
                _eff.StartEffect      = (GameObject)EditorGUILayout.ObjectField("StartEffect", _eff.StartEffect, typeof(GameObject), true);
                _eff.StartEffLifeTime = EditorGUILayout.FloatField("StartEffLifeTime", _eff.StartEffLifeTime);

                //特效运动方式
                _eff.moveType = (BulletStruct.MoveType)EditorGUILayout.EnumPopup("Move Type", _eff.moveType);
                switch (_eff.moveType)
                {
                case BulletStruct.MoveType.Line:
                {
                    _eff.Distance = EditorGUILayout.FloatField("Distance", _eff.Distance);
                }
                break;

                case BulletStruct.MoveType.TargetObject:
                {
                }
                break;
                }

                _eff.Speed = EditorGUILayout.FloatField("Speed", _eff.Speed);

                _eff.TouchAudio  = (AudioClip)EditorGUILayout.ObjectField("TouchAudio", _eff.TouchAudio, typeof(AudioClip), true);
                _eff.TouchEffect = (GameObject)EditorGUILayout.ObjectField("TouchEffect", _eff.TouchEffect, typeof(GameObject), true);

                _eff.TouchEffLifeTime = EditorGUILayout.FloatField("TouchEffLifeTime", _eff.TouchEffLifeTime);

                mData.AnimationSkillList[id].BulletStructList[i] = _eff;
            }
            EditorGUI.EndDisabledGroup();


            EditorGUILayout.EndVertical();
            EditorGUI.indentLevel--;
        }
    }
예제 #28
0
        public override void OnInspectorGUI()
        {
            if (texlogo == null)
            {
                Init();
            }
            //Rect imgRect = GUILayoutUtility.GetRect(Screen.width - 64, 32);
            //GUI.DrawTexture(imgRect, _logo, ScaleMode.ScaleToFit);

            BocsCyclesCamera script = (BocsCyclesCamera)target;

            bool needUpdate = false;

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(texSky, GUILayout.Width(45), GUILayout.Height(45)))
            {
                script.Nodes[0] = "node|t=BocsNodeOutput,x=940,y=60,c=0:node|t=BocsNodeBackground,x=530,y=40,c=0:node|t=BocsNodeSkyTexture,x=42,y=30,c=0:node|t=BocsNodeEnviromentTexture,x=80,y=200,c=0:val|n=1,s=color,v=FFFFFFFF:val|n=1,s=strength,v=0.75:val|n=2,s=sun_direction,v=0 0 1:val|n=2,s=turbidity,v=2.2:val|n=2,s=ground_albedo,v=0.3:val|n=3,s=filename,v=:val|n=3,s=color_space,v=1:val|n=3,s=use_alpha,v=True:val|n=3,s=interpolation,v=1:val|n=3,s=projection,v=0:connect|n1=1,n2=0,s1=background,s2=surface,:connect|n1=2,n2=1,s1=color,s2=color,:";
                UpdateNodeEditor();
                needUpdate = true;
            }
            if (GUILayout.Button(texSoftlight, GUILayout.Width(45), GUILayout.Height(45)))
            {
                script.Nodes[0] = "node|t=BocsNodeOutput,x=940,y=60,c=0:node|t=BocsNodeBackground,x=530,y=40,c=0:node|t=BocsNodeSkyTexture,x=42,y=30,c=0:node|t=BocsNodeEnviromentTexture,x=80,y=200,c=0:val|n=1,s=color,v=FFFFFFFF:val|n=1,s=strength,v=0.25:val|n=2,s=sun_direction,v=0 0 1:val|n=2,s=turbidity,v=2.2:val|n=2,s=ground_albedo,v=0.3:val|n=3,s=filename,v=:val|n=3,s=color_space,v=1:val|n=3,s=use_alpha,v=True:val|n=3,s=interpolation,v=1:val|n=3,s=projection,v=0:connect|n1=1,n2=0,s1=background,s2=surface,:";
                UpdateNodeEditor();
                needUpdate = true;
            }
            if (GUILayout.Button(texHDR, GUILayout.Width(45), GUILayout.Height(45)))
            {
                script.Nodes[0] = "node|t=BocsNodeOutput,x=940,y=60,c=0:node|t=BocsNodeBackground,x=530,y=40,c=0:node|t=BocsNodeSkyTexture,x=42,y=30,c=0:node|t=BocsNodeEnviromentTexture,x=80,y=200,c=0:val|n=1,s=color,v=FFFFFFFF:val|n=1,s=strength,v=0.5:val|n=2,s=sun_direction,v=0 0 1:val|n=2,s=turbidity,v=2.2:val|n=2,s=ground_albedo,v=0.3:val|n=3,s=filename,v=12a586c687c7a544890dc2fe09370550:val|n=3,s=color_space,v=1:val|n=3,s=use_alpha,v=True:val|n=3,s=interpolation,v=1:val|n=3,s=projection,v=0:connect|n1=1,n2=0,s1=background,s2=surface,:connect|n1=3,n2=1,s1=color,s2=color,:";
                UpdateNodeEditor();
                needUpdate = true;
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            if (GUILayout.Button("Background Shader Editor"))
            {
                EditorWindow.GetWindow <EditorNodeEdit>();
            }

            quick = EditorGUILayout.Foldout(quick, "Quick Settings");
            if (quick)
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);

                EditorGUI.BeginChangeCheck();

                script._type = EditorGUILayout.Popup("Projection", script._type, script._types);

                script._fov     = EditorGUILayout.FloatField("Field of View", script._fov);
                script._farclip = EditorGUILayout.FloatField("Far Clip", script._farclip);

                script._exposure = EditorGUILayout.FloatField("Exposure", script._exposure);

                //script._aperturesize = EditorGUILayout.FloatField("Aperture Size", script._aperturesize);

                //EditorGUILayout.BeginHorizontal();
                //script._focaldistance = EditorGUILayout.FloatField("Focal Distance", script._focaldistance);
                //EditorGUILayout.EndHorizontal();

                script._visibility = (BocsCyclesCamera.PathRayFlag)EditorGUILayout.EnumMaskField("Background Visibility", (System.Enum)script._visibility);
                script._use_shader = GUILayout.Toggle(script._use_shader, "Use Shader");

                script._filter_glossy            = EditorGUILayout.FloatField("Filter Glossy", script._filter_glossy);
                script._sample_clamp_direct      = EditorGUILayout.FloatField("Clamp Direct", script._sample_clamp_direct);
                script._sample_clamp_indirect    = EditorGUILayout.FloatField("Clamp Indirect", script._sample_clamp_indirect);
                script._light_sampling_threshold = EditorGUILayout.FloatField("Light Sampling Threshold", script._light_sampling_threshold);

                script._caustics_reflective = GUILayout.Toggle(script._caustics_reflective, "Reflective Caustics");
                script._caustics_refractive = GUILayout.Toggle(script._caustics_refractive, "Refractive Caustics");

                if (EditorGUI.EndChangeCheck())
                {
                    needUpdate = true;
                }
                EditorGUILayout.EndVertical();
            }

            camera = EditorGUILayout.Foldout(camera, "Camera");
            if (camera)
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);

                EditorGUI.BeginChangeCheck();

                script._shuttertime = EditorGUILayout.FloatField("Shutter Time", script._shuttertime);

                script._motion_position          = EditorGUILayout.Popup("Motion Positon", script._motion_position, script._motion_positions);
                script._rolling_shutter_type     = EditorGUILayout.Popup("Rolling Shutter Type", script._rolling_shutter_type, script._rolling_shutter_types);
                script._rolling_shutter_duration = EditorGUILayout.FloatField("Rolling Shutter Duration", script._rolling_shutter_duration);

                script._aperturesize = EditorGUILayout.FloatField("Aperture Size", script._aperturesize);

                EditorGUILayout.BeginHorizontal();
                script._focaldistance = EditorGUILayout.FloatField("Focal Distance", script._focaldistance);
                EditorGUILayout.EndHorizontal();

                script._blades         = EditorGUILayout.IntField("Blades", script._blades);
                script._bladesrotation = EditorGUILayout.FloatField("Blades Rotation", script._bladesrotation);

                script._aperture_ratio = EditorGUILayout.FloatField("Aperture Ratio", script._aperture_ratio);

                script._type = EditorGUILayout.Popup("Projection", script._type, script._types);

                script._panorama_type = EditorGUILayout.Popup("Panorama", script._panorama_type, script._panorama_types);

                script._fisheye_fov  = EditorGUILayout.FloatField("Fisheye Field of View", script._fisheye_fov);
                script._fisheye_lens = EditorGUILayout.FloatField("Fisheye Lens", script._fisheye_lens);

                //public float _latitude_min = -1.5707f;
                //public float _latitude_max = 1.5707f;
                //public float _longitude_min = -3.141592f;
                //public float _longitude_max = 3.141592f;

                script._fov      = EditorGUILayout.FloatField("Field of View", script._fov);
                script._fov_pre  = EditorGUILayout.FloatField("Field of View Pre", script._fov_pre);
                script._fov_post = EditorGUILayout.FloatField("Field of View Post", script._fov_post);

                script._stereo_eye           = EditorGUILayout.Popup("Stereo Eye", script._stereo_eye, script._stereo_eyes);
                script._interocular_distance = EditorGUILayout.FloatField("Interocular Distance", script._interocular_distance);
                script._convergence_distance = EditorGUILayout.FloatField("Convergence Distance", script._convergence_distance);

                script._nearclip = EditorGUILayout.FloatField("Near Clip", script._nearclip);
                script._farclip  = EditorGUILayout.FloatField("Far Clip", script._farclip);

                //SOCKET_FLOAT(viewplane.left, "Viewplane Left", 0);
                //SOCKET_FLOAT(viewplane.right, "Viewplane Right", 0);
                //SOCKET_FLOAT(viewplane.bottom, "Viewplane Bottom", 0);
                //SOCKET_FLOAT(viewplane.top, "Viewplane Top", 0);

                //SOCKET_FLOAT(border.left, "Border Left", 0);
                //SOCKET_FLOAT(border.right, "Border Right", 0);
                //SOCKET_FLOAT(border.bottom, "Border Bottom", 0);
                //SOCKET_FLOAT(border.top, "Border Top", 0);

                if (EditorGUI.EndChangeCheck())
                {
                    needUpdate = true;
                }
                EditorGUILayout.EndVertical();
            }

            background = EditorGUILayout.Foldout(background, "Background");
            if (background)
            {
                GUILayout.BeginVertical(GUI.skin.box);
                EditorGUI.BeginChangeCheck();

                script._use_ao      = GUILayout.Toggle(script._use_ao, "Use AO");
                script._ao_factor   = EditorGUILayout.FloatField("AO Factor", script._ao_factor);
                script._ao_distance = EditorGUILayout.FloatField("AO Distance", script._ao_distance);
                script._use_shader  = GUILayout.Toggle(script._use_shader, "Use Shader");

                script._visibility = (BocsCyclesCamera.PathRayFlag)EditorGUILayout.EnumMaskField("Visibility", (System.Enum)script._visibility);

                if (EditorGUI.EndChangeCheck())
                {
                    needUpdate = true;
                }
                GUILayout.EndVertical();
            }

            film = EditorGUILayout.Foldout(film, "Film");
            if (film)
            {
                GUILayout.BeginVertical(GUI.skin.box);
                EditorGUI.BeginChangeCheck();

                script._exposure = EditorGUILayout.FloatField("Exposure", script._exposure);

                script._filter_type  = EditorGUILayout.Popup("Filter Type", script._filter_type, script._filter_types);
                script._filter_width = EditorGUILayout.FloatField("Filter Width", script._filter_width);

                script._mist_start   = EditorGUILayout.FloatField("Mist Start", script._mist_start);
                script._mist_depth   = EditorGUILayout.FloatField("Mist Depth", script._mist_depth);
                script._mist_falloff = EditorGUILayout.FloatField("Mist Falloff", script._mist_falloff);

                script._use_sample_clamp = GUILayout.Toggle(script._use_sample_clamp, "Use Sample Clamp");

                if (EditorGUI.EndChangeCheck())
                {
                    needUpdate = true;
                }
                GUILayout.EndVertical();
            }

            integrator = EditorGUILayout.Foldout(integrator, "Integrator");
            if (integrator)
            {
                GUILayout.BeginVertical(GUI.skin.box);
                EditorGUI.BeginChangeCheck();

                script._min_bounce = EditorGUILayout.IntField("Min Bounce", script._min_bounce);
                script._max_bounce = EditorGUILayout.IntField("Max Bounce", script._max_bounce);

                script._max_diffuse_bounce      = EditorGUILayout.IntField("Max Diffuse Bounce", script._max_diffuse_bounce);
                script._max_glossy_bounce       = EditorGUILayout.IntField("Max Glossy Bounce", script._max_glossy_bounce);
                script._max_transmission_bounce = EditorGUILayout.IntField("Max Transmission Bounce", script._max_transmission_bounce);
                script._max_volume_bounce       = EditorGUILayout.IntField("Max Volume Bounce", script._max_volume_bounce);

                script._transparent_min_bounce = EditorGUILayout.IntField("Min Transparent Bounce", script._transparent_min_bounce);
                script._transparent_max_bounce = EditorGUILayout.IntField("Max Transparent Bounce", script._transparent_max_bounce);

                script._transparent_shadows = GUILayout.Toggle(script._transparent_shadows, "Transparent Shadows");

                script._ao_bounces = EditorGUILayout.IntField("AO Bounces", script._ao_bounces);

                script._volume_max_steps = EditorGUILayout.IntField("Max Volume Steps", script._volume_max_steps);
                script._volume_step_size = EditorGUILayout.FloatField("Volume Step Size", script._volume_step_size);

                script._caustics_reflective = GUILayout.Toggle(script._caustics_reflective, "Reflective Caustics");
                script._caustics_refractive = GUILayout.Toggle(script._caustics_refractive, "Refractive Caustics");

                script._filter_glossy         = EditorGUILayout.FloatField("Filter Glossy", script._filter_glossy);
                script._sample_clamp_direct   = EditorGUILayout.FloatField("Clamp Direct", script._sample_clamp_direct);
                script._sample_clamp_indirect = EditorGUILayout.FloatField("Clamp Indirect", script._sample_clamp_indirect);

                script._motion_blur = GUILayout.Toggle(script._motion_blur, "Motion Blur");

                script._aa_samples           = EditorGUILayout.IntField("AA Samples", script._aa_samples);
                script._diffuse_samples      = EditorGUILayout.IntField("Diffuse Samples", script._diffuse_samples);
                script._glossy_samples       = EditorGUILayout.IntField("Glossy Samples", script._glossy_samples);
                script._transmission_samples = EditorGUILayout.IntField("Transmission Samples", script._transmission_samples);
                script._ao_samples           = EditorGUILayout.IntField("AO Samples", script._ao_samples);
                script._mesh_light_samples   = EditorGUILayout.IntField("Mesh Light Samples", script._mesh_light_samples);
                script._subsurface_samples   = EditorGUILayout.IntField("Subsurface Samples", script._subsurface_samples);
                script._volume_samples       = EditorGUILayout.IntField("Volume Samples", script._volume_samples);

                script._sample_all_lights_direct   = GUILayout.Toggle(script._sample_all_lights_direct, "Sample All Lights Direct");
                script._sample_all_lights_indirect = GUILayout.Toggle(script._sample_all_lights_indirect, "Sample All Lights Indirect");
                script._light_sampling_threshold   = EditorGUILayout.FloatField("Light Sampling Threshold", script._light_sampling_threshold);

                script._method           = EditorGUILayout.Popup("Path Type", script._method, script._methods);
                script._sampling_pattern = EditorGUILayout.Popup("Sampling Pattern", script._sampling_pattern, script._sampling_patterns);

                if (EditorGUI.EndChangeCheck())
                {
                    needUpdate = true;
                }
                GUILayout.EndVertical();
            }

            //Some Checks...
            if (script._nearclip <= 0)
            {
                script._nearclip = .001f;
            }

            if (needUpdate)
            {
                BocsCyclesAPI.Cycles_request_settings();
                BocsCyclesAPI.Cycles_request_reset();
            }

            debug = EditorGUILayout.Foldout(debug, "Debug");
            if (debug)
            {
                //Debug.Log(script.GetShaderCount());
                for (int i = 0; i < script.GetGraphCount(); i++)
                {
                    //GUILayout.TextField(script._nodes);
                    GUI.skin.textArea.wordWrap = false;
                    EditorGUILayout.TextArea(script.Nodes[i]);
                }
            }
        }
예제 #29
0
    protected void OnGUI()
    {
        if (m_ShowGUI)
        {
            InitializeOnGUI();

            // Up

            GUILayout.BeginArea(m_ScaledScreenRect);

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

            GUILayout.BeginVertical();
            GUILayout.Space(topBorder * borderScale);

            upPressed = GUILayout.RepeatButton(upArrow, m_CircleButtonStyle);

            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();

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

            GUILayout.EndArea();


            // Down

            GUILayout.BeginArea(m_ScaledScreenRect);

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

            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();

            downPressed = GUILayout.RepeatButton(downArrow, m_CircleButtonStyle);

            GUILayout.Space(bottomBorder * borderScale);
            GUILayout.EndVertical();

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

            GUILayout.EndArea();


            // Left

            GUILayout.BeginArea(m_ScaledScreenRect);

            GUILayout.BeginHorizontal();
            GUILayout.Space(leftBorder * borderScale);

            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();

            leftPressed = GUILayout.RepeatButton(leftArrow, m_CircleButtonStyle);

            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();

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

            GUILayout.EndArea();


            // Right

            GUILayout.BeginArea(m_ScaledScreenRect);

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

            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();

            rightPressed = GUILayout.RepeatButton(rightArrow, m_CircleButtonStyle);

            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();

            GUILayout.Space(rightBorder * borderScale);
            GUILayout.EndHorizontal();

            GUILayout.EndArea();


            // Minus and plus

            GUILayout.BeginArea(m_ScaledScreenRect);

            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();

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

            minusPressed = GUILayout.RepeatButton(minus, m_CircleButtonStyle);
            GUILayout.Space(defaultSpace * spaceScale);
            plusPressed = GUILayout.RepeatButton(plus, m_CircleButtonStyle);

            GUILayout.Space(rightBorder * borderScale);
            GUILayout.EndHorizontal();

            GUILayout.Space(bottomBorder * borderScale);
            GUILayout.EndVertical();

            GUILayout.EndArea();


            // Switch

            if (showSwitchButton)
            {
                GUILayout.BeginArea(m_ScaledScreenRect);

                GUILayout.BeginVertical();
                GUILayout.Space(topBorder * borderScale);

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

                switchPressed = GUILayout.Button("Switch");

                GUILayout.Space(rightBorder * borderScale);
                GUILayout.EndHorizontal();

                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();

                GUILayout.EndArea();
            }
        }
    }
예제 #30
0
    // ReSharper disable once UnusedMember.Local
    // ReSharper disable once InconsistentNaming
    void OnGUI()
    {
        _scrollPos = GUI.BeginScrollView(
            new Rect(0, 0, position.width, position.height),
            _scrollPos,
            new Rect(0, 0, 550, 570)
            );

        PlaylistController.Instances = null;
        var pcs = PlaylistController.Instances;
        // ReSharper disable once PossibleNullReferenceException
        var plControllerInScene = pcs.Count > 0;

        if (MasterAudioInspectorResources.LogoTexture != null)
        {
            DTGUIHelper.ShowHeaderTexture(MasterAudioInspectorResources.LogoTexture);
        }

        if (Application.isPlaying)
        {
            DTGUIHelper.ShowLargeBarAlert("This screen cannot be used during play.");
            GUI.EndScrollView();
            return;
        }

        DTGUIHelper.HelpHeader("https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/MasterAudioManager.htm");

        var settings = MasterAudioInspectorResources.GearTexture;

        MasterAudio.Instance = null;
        var ma        = MasterAudio.Instance;
        var maInScene = ma != null;

        var organizer    = FindObjectOfType(typeof(SoundGroupOrganizer));
        var hasOrganizer = organizer != null;

        DTGUIHelper.ShowColorWarning("The Master Audio prefab holds sound FX group and mixer controls. Add this first (only one per scene).");
        EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);

        EditorGUILayout.LabelField("Master Audio prefab", GUILayout.Width(300));
        if (!maInScene)
        {
            GUI.contentColor = DTGUIHelper.BrightButtonColor;
            if (GUILayout.Button(new GUIContent("Create", "Create Master Audio prefab"), EditorStyles.toolbarButton, GUILayout.Width(100)))
            {
                var go = MasterAudio.CreateMasterAudio();
                AudioUndoHelper.CreateObjectForUndo(go, "Create Master Audio prefab");
            }
            GUI.contentColor = Color.white;
        }
        else
        {
            if (settings != null)
            {
                if (GUILayout.Button(new GUIContent(settings, "Master Audio Settings"), EditorStyles.toolbarButton))
                {
                    Selection.activeObject = ma.transform;
                }
            }
            GUILayout.Label("Exists in scene", EditorStyles.boldLabel);
        }

        GUILayout.FlexibleSpace();
        DTGUIHelper.AddHelpIcon("https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/MasterAudioManager.htm#MAGO");
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Separator();

        // Playlist Controller
        DTGUIHelper.ShowColorWarning("The Playlist Controller prefab controls sets of songs (or other audio) and ducking. No limit per scene.");
        EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
        EditorGUILayout.LabelField("Playlist Controller prefab", GUILayout.Width(300));

        GUI.contentColor = DTGUIHelper.BrightButtonColor;
        if (GUILayout.Button(new GUIContent("Create", "Place a Playlist Controller prefab in the current scene."), EditorStyles.toolbarButton, GUILayout.Width(100)))
        {
            var go = MasterAudio.CreatePlaylistController();
            AudioUndoHelper.CreateObjectForUndo(go, "Create Playlist Controller prefab");
        }
        GUI.contentColor = Color.white;

        GUILayout.FlexibleSpace();
        DTGUIHelper.AddHelpIcon("https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/MasterAudioManager.htm#PCGO");
        EditorGUILayout.EndHorizontal();
        if (!plControllerInScene)
        {
            DTGUIHelper.ShowLargeBarAlert("There is no Playlist Controller in the scene. Music will not play.");
        }

        EditorGUILayout.Separator();
        // Dynamic Sound Group Creators
        DTGUIHelper.ShowColorWarning("The Dynamic Sound Group Creator prefab can per-Scene Sound Groups and other audio. No limit per scene.");
        EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
        EditorGUILayout.LabelField("Dynamic Sound Group Creator prefab", GUILayout.Width(300));

        GUI.contentColor = DTGUIHelper.BrightButtonColor;
        if (GUILayout.Button(new GUIContent("Create", "Place a Dynamic Sound Group prefab in the current scene."), EditorStyles.toolbarButton, GUILayout.Width(100)))
        {
            var go = MasterAudio.CreateDynamicSoundGroupCreator();
            AudioUndoHelper.CreateObjectForUndo(go, "Create Dynamic Sound Group Creator prefab");
        }

        GUI.contentColor = Color.white;

        GUILayout.FlexibleSpace();
        DTGUIHelper.AddHelpIcon("https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/MasterAudioManager.htm#DSGC");
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.Separator();
        // Sound Group Organizer
        DTGUIHelper.ShowColorWarning("The Sound Group Organizer prefab can import/export Groups to/from MA and Dynamic SGC prefabs.");
        EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
        EditorGUILayout.LabelField("Sound Group Organizer prefab", GUILayout.Width(300));

        if (hasOrganizer)
        {
            if (settings != null)
            {
                if (GUILayout.Button(new GUIContent(settings, "Sound Group Organizer Settings"), EditorStyles.toolbarButton))
                {
                    Selection.activeObject = organizer;
                }
            }
            GUILayout.Label("Exists in scene", EditorStyles.boldLabel);
        }
        else
        {
            GUI.contentColor = DTGUIHelper.BrightButtonColor;
            if (GUILayout.Button(new GUIContent("Create", "Place a Sound Group Organizer prefab in the current scene."), EditorStyles.toolbarButton, GUILayout.Width(100)))
            {
                var go = MasterAudio.CreateSoundGroupOrganizer();
                AudioUndoHelper.CreateObjectForUndo(go, "Create Dynamic Sound Group Creator prefab");
            }
        }

        GUI.contentColor = Color.white;

        GUILayout.FlexibleSpace();
        DTGUIHelper.AddHelpIcon("https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/MasterAudioManager.htm#SGO");
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.Separator();

        if (!Application.isPlaying)
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            GUILayout.Label("Global Settings");
            DTGUIHelper.AddHelpIcon("https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/MasterAudioManager.htm#GlobalSettings");
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            var newVol = GUILayout.Toggle(MasterAudio.UseDbScaleForVolume, " Display dB For Volumes");
            // ReSharper disable once RedundantCheckBeforeAssignment
            if (newVol != MasterAudio.UseDbScaleForVolume)
            {
                MasterAudio.UseDbScaleForVolume = newVol;
            }

            GUILayout.Space(30);

            var newCents = GUILayout.Toggle(MasterAudio.UseCentsForPitch, " Display Semitones for Pitches");
            // ReSharper disable once RedundantCheckBeforeAssignment
            if (newCents != MasterAudio.UseCentsForPitch)
            {
                MasterAudio.UseCentsForPitch = newCents;
            }

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();

            var useLogo = GUILayout.Toggle(MasterAudio.HideLogoNav, " Hide Logo Nav. in Inspectors");
            // ReSharper disable once RedundantCheckBeforeAssignment
            if (useLogo != MasterAudio.HideLogoNav)
            {
                MasterAudio.HideLogoNav = useLogo;
            }

            if (!Application.isPlaying)
            {
                EditorGUILayout.BeginHorizontal();
                MasterAudio._editMAFolder = GUILayout.Toggle(MasterAudio._editMAFolder, " Edit Installation Path");

                if (MasterAudio._editMAFolder)
                {
                    var path = EditorGUILayout.TextField("", MasterAudio.ProspectiveMAPath);
                    // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
                    if (!string.IsNullOrEmpty(path))
                    {
                        MasterAudio.ProspectiveMAPath = path;
                    }
                    else
                    {
                        MasterAudio.ProspectiveMAPath = MasterAudio.MasterAudioFolderPath;
                    }
                    GUI.contentColor = DTGUIHelper.BrightButtonColor;
                    if (
                        GUILayout.Button(
                            new GUIContent("Update",
                                           "This will update the installation folder path with the value to the left."),
                            EditorStyles.toolbarButton, GUILayout.Width(60)))
                    {
                        MasterAudio.MasterAudioFolderPath = MasterAudio.ProspectiveMAPath;
                        DTGUIHelper.ShowAlert("Installation Path updated!");
                    }
                    GUILayout.Space(4);
                    if (GUILayout.Button(new GUIContent("Revert", "Revert to default settings"),
                                         EditorStyles.toolbarButton, GUILayout.Width(60)))
                    {
                        MasterAudio.MasterAudioFolderPath = MasterAudio.MasterAudioDefaultFolder;
                        MasterAudio.ProspectiveMAPath     = MasterAudio.MasterAudioDefaultFolder;
                        DTGUIHelper.ShowAlert("Installation Path reverted!");
                    }
                    GUI.contentColor = Color.white;
                    GUILayout.Space(10);
                    DTGUIHelper.AddHelpIcon("https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/InstallationFolder.htm");
                }
                else
                {
                    DTGUIHelper.AddHelpIcon("https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/InstallationFolder.htm");
                    GUILayout.FlexibleSpace();
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.Separator();

            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            GUILayout.Label("Utility Functions");
            DTGUIHelper.AddHelpIcon("https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/MasterAudioManager.htm#UtilityFunctions");
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(10);
            GUI.contentColor = DTGUIHelper.BrightButtonColor;
            if (GUILayout.Button(new GUIContent("Delete all unused Filter FX", "This will delete all unused Unity Audio Filter FX components in the entire MasterAudio prefab and all Sound Groups within."), EditorStyles.toolbarButton, GUILayout.Width(160)))
            {
                DeleteAllUnusedFilterFx();
            }

            GUILayout.Space(10);

            if (GUILayout.Button(new GUIContent("Reset Prefs / Settings", "This will delete all Master Audio's Persistent Settings and global preferences (back to installation default). None of your prefabs will be deleted."), EditorStyles.toolbarButton, GUILayout.Width(160)))
            {
                ResetPrefs();
            }

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

                if (GUILayout.Button(new GUIContent("Upgrade MA Prefab to V3.5.5", "This will upgrade all Sound Groups in the entire MasterAudio prefab and all Sound Groups within to the latest changes, including a new script in V3.5.5."), EditorStyles.toolbarButton, GUILayout.Width(160)))
                {
                    UpgradeMasterAudioPrefab();
                }
            }

            GUI.contentColor = Color.white;
            EditorGUILayout.EndHorizontal();
        }

        GUI.EndScrollView();
    }