示例#1
0
    public static void InspectorGUI(BuildrEditMode editMode, BuildrData data)
    {
        BuildrDetail[] details         = data.details.ToArray();
        int            numberOfDetails = details.Length;

        selectedDetail = Mathf.Clamp(selectedDetail, 0, numberOfDetails - 1);

        if (numberOfDetails == 0)
        {
            EditorGUILayout.HelpBox("There are no details to show", MessageType.Info);
            if (GUILayout.Button("Add New"))
            {
                data.details.Add(new BuildrDetail("new detail " + numberOfDetails));
                numberOfDetails++;
                selectedDetail = numberOfDetails - 1;
            }
            return;
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Detail", GUILayout.Width(75));
        string[] detailNames = new string[numberOfDetails];
        for (int t = 0; t < numberOfDetails; t++)
        {
            detailNames[t] = details[t].name;
        }
        selectedDetail = EditorGUILayout.Popup(selectedDetail, detailNames);
        EditorGUILayout.EndHorizontal();

        BuildrDetail bDetail = details[selectedDetail];

        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.Space();

        if (GUILayout.Button("Add New", GUILayout.Width(81)))
        {
            data.details.Add(new BuildrDetail("new detail " + numberOfDetails));
            numberOfDetails++;
            selectedDetail = numberOfDetails - 1;
        }


        if (GUILayout.Button("Duplicate", GUILayout.Width(90)))
        {
            data.details.Add(bDetail.Duplicate());
            numberOfDetails++;
            selectedDetail = numberOfDetails - 1;
        }

        if (GUILayout.Button("Delete", GUILayout.Width(71)))
        {
            if (EditorUtility.DisplayDialog("Deleting Building Detail Entry", "Are you sure you want to delete this detail?", "Delete", "Cancel"))
            {
                data.details.Remove(bDetail);
                selectedDetail = 0;
                GUI.changed    = true;

                return;
            }
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();

        details     = data.details.ToArray();
        detailNames = new string[numberOfDetails];
        for (int t = 0; t < numberOfDetails; t++)
        {
            detailNames[t] = details[t].name;
        }
        bDetail = details[selectedDetail];//reassign

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.BeginVertical();

        bDetail.name = EditorGUILayout.TextField("Name", bDetail.name);

        bDetail.mesh = (Mesh)EditorGUILayout.ObjectField("Mesh", bDetail.mesh, typeof(Mesh), false);
        EditorGUIUtility.LookLikeControls();
        bDetail.material.mainTexture = (Texture)EditorGUILayout.ObjectField("Texture", bDetail.material.mainTexture, typeof(Texture), false, GUILayout.Height(140));

        if (bDetail.material.mainTexture != null)
        {
            string          texturePath     = AssetDatabase.GetAssetPath(bDetail.material.mainTexture);
            TextureImporter textureImporter = (TextureImporter)AssetImporter.GetAtPath(texturePath);

            if (!textureImporter.isReadable)
            {
                EditorGUILayout.HelpBox("The texture you have selected is not readable." +
                                        "\nPlease select the readable checkbox under advanced texture settings." +
                                        "\nOr move this texture to the BuildR texture folder and reimport.",
                                        MessageType.Error);
            }
        }

        BuildrPlan    plan                    = data.plan;
        int           numberOfVolumes         = plan.numberOfVolumes;
        int           numberOfFaces           = 0;
        List <int>    faceSeletionsList       = new List <int>();
        List <string> faceSeletionsStringList = new List <string>();

        if (bDetail.type == BuildrDetail.Types.Facade)
        {
            for (int s = 0; s < numberOfVolumes; s++)
            {
                int numberOfPoints = plan.volumes[s].Count;
                numberOfFaces += numberOfPoints;
                for (int p = 0; p < numberOfPoints; p++)
                {
                    int index = faceSeletionsList.Count;
                    faceSeletionsStringList.Add("facade " + index);
                    faceSeletionsList.Add(index);
                }
            }
        }
        else
        {
            bDetail.face = Mathf.Clamp(0, numberOfVolumes - 1, bDetail.face);
            for (int s = 0; s < numberOfVolumes; s++)
            {
                int index = faceSeletionsList.Count;
                faceSeletionsStringList.Add("roof " + index);
                faceSeletionsList.Add(index);
            }
        }

        if (!clickPlace)
        {
            if (GUILayout.Button("Place Detail with Mouse"))
            {
                clickPlace = true;
            }
        }
        else
        {
            if (GUILayout.Button("Cancel Place Detail"))
            {
                clickPlace = false;
            }
        }

        BuildrDetail.Types bDetailtype = (BuildrDetail.Types)EditorGUILayout.EnumPopup("Face Type", bDetail.type);
        if (bDetailtype != bDetail.type)
        {
            bDetail.type = bDetailtype;
        }
        int[]    faceSelections      = faceSeletionsList.ToArray();
        string[] faceSelectionString = faceSeletionsStringList.ToArray();
        int      bDetailface         = EditorGUILayout.IntPopup("Selected Face", bDetail.face, faceSelectionString, faceSelections);

        if (bDetailface != bDetail.face)
        {
            bDetail.face = bDetailface;
        }

        Vector2 bDetailfaceUv = EditorGUILayout.Vector2Field("Face UV", bDetail.faceUv);

        if (bDetailfaceUv != bDetail.faceUv)
        {
            bDetail.faceUv = bDetailfaceUv;
        }
        float bDetailfaceHeight = EditorGUILayout.FloatField("Face Height", bDetail.faceHeight);

        if (bDetailfaceHeight != bDetail.faceHeight)
        {
            bDetail.faceHeight = bDetailfaceHeight;
        }
        Vector3 bDetailuserRotation = EditorGUILayout.Vector3Field("Rotation", bDetail.userRotation);

        if (bDetailuserRotation != bDetail.userRotation)
        {
            bDetail.userRotation = bDetailuserRotation;
        }
        Vector3 bDetailscale = EditorGUILayout.Vector3Field("Object Scale", bDetail.scale);

        if (bDetailscale != bDetail.scale)
        {
            bDetail.scale = bDetailscale;
        }

        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical(GUILayout.Width(120));
        if (bDetail.mesh != null)
        {
            Texture2D previewMeshImage = AssetPreview.GetAssetPreview(bDetail.mesh);
            GUILayout.Label(previewMeshImage);
        }
        else
        {
            Texture2D previewMeshImage = new Texture2D(118, 118);
            GUILayout.Label(previewMeshImage);
            GUILayout.Label("No Mesh Selected");
        }

        if (bDetail.material.mainTexture != null)
        {
            Texture previewMeshImage = bDetail.material.mainTexture;
            GUILayout.Label(previewMeshImage, GUILayout.Width(128), GUILayout.Height(128));
        }
        else
        {
            Texture2D previewMeshImage = new Texture2D(118, 118);
            GUILayout.Label(previewMeshImage);
            GUILayout.Label("No Texture Selected");
        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();
    }
        public override void OnInspectorGUI(NavGraph target)
        {
            GridGraph graph = target as GridGraph;

            //GUILayout.BeginHorizontal ();
            //GUILayout.BeginVertical ();
            Rect lockRect;

            GUIStyle lockStyle = AstarPathEditor.astarSkin.FindStyle("GridSizeLock");

            if (lockStyle == null)
            {
                lockStyle = new GUIStyle();
            }

        #if !UNITY_LE_4_3 || true
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            int newWidth = EditorGUILayout.IntField(new GUIContent("Width (nodes)", "Width of the graph in nodes"), graph.width);
            int newDepth = EditorGUILayout.IntField(new GUIContent("Depth (nodes)", "Depth (or height you might also call it) of the graph in nodes"), graph.depth);
            GUILayout.EndVertical();

            lockRect = GUILayoutUtility.GetRect(lockStyle.fixedWidth, lockStyle.fixedHeight);

            // Add a small offset to make it better centred around the controls
            lockRect.y += 3;
            GUILayout.EndHorizontal();

            // All the layouts mess up the margin to the next control, so add it manually
            GUILayout.Space(2);
        #elif UNITY_4
            Rect tmpLockRect;
            int  newWidth = IntField(new GUIContent("Width (nodes)", "Width of the graph in nodes"), graph.width, 100, 0, out lockRect, out sizeSelected1);
            int  newDepth = IntField(new GUIContent("Depth (nodes)", "Depth (or height you might also call it) of the graph in nodes"), graph.depth, 100, 0, out tmpLockRect, out sizeSelected2);
        #else
            Rect tmpLockRect;
            int  newWidth = IntField(new GUIContent("Width (nodes)", "Width of the graph in nodes"), graph.width, 50, 0, out lockRect, out sizeSelected1);
            int  newDepth = IntField(new GUIContent("Depth (nodes)", "Depth (or height you might also call it) of the graph in nodes"), graph.depth, 50, 0, out tmpLockRect, out sizeSelected2);
        #endif

            lockRect.width  = lockStyle.fixedWidth;
            lockRect.height = lockStyle.fixedHeight;
            lockRect.x     += lockStyle.margin.left;
            lockRect.y     += lockStyle.margin.top;

            locked = GUI.Toggle(lockRect, locked, new GUIContent("", "If the width and depth values are locked, changing the node size will scale the grid which keeping the number of nodes consistent instead of keeping the size the same and changing the number of nodes in the graph"), lockStyle);

            //GUILayout.EndHorizontal ();

            if (newWidth != graph.width || newDepth != graph.depth)
            {
                SnapSizeToNodes(newWidth, newDepth, graph);
            }

            GUI.SetNextControlName("NodeSize");
            newNodeSize = EditorGUILayout.FloatField(new GUIContent("Node size", "The size of a single node. The size is the side of the node square in world units"), graph.nodeSize);

            newNodeSize = newNodeSize <= 0.01F ? 0.01F : newNodeSize;

            float prevRatio = graph.aspectRatio;
            graph.aspectRatio = EditorGUILayout.FloatField(new GUIContent("Aspect Ratio", "Scaling of the nodes width/depth ratio. Good for isometric games"), graph.aspectRatio);

            graph.isometricAngle = EditorGUILayout.FloatField(new GUIContent("Isometric Angle", "For an isometric 2D game, you can use this parameter to scale the graph correctly."), graph.isometricAngle);

            if (graph.nodeSize != newNodeSize || prevRatio != graph.aspectRatio)
            {
                if (!locked)
                {
                    graph.nodeSize = newNodeSize;
                    Matrix4x4 oldMatrix = graph.matrix;
                    graph.GenerateMatrix();
                    if (graph.matrix != oldMatrix)
                    {
                        //Rescann the graphs
                        //AstarPath.active.AutoScan ();
                        GUI.changed = true;
                    }
                }
                else
                {
                    float delta = newNodeSize / graph.nodeSize;
                    graph.nodeSize      = newNodeSize;
                    graph.unclampedSize = new Vector2(newWidth * graph.nodeSize, newDepth * graph.nodeSize);
                    Vector3 newCenter = graph.matrix.MultiplyPoint3x4(new Vector3((newWidth / 2F) * delta, 0, (newDepth / 2F) * delta));
                    graph.center = newCenter;
                    graph.GenerateMatrix();

                    //Make sure the width & depths stay the same
                    graph.width = newWidth;
                    graph.depth = newDepth;
                    AutoScan();
                }
            }

            Vector3 pivotPoint;
            Vector3 diff;

        #if UNITY_LE_4_3
            EditorGUIUtility.LookLikeControls();
        #endif

        #if !UNITY_4
            EditorGUILayoutx.BeginIndent();
        #else
            GUILayout.BeginHorizontal();
        #endif

            switch (pivot)
            {
            case GridPivot.Center:
                graph.center = RoundVector3(graph.center);
                graph.center = EditorGUILayout.Vector3Field("Center", graph.center);
                break;

            case GridPivot.TopLeft:
                pivotPoint   = graph.matrix.MultiplyPoint3x4(new Vector3(0, 0, graph.depth));
                pivotPoint   = RoundVector3(pivotPoint);
                diff         = pivotPoint - graph.center;
                pivotPoint   = EditorGUILayout.Vector3Field("Top-Left", pivotPoint);
                graph.center = pivotPoint - diff;
                break;

            case GridPivot.TopRight:
                pivotPoint   = graph.matrix.MultiplyPoint3x4(new Vector3(graph.width, 0, graph.depth));
                pivotPoint   = RoundVector3(pivotPoint);
                diff         = pivotPoint - graph.center;
                pivotPoint   = EditorGUILayout.Vector3Field("Top-Right", pivotPoint);
                graph.center = pivotPoint - diff;
                break;

            case GridPivot.BottomLeft:
                pivotPoint   = graph.matrix.MultiplyPoint3x4(new Vector3(0, 0, 0));
                pivotPoint   = RoundVector3(pivotPoint);
                diff         = pivotPoint - graph.center;
                pivotPoint   = EditorGUILayout.Vector3Field("Bottom-Left", pivotPoint);
                graph.center = pivotPoint - diff;
                break;

            case GridPivot.BottomRight:
                pivotPoint   = graph.matrix.MultiplyPoint3x4(new Vector3(graph.width, 0, 0));
                pivotPoint   = RoundVector3(pivotPoint);
                diff         = pivotPoint - graph.center;
                pivotPoint   = EditorGUILayout.Vector3Field("Bottom-Right", pivotPoint);
                graph.center = pivotPoint - diff;
                break;
            }

            graph.GenerateMatrix();

            pivot = PivotPointSelector(pivot);

        #if !UNITY_4
            EditorGUILayoutx.EndIndent();

            EditorGUILayoutx.BeginIndent();
        #else
            GUILayout.EndHorizontal();
        #endif

            graph.rotation = EditorGUILayout.Vector3Field("Rotation", graph.rotation);

        #if UNITY_LE_4_3
            //Add some space to make the Rotation and postion fields be better aligned (instead of the pivot point selector)
            //GUILayout.Space (19+7);
        #endif
            //GUILayout.EndHorizontal ();

        #if !UNITY_4
            EditorGUILayoutx.EndIndent();
        #endif
        #if UNITY_LE_4_3
            EditorGUIUtility.LookLikeInspector();
        #endif

            if (GUILayout.Button(new GUIContent("Snap Size", "Snap the size to exactly fit nodes"), GUILayout.MaxWidth(100), GUILayout.MaxHeight(16)))
            {
                SnapSizeToNodes(newWidth, newDepth, graph);
            }

            Separator();

            graph.cutCorners = EditorGUILayout.Toggle(new GUIContent("Cut Corners", "Enables or disables cutting corners. See docs for image example"), graph.cutCorners);
            if (!graph.cutCorners && graph.useJumpPointSearch)
            {
                EditorGUILayout.HelpBox("Jump Point Search only works if 'Cut Corners' is enabled.", MessageType.Error);
            }
            graph.neighbours = (NumNeighbours)EditorGUILayout.EnumPopup(new GUIContent("Connections", "Sets how many connections a node should have to it's neighbour nodes."), graph.neighbours);
            if (graph.neighbours != NumNeighbours.Eight && graph.useJumpPointSearch)
            {
                EditorGUILayout.HelpBox("Jump Point Search only works for 8 neighbours.", MessageType.Error);
            }

            graph.maxClimb = EditorGUILayout.FloatField(new GUIContent("Max Climb", "How high, relative to the graph, should a climbable level be. A zero (0) indicates infinity"), graph.maxClimb);
            if (graph.maxClimb < 0)
            {
                graph.maxClimb = 0;
            }
            EditorGUI.indentLevel++;
            graph.maxClimbAxis = EditorGUILayout.IntPopup(new GUIContent("Climb Axis", "Determines which axis the above setting should test on"), graph.maxClimbAxis, new GUIContent[3] {
                new GUIContent("X"), new GUIContent("Y"), new GUIContent("Z")
            }, new int[3] {
                0, 1, 2
            });
            EditorGUI.indentLevel--;

            if (graph.maxClimb > 0 && Mathf.Abs((Quaternion.Euler(graph.rotation) * new Vector3(graph.nodeSize, 0, graph.nodeSize))[graph.maxClimbAxis]) > graph.maxClimb)
            {
                EditorGUILayout.HelpBox("Nodes are spaced further apart than this in the grid. You might want to increase this value or change the axis", MessageType.Warning);
            }

            //GUILayout.EndHorizontal ();

            graph.maxSlope = EditorGUILayout.Slider(new GUIContent("Max Slope", "Sets the max slope in degrees for a point to be walkable. Only enabled if Height Testing is enabled."), graph.maxSlope, 0, 90F);

            graph.erodeIterations = EditorGUILayout.IntField(new GUIContent("Erosion iterations", "Sets how many times the graph should be eroded. This adds extra margin to objects. This will not work when using Graph Updates, so if you can, use the Diameter setting in collision settings instead"), graph.erodeIterations);
            graph.erodeIterations = graph.erodeIterations < 0 ? 0 : (graph.erodeIterations > 16 ? 16 : graph.erodeIterations);             //Clamp iterations to [0,16]

            if (graph.erodeIterations > 0)
            {
                EditorGUI.indentLevel++;
                graph.erosionUseTags = EditorGUILayout.Toggle(new GUIContent("Erosion Uses Tags", "Instead of making nodes unwalkable, " +
                                                                             "nodes will have their tag set to a value corresponding to their erosion level, " +
                                                                             "which is a quite good measurement of their distance to the closest wall.\nSee online documentation for more info."),
                                                              graph.erosionUseTags);
                if (graph.erosionUseTags)
                {
                    EditorGUI.indentLevel++;
                    graph.erosionFirstTag = EditorGUILayoutx.SingleTagField("First Tag", graph.erosionFirstTag);
                    EditorGUI.indentLevel--;
                }
                EditorGUI.indentLevel--;
            }
            DrawCollisionEditor(graph.collision);

            if (graph.collision.use2D)
            {
                if (Mathf.Abs(Vector3.Dot(Vector3.forward, Quaternion.Euler(graph.rotation) * Vector3.up)) < 0.9f)
                {
                    EditorGUILayout.HelpBox("When using 2D it is recommended to rotate the graph so that it aligns with the 2D plane.", MessageType.Warning);
                }
            }

            Separator();
            GUILayout.Label(new GUIContent("Advanced"), EditorStyles.boldLabel);

            showExtra = EditorGUILayout.Foldout(showExtra, "Penalty Modifications");

            if (showExtra)
            {
                EditorGUI.indentLevel += 2;

                graph.penaltyAngle = ToggleGroup(new GUIContent("Angle Penalty", "Adds a penalty based on the slope of the node"), graph.penaltyAngle);
                //bool preGUI = GUI.enabled;
                //GUI.enabled = graph.penaltyAngle && GUI.enabled;
                if (graph.penaltyAngle)
                {
                    EditorGUI.indentLevel++;
                    graph.penaltyAngleFactor = EditorGUILayout.FloatField(new GUIContent("Factor", "Scale of the penalty. A negative value should not be used"), graph.penaltyAngleFactor);
                    graph.penaltyAnglePower  = EditorGUILayout.Slider("Power", graph.penaltyAnglePower, 0.1f, 10f);
                    //GUI.enabled = preGUI;
                    HelpBox("Applies penalty to nodes based on the angle of the hit surface during the Height Testing\nPenalty applied is: P=(1-cos(angle)^power)*factor.");

                    EditorGUI.indentLevel--;
                }

                graph.penaltyPosition = ToggleGroup("Position Penalty", graph.penaltyPosition);
                //EditorGUILayout.Toggle ("Position Penalty",graph.penaltyPosition);
                //preGUI = GUI.enabled;
                //GUI.enabled = graph.penaltyPosition && GUI.enabled;
                if (graph.penaltyPosition)
                {
                    EditorGUI.indentLevel++;
                    graph.penaltyPositionOffset = EditorGUILayout.FloatField("Offset", graph.penaltyPositionOffset);
                    graph.penaltyPositionFactor = EditorGUILayout.FloatField("Factor", graph.penaltyPositionFactor);
                    HelpBox("Applies penalty to nodes based on their Y coordinate\nSampled in Int3 space, i.e it is multiplied with Int3.Precision first (" + Int3.Precision + ")\n" +
                            "Be very careful when using negative values since a negative penalty will underflow and instead get really high");
                    //GUI.enabled = preGUI;
                    EditorGUI.indentLevel--;
                }

                if (textureVisible)
                {
                    DrawTextureData(graph.textureData, graph);
                }
                EditorGUI.indentLevel -= 2;
            }

            graph.useJumpPointSearch = EditorGUILayout.Toggle(new GUIContent("Use Jump Point Search", "Jump Point Search can significantly speed up pathfinding. But only works on uniformly weighted graphs"), graph.useJumpPointSearch);
            if (graph.useJumpPointSearch)
            {
                EditorGUILayout.HelpBox("Jump Point Search assumes that there are no penalties applied to the graph. Tag penalties cannot be used either.", MessageType.Warning);

#if !ASTAR_JPS
                EditorGUILayout.HelpBox("JPS needs to be enabled using a compiler directive before it can be used.\n" +
                                        "Enabling this will add ASTAR_JPS to the Scriping Define Symbols field in the Unity Player Settings", MessageType.Warning);
                if (GUILayout.Button("Enable Jump Point Search support"))
                {
                    var vals = System.Enum.GetValues(typeof(BuildTargetGroup)) as int[];

                    for (int i = 0; i < vals.Length; i++)
                    {
                        string s = PlayerSettings.GetScriptingDefineSymbolsForGroup((BuildTargetGroup)vals[i]);
                        if (s != null)
                        {
                            s += ";ASTAR_JPS";
                            PlayerSettings.SetScriptingDefineSymbolsForGroup((BuildTargetGroup)vals[i], s);
                        }
                    }
                }
#endif
            }
            else
            {
#if ASTAR_JPS
                EditorGUILayout.HelpBox("If you are not using JPS in any scene, you can disable it to save memory", MessageType.Info);
                if (GUILayout.Button("Disable Jump Point Search support"))
                {
                    var vals = System.Enum.GetValues(typeof(BuildTargetGroup)) as int[];

                    for (int i = 0; i < vals.Length; i++)
                    {
                        string s = PlayerSettings.GetScriptingDefineSymbolsForGroup((BuildTargetGroup)vals[i]);
                        if (s != null)
                        {
                            s = s.Replace("ASTAR_JPS;", "");
                            s = s.Replace(";ASTAR_JPS", "");
                            s = s.Replace("ASTAR_JPS", "");
                            PlayerSettings.SetScriptingDefineSymbolsForGroup((BuildTargetGroup)vals[i], s);
                        }
                    }
                }
#endif
            }
        }
示例#3
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public override void OnInspectorGUI()
    {
        exSprite editSprite = target as exSprite;

        inAnimMode = AnimationUtility.InAnimationMode();

#if UNITY_3_4
        isPrefab = (EditorUtility.GetPrefabType(target) == PrefabType.Prefab);
#else
        isPrefab = (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab);
#endif

        // TEMP: not sure this is good {
        Event e = Event.current;
        if (e.type == EventType.MouseDown && e.button == 0 && e.clickCount == 1)
        {
            if (isPrefab)
            {
                Undo.RegisterUndo(editPlane, "editPlane");
            }
            else
            {
                Undo.RegisterSceneUndo("ex2D.Scene");
            }
        }
        // } TEMP end

        EditorGUIUtility.LookLikeInspector();
        EditorGUILayout.Space();
        ++EditorGUI.indentLevel;

        if (isPrefab && editPlane.meshFilter && editPlane.meshFilter.sharedMesh)
        {
            editPlane.meshFilter.sharedMesh = null;
        }

        // TODO: I do not know how to do it. {
        // // ========================================================
        // // Script
        // // ========================================================

        // MonoScript script = (MonoScript)AssetDatabase.LoadAssetAtPath( AssetDatabase.GetAssetPath (target), typeof(MonoScript) );
        // script = (MonoScript)EditorGUILayout.ObjectField( "Script", script, typeof(MonoScript) );
        // } TODO end

        // ========================================================
        // trans2d
        // ========================================================

        GUI.enabled = !inAnimMode;
        EditorGUIUtility.LookLikeControls();
        Transform2D newTrans2D = (Transform2D)EditorGUILayout.EnumPopup("Transform 2D", trans2d, GUILayout.Width(200), GUILayout.ExpandWidth(false));
        EditorGUIUtility.LookLikeInspector();
        GUI.enabled = true;

        //
        if (newTrans2D != trans2d)
        {
            trans2d = newTrans2D;

            exScreenPosition screenPos = editPlane.GetComponent <exScreenPosition>();
            if (screenPos != null)
            {
                Object.DestroyImmediate(screenPos, true);
            }
            exViewportPosition vpPos = editPlane.GetComponent <exViewportPosition>();
            if (vpPos != null)
            {
                Object.DestroyImmediate(vpPos, true);
            }

            switch (trans2d)
            {
            case Transform2D.None:
                break;

            case Transform2D.Screen:
                editPlane.gameObject.AddComponent <exScreenPosition>();
                break;

            case Transform2D.Viewport:
                editPlane.gameObject.AddComponent <exViewportPosition>();
                break;
            }
        }

        // ========================================================
        // use animation helper
        // ========================================================

        GUILayout.BeginHorizontal();
        GUILayout.Space(15);
        GUI.enabled = !inAnimMode;
        exAnimationHelper compAnimHelper = editPlane.GetComponent <exAnimationHelper>();
        bool hasAnimHelper = compAnimHelper != null;
        bool useAnimHelper = GUILayout.Toggle(hasAnimHelper, "Use Animation Helper");
        if (useAnimHelper != hasAnimHelper)
        {
            if (useAnimHelper)
            {
                AddAnimationHelper();
            }
            else
            {
                Object.DestroyImmediate(compAnimHelper, true);
            }
            GUI.changed = true;
        }
        GUI.enabled = true;
        GUILayout.EndHorizontal();

        // ========================================================
        // camera type
        // ========================================================

        GUI.enabled = !inAnimMode;
        EditorGUIUtility.LookLikeControls();
        if (isPrefab)
        {
            GUILayout.BeginHorizontal();
            bool isPrefabCamera = false;
            if (editPlane.renderCameraForPrefab != null)
            {
#if UNITY_3_4
                isPrefabCamera = (EditorUtility.GetPrefabType(editPlane.renderCameraForPrefab) == PrefabType.Prefab);
#else
                isPrefabCamera = (PrefabUtility.GetPrefabType(editPlane.renderCameraForPrefab) == PrefabType.Prefab);
#endif
            }
            editPlane.renderCamera = (Camera)EditorGUILayout.ObjectField("Camera"
                                                                         , isPrefabCamera ? editPlane.renderCameraForPrefab : null
                                                                         , typeof(Camera)
                                                                         , false
                                                                         , GUILayout.Width(300));
            labelStyle.fontStyle        = FontStyle.Bold;
            labelStyle.normal.textColor = Color.yellow;
            GUILayout.Label("(Prefab Only)", labelStyle);
            GUILayout.EndHorizontal();
            GUILayout.Space(5);
        }
        else
        {
            editPlane.renderCamera = (Camera)EditorGUILayout.ObjectField("Camera"
                                                                         , editPlane.renderCamera
                                                                         , typeof(Camera)
                                                                         , true
                                                                         , GUILayout.Width(300));
        }
        EditorGUIUtility.LookLikeInspector();

        // ========================================================
        // anchor
        // ========================================================

        EditorGUILayout.LabelField("Anchor", "");
        GUILayout.BeginHorizontal();
        GUILayout.Space(30);
        editPlane.anchor
            = (exPlane.Anchor)GUILayout.SelectionGrid((int)editPlane.anchor,
                                                      anchorTexts,
                                                      3,
                                                      GUILayout.Width(80));
        GUILayout.EndHorizontal();

        // ========================================================
        // use texture offset
        // ========================================================

        if (editSprite != null)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(30);
            editSprite.useTextureOffset = GUILayout.Toggle(editSprite.useTextureOffset, "Use Texture Offset");
            GUILayout.EndHorizontal();
        }
        GUI.enabled = true;

        // ========================================================
        // offset
        // ========================================================

        EditorGUIUtility.LookLikeControls();
        editPlane.offset = EditorGUILayout.Vector2Field("Offset", editPlane.offset);
        EditorGUIUtility.LookLikeInspector();

        // ========================================================
        // check dirty
        // ========================================================

        if (GUI.changed)
        {
            EditorUtility.SetDirty(editPlane);
        }
        --EditorGUI.indentLevel;
    }
示例#4
0
    public override void OnInspectorGUI()
    {
        MegaModifyGroup mod = (MegaModifyGroup)target;

        EditorGUIUtility.LookLikeControls();
        MegaModifiers.GlobalDisplay = EditorGUILayout.Toggle("GlobalDisplayGizmos", MegaModifiers.GlobalDisplay);
        mod.Enabled     = EditorGUILayout.Toggle("Enabled", mod.Enabled);
        mod.recalcnorms = EditorGUILayout.Toggle("Recalc Normals", mod.recalcnorms);
        MegaNormalMethod method = mod.NormalMethod;

        mod.NormalMethod   = (MegaNormalMethod)EditorGUILayout.EnumPopup("Normal Method", mod.NormalMethod);
        mod.recalcbounds   = EditorGUILayout.Toggle("Recalc Bounds", mod.recalcbounds);
        mod.recalcCollider = EditorGUILayout.Toggle("Recalc Collider", mod.recalcCollider);
        mod.recalcTangents = EditorGUILayout.Toggle("Recalc Tangents", mod.recalcTangents);
        mod.DoLateUpdate   = EditorGUILayout.Toggle("Do Late Update", mod.DoLateUpdate);
        mod.GrabVerts      = EditorGUILayout.Toggle("Grab Verts", mod.GrabVerts);
        mod.DrawGizmos     = EditorGUILayout.Toggle("Draw Gizmos", mod.DrawGizmos);

        if (mod.NormalMethod != method && mod.NormalMethod == MegaNormalMethod.Mega)
        {
            mod.BuildNormalMapping(mod.mesh, false);
        }

        if (GUILayout.Button("Threading Options"))
        {
            showmulti = !showmulti;
        }

        if (showmulti)
        {
            MegaModifiers.ThreadingOn = EditorGUILayout.Toggle("Threading Enabled", MegaModifiers.ThreadingOn);
            mod.UseThreading          = EditorGUILayout.Toggle("Thread This Object", mod.UseThreading);
        }

        EditorGUIUtility.LookLikeControls();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }

        showorder = EditorGUILayout.Foldout(showorder, "Modifier Order");

        if (showorder && mod.mods != null)
        {
            for (int i = 0; i < mod.mods.Length; i++)
            {
                EditorGUILayout.LabelField("", i.ToString() + " - " + mod.mods[i].ModName() + " " + mod.mods[i].Order);
            }
        }

        if (GUILayout.Button("Targets"))
        {
            targetsFlag = !targetsFlag;
        }

        if (targetsFlag)
        {
            if (GUILayout.Button("Add Target"))
            {
                MegaModifierTarget targ = new MegaModifierTarget();
                mod.targets.Add(targ);
            }

            for (int i = 0; i < mod.targets.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                mod.targets[i].go = (GameObject)EditorGUILayout.ObjectField("Target " + i, mod.targets[i].go, typeof(GameObject), true);
                if (GUILayout.Button("Del"))
                {
                    mod.targets.Remove(mod.targets[i]);
                    i--;
                }
                EditorGUILayout.EndHorizontal();
            }
        }
    }
示例#5
0
    /// <summary>
    /// Draw the UI for this tool.
    /// </summary>

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

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

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

        EditorGUIUtility.LookLikeControls(80f);

        NGUIEditorTools.DrawHeader("Input");

        UISettings.fontData    = EditorGUILayout.ObjectField("Font Data", UISettings.fontData, typeof(TextAsset), false) as TextAsset;
        UISettings.fontTexture = EditorGUILayout.ObjectField("Texture", UISettings.fontTexture, typeof(Texture2D), false) as Texture2D;

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

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

            ComponentSelector.Draw <UIFont>("...or select", UISettings.font, OnSelectFont);
            ComponentSelector.Draw <UIAtlas>(UISettings.atlas, OnSelectAtlas);
        }
        NGUIEditorTools.DrawSeparator();

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

            NGUIEditorTools.DrawSeparator();

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

            if (create)
            {
                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 " +
                                                              UISettings.fontName + " font with the currently selected values? This action can't be undone.", "Yes", "No"))
                {
                    // Try to load the material
                    Material 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 = UISettings.fontTexture;

                    if (go == null || go.GetComponent <UIFont>() == null)
                    {
                        // Create a new prefab for the atlas
#if UNITY_3_4
                        Object prefab = EditorUtility.CreateEmptyPrefab(prefabPath);
#else
                        Object prefab = PrefabUtility.CreateEmptyPrefab(prefabPath);
#endif
                        // Create a new game object for the font
                        go = new GameObject(UISettings.fontName);
                        UISettings.font          = go.AddComponent <UIFont>();
                        UISettings.font.material = mat;
                        BMFontReader.Load(UISettings.font.bmFont, NGUITools.GetHierarchy(UISettings.font.gameObject), UISettings.fontData.bytes);

                        // Update the prefab
#if UNITY_3_4
                        EditorUtility.ReplacePrefab(go, prefab);
#else
                        PrefabUtility.ReplacePrefab(go, prefab);
#endif
                        DestroyImmediate(go);
                        AssetDatabase.Refresh();

                        // Select the atlas
                        go = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;
                    }

                    UISettings.font = go.GetComponent <UIFont>();
                    MarkAsChanged();
                }
            }
        }
        else
        {
            GameObject go = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;

            bool create = false;

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

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

            if (create)
            {
                if (go == null || EditorUtility.DisplayDialog("Are you sure?", "Are you sure you want to replace the contents of the " +
                                                              UISettings.fontName + " font with the currently selected values? This action can't be undone.", "Yes", "No"))
                {
                    UIAtlasMaker.AddOrUpdate(UISettings.atlas, UISettings.fontTexture);

                    if (go == null || go.GetComponent <UIFont>() == null)
                    {
                        // Create a new prefab for the atlas
#if UNITY_3_4
                        Object prefab = EditorUtility.CreateEmptyPrefab(prefabPath);
#else
                        Object prefab = PrefabUtility.CreateEmptyPrefab(prefabPath);
#endif
                        // Create a new game object for the font
                        go = new GameObject(UISettings.fontName);
                        UISettings.font            = go.AddComponent <UIFont>();
                        UISettings.font.atlas      = UISettings.atlas;
                        UISettings.font.spriteName = UISettings.fontTexture.name;
                        BMFontReader.Load(UISettings.font.bmFont, NGUITools.GetHierarchy(UISettings.font.gameObject), UISettings.fontData.bytes);

                        // Update the prefab
#if UNITY_3_4
                        EditorUtility.ReplacePrefab(go, prefab);
#else
                        PrefabUtility.ReplacePrefab(go, prefab);
#endif
                        DestroyImmediate(go);
                        AssetDatabase.Refresh();

                        // Select the atlas
                        go = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;
                    }
                    else if (UISettings.fontData != null)
                    {
                        BMFontReader.Load(UISettings.font.bmFont, NGUITools.GetHierarchy(UISettings.font.gameObject), UISettings.fontData.bytes);
                        EditorUtility.SetDirty(UISettings.font);
                        UISettings.font.MarkAsDirty();
                    }

                    UISettings.font            = go.GetComponent <UIFont>();
                    UISettings.font.spriteName = UISettings.fontTexture.name;
                    UISettings.font.atlas      = UISettings.atlas;
                    MarkAsChanged();
                }
            }
        }
    }
示例#6
0
    void DrawClipEditor(tk2dSpriteAnimationClip clip)
    {
        EditorGUIUtility.LookLikeControls(80.0f, 50.0f);

        var frameBorderStyle = EditorStyles.textField;

        int clipNumFrames = clip.frames.Length;

        if (tk2dPreferences.inst.horizontalAnimDisplay)
        {
            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Height(144.0f));
            EditorGUILayout.BeginHorizontal();

            for (int i = 0; i < clipNumFrames; ++i)
            {
                int frameCount = GetFrameCount(clip, i);
                EditorGUILayout.BeginHorizontal(frameBorderStyle);

                EditorGUILayout.BeginVertical();
                GUILayout.Label(new GUIContent(i.ToString(), "Frame"));
//				GUILayout.Label(new GUIContent((i / clip.fps).ToString("0.00" + "s"), "Time"));
                EditorGUILayout.EndVertical();
                DrawSpritePreview(clip.frames[i].spriteCollection, clip.frames[i].spriteId);

                EditorGUILayout.BeginVertical();
                DrawFrameEditor(clip, i, frameCount);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
                EditorGUILayout.Space();

                i += (frameCount - 1);
            }

            DrawAddFrame(clip, false);

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndScrollView();
        }
        else
        {
            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
            EditorGUILayout.BeginVertical();

            for (int i = 0; i < clipNumFrames; ++i)
            {
                int frameCount = GetFrameCount(clip, i);
                EditorGUILayout.BeginHorizontal(frameBorderStyle);

                EditorGUILayout.BeginVertical();
                GUILayout.Label(new GUIContent(i.ToString(), "Frame"));
//				GUILayout.Label(new GUIContent((i / clip.fps).ToString("0.00" + "s"), "Time"));
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical();
                DrawFrameEditor(clip, i, frameCount);
                EditorGUILayout.EndVertical();

                DrawSpritePreview(clip.frames[i].spriteCollection, clip.frames[i].spriteId);

                EditorGUILayout.EndHorizontal();

                i += (frameCount - 1);
            }

            DrawAddFrame(clip, true);

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

        if (deferredFrameOp != null)
        {
            deferredFrameOp(clip);
            deferredFrameOp = null;

            GUI.changed = true;
        }
    }
示例#7
0
        public static void TagsMaskField(GUIContent changeLabel, GUIContent setLabel, ref Pathfinding.TagMask value)
        {
            GUILayout.BeginHorizontal();

            EditorGUIUtility.LookLikeControls();
            EditorGUILayout.PrefixLabel(changeLabel, EditorStyles.layerMaskField);

            string text = "";

            if (value.tagsChange == 0)
            {
                text = "Nothing";
            }
            else if (value.tagsChange == ~0)
            {
                text = "Everything";
            }
            else
            {
                text = System.Convert.ToString(value.tagsChange, 2);
            }

            if (GUILayout.Button(text, EditorStyles.layerMaskField, GUILayout.ExpandWidth(true)))
            {
                GenericMenu menu = new GenericMenu();

                menu.AddItem(new GUIContent("Everything"), value.tagsChange == ~0, value.SetValues, new Pathfinding.TagMask(~0, value.tagsSet));
                menu.AddItem(new GUIContent("Nothing"), value.tagsChange == 0, value.SetValues, new Pathfinding.TagMask(0, value.tagsSet));

                for (int i = 0; i < 32; i++)
                {
                    bool on = (value.tagsChange >> i & 0x1) != 0;
                    Pathfinding.TagMask result = new Pathfinding.TagMask(on ? value.tagsChange & ~(1 << i) : value.tagsChange | 1 << i, value.tagsSet);
                    menu.AddItem(new GUIContent("" + i), on, value.SetValues, result);
                }

                menu.ShowAsContext();

                Event.current.Use();
            }

        #if UNITY_LE_4_3
            EditorGUIUtility.LookLikeInspector();
        #endif
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            EditorGUIUtility.LookLikeControls();
            EditorGUILayout.PrefixLabel(setLabel, EditorStyles.layerMaskField);

            text = "";
            if (value.tagsSet == 0)
            {
                text = "Nothing";
            }
            else if (value.tagsSet == ~0)
            {
                text = "Everything";
            }
            else
            {
                text = System.Convert.ToString(value.tagsSet, 2);
            }

            if (GUILayout.Button(text, EditorStyles.layerMaskField, GUILayout.ExpandWidth(true)))
            {
                GenericMenu menu = new GenericMenu();

                if (value.tagsChange != 0)
                {
                    menu.AddItem(new GUIContent("Everything"), value.tagsSet == ~0, value.SetValues, new Pathfinding.TagMask(value.tagsChange, ~0));
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("Everything"));
                }

                menu.AddItem(new GUIContent("Nothing"), value.tagsSet == 0, value.SetValues, new Pathfinding.TagMask(value.tagsChange, 0));

                for (int i = 0; i < 32; i++)
                {
                    bool enabled = (value.tagsChange >> i & 0x1) != 0;
                    bool on      = (value.tagsSet >> i & 0x1) != 0;

                    Pathfinding.TagMask result = new Pathfinding.TagMask(value.tagsChange, on ? value.tagsSet & ~(1 << i) : value.tagsSet | 1 << i);

                    if (enabled)
                    {
                        menu.AddItem(new GUIContent("" + i), on, value.SetValues, result);
                    }
                    else
                    {
                        menu.AddDisabledItem(new GUIContent("" + i));
                    }
                }

                menu.ShowAsContext();

                Event.current.Use();
            }

        #if UNITY_LE_4_3
            EditorGUIUtility.LookLikeInspector();
        #endif
            GUILayout.EndHorizontal();
        }
示例#8
0
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeControls(80f);
        mMogoButton = target as MogoSingleButton;

        EditorGUILayout.Space();

        GUILayout.BeginHorizontal();
        var isImage = EditorGUILayout.Toggle("isImage", mMogoButton.isImage, GUILayout.Width(250f));

        if (isImage != mMogoButton.isImage)
        {
            RegisterUndo(); mMogoButton.isImage = isImage;
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        var BGDown = EditorGUILayout.ObjectField("BGDown", mMogoButton.BGDown, typeof(GameObject)) as GameObject;

        if (BGDown != mMogoButton.BGDown)
        {
            RegisterUndo(); mMogoButton.BGDown = BGDown;
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        var BGUp = EditorGUILayout.ObjectField("BGUp", mMogoButton.BGUp, typeof(GameObject)) as GameObject;

        if (BGUp != mMogoButton.BGUp)
        {
            RegisterUndo(); mMogoButton.BGUp = BGUp;
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        var TextFG = EditorGUILayout.ObjectField("TextFG", mMogoButton.TextFG, typeof(GameObject)) as GameObject;

        if (TextFG != mMogoButton.TextFG)
        {
            RegisterUndo(); mMogoButton.TextFG = TextFG;
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        var m_lblName = EditorGUILayout.ObjectField("m_lblName", mMogoButton.m_lblName, typeof(UILabel)) as UILabel;

        if (m_lblName != mMogoButton.m_lblName)
        {
            RegisterUndo(); mMogoButton.m_lblName = m_lblName;
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        var buttonType = (ButtonClickSoundType)EditorGUILayout.EnumPopup("buttonType", mMogoButton.buttonType, GUILayout.Width(170f));

        if (buttonType != mMogoButton.buttonType)
        {
            RegisterUndo(); mMogoButton.buttonType = buttonType;
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("一秒变样式", GUILayout.Width(75f));
        //if (GUILayout.Button("A横上选中", GUILayout.Width(100f)))
        //    ExportScenesManager.SetUIASingleButton(mMogoButton.gameObject, true);
        //if (GUILayout.Button("A横上普通", GUILayout.Width(100f)))
        //    ExportScenesManager.SetUIASingleButton(mMogoButton.gameObject, false);
        //GUILayout.EndHorizontal();

        //GUILayout.BeginHorizontal();
        //GUILayout.Label("", GUILayout.Width(75f));
        //if (GUILayout.Button("B竖左选中", GUILayout.Width(100f)))
        //    ExportScenesManager.SetUIBSingleButton(mMogoButton.gameObject, true);
        //if (GUILayout.Button("B竖左普通", GUILayout.Width(100f)))
        //    ExportScenesManager.SetUIBSingleButton(mMogoButton.gameObject, false);
        //GUILayout.EndHorizontal();

        //GUILayout.BeginHorizontal();
        //GUILayout.Label("", GUILayout.Width(75f));
        //if (GUILayout.Button("C横左选中", GUILayout.Width(100f)))
        //    ExportScenesManager.SetUICSingleButton(mMogoButton.gameObject, true);
        //if (GUILayout.Button("C横左普通", GUILayout.Width(100f)))
        //    ExportScenesManager.SetUICSingleButton(mMogoButton.gameObject, false);
        //GUILayout.EndHorizontal();

        //GUILayout.BeginHorizontal();
        //GUILayout.Label("", GUILayout.Width(75f));
        //if (GUILayout.Button("D子页签选中", GUILayout.Width(120f)))
        //    ExportScenesManager.SetUIDSingleButton(mMogoButton.gameObject, true);
        //if (GUILayout.Button("D子页签普通", GUILayout.Width(120f)))
        //    ExportScenesManager.SetUIDSingleButton(mMogoButton.gameObject, false);
        GUILayout.EndHorizontal();
    }
示例#9
0
    public override void OnInspectorGUI()
    {
        TV_Orbit myTarget = (TV_Orbit)target;

        EditorGUILayout.Space();
        GUILayout.Label("ForceX Tools: Planet & Orbit Editor");
        GUILayout.Label("Version 1.0.1");

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

        myTarget.TimeMultiplier = EditorGUILayout.IntField("Time Multiplier: ", myTarget.TimeMultiplier);
        myTarget.Name           = EditorGUILayout.TextField("Name: ", myTarget.Name);

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

        EditorGUILayout.Space();
        //EditorGUIUtility.LookLikeInspector();
        myTarget.Parent = (Transform)EditorGUILayout.ObjectField("Parent Mass: ", myTarget.Parent, typeof(Transform), true);
        EditorGUIUtility.LookLikeControls();

        EditorGUILayout.Space();
        myTarget.LockOrbit = EditorGUILayout.Toggle("Lock Orbit:", myTarget.LockOrbit);
        myTarget.TidalLock = EditorGUILayout.Toggle("Tidal Lock:", myTarget.TidalLock);

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        GUILayout.Label("Orbit Display 	------------------------------", EditorStyles.boldLabel);
        myTarget._DrawOrbit = EditorGUILayout.Toggle("Draw Orbit:", myTarget._DrawOrbit);

        if (myTarget._DrawOrbit == true)
        {
            myTarget.Segments     = EditorGUILayout.IntField("Display Segments: ", myTarget.Segments);
            myTarget.DisplaySize  = EditorGUILayout.FloatField("Display Size: ", myTarget.DisplaySize);
            myTarget.DisplayColor = EditorGUILayout.ColorField("Display Color: ", myTarget.DisplayColor);

            EditorGUILayout.Space();
            myTarget.UseTexture = EditorGUILayout.Toggle("Use Texture:", myTarget.UseTexture);
            if (myTarget.UseTexture == true)
            {
                //EditorGUIUtility.LookLikeInspector();
                myTarget.DisplayTexture = (Texture2D)EditorGUILayout.ObjectField("Display Texture: ", myTarget.DisplayTexture, typeof(Texture2D), true);
                EditorGUIUtility.LookLikeControls();
                myTarget.DisplayTiling = EditorGUILayout.IntField("Texture Tiling: ", myTarget.DisplayTiling);
            }
        }
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        //SetupPlanet = EditorGUILayout.EnumPopup("Planet Options:",SetupPlanet);

        GUILayout.Label("Planet Orbit 	------------------------------", EditorStyles.boldLabel);
        EditorGUILayout.Space();

        //if(SetupPlanet == 0){
        myTarget.AxialTilt       = EditorGUILayout.Slider("Axial Tilt: ", myTarget.AxialTilt, 0, 360);
        myTarget.OrbitalDistance = EditorGUILayout.FloatField("Orbital Distance: ", myTarget.OrbitalDistance);
        myTarget.OrbitAngle      = EditorGUILayout.FloatField("Orbit Angle: ", myTarget.OrbitAngle);
        EditorGUILayout.Space();
        myTarget.OrbitOffset = EditorGUILayout.Vector3Field("Orbit Center Offset: ", myTarget.OrbitOffset);
        EditorGUILayout.Space();

        EditorGUILayout.Space();
        myTarget.OrbitPosOffset = EditorGUILayout.Slider("Start Orbital Offset: ", myTarget.OrbitPosOffset, 0, 360);
        EditorGUILayout.Space();
        if (!myTarget.LockOrbit)
        {
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            myTarget.SetOrbit = (TV_Orbit.Orbit)EditorGUILayout.EnumPopup("Set Orbit:", myTarget.SetOrbit);
            EditorGUILayout.Space();
            if (myTarget.SetOrbit == 0)
            {
                GUILayout.Label("Orbital Period x1 Earth Years");
                myTarget.OrbitalPeriod = EditorGUILayout.FloatField("Orbital Period: ", myTarget.OrbitalPeriod);
            }
            else
            {
                GUILayout.Label("Orbital Period In Earth Time");
                myTarget.OrbitYears   = EditorGUILayout.IntField("Orbit Years: ", myTarget.OrbitYears);
                myTarget.OrbitDays    = EditorGUILayout.IntField("Orbit Days: ", myTarget.OrbitDays);
                myTarget.OrbitHours   = EditorGUILayout.IntField("Orbit Hours: ", myTarget.OrbitHours);
                myTarget.OrbitMinutes = EditorGUILayout.IntField("Orbit Minutes: ", myTarget.OrbitMinutes);
                myTarget.OrbitSeconds = EditorGUILayout.FloatField("Orbit Seconds: ", myTarget.OrbitSeconds);
            }
        }
        //}else

        //if(SetupPlanet == 1){
        if (!myTarget.TidalLock)
        {
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            GUILayout.Label("Planet Rotation 	------------------------------", EditorStyles.boldLabel);
            EditorGUILayout.Space();
            myTarget.SetRotation = (TV_Orbit.Rotation)EditorGUILayout.EnumPopup("Set Rotation:", myTarget.SetRotation);
            EditorGUILayout.Space();
            if (myTarget.SetRotation == 0)
            {
                GUILayout.Label("Rotation Period x1 Earth Days");
                myTarget.RotationPeriod = EditorGUILayout.FloatField("Orbital Period: ", myTarget.OrbitalPeriod);
            }
            else
            {
                GUILayout.Label("Rotation Period In Earth Time");
                myTarget.RotationYears   = EditorGUILayout.IntField("Rotation Years: ", myTarget.RotationYears);
                myTarget.RotationDays    = EditorGUILayout.IntField("Rotation Days: ", myTarget.RotationDays);
                myTarget.RotationHours   = EditorGUILayout.IntField("Rotation Hours: ", myTarget.RotationHours);
                myTarget.RotationMinutes = EditorGUILayout.IntField("Rotation Minutes: ", myTarget.RotationMinutes);
                myTarget.RotationSeconds = EditorGUILayout.FloatField("Rotation Seconds: ", myTarget.RotationSeconds);
            }
        }
        //}

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        if (!myTarget.LockOrbit)
        {
            GUILayout.Label("Local Planetary Statistics 	--------------------", EditorStyles.boldLabel);

            EditorGUILayout.Space();
            //GUILayout.Label("Allow Start Orbital Offset To Effect Year");
            //target.OrbitOffSetYear = EditorGUILayout.Toggle("Enabled:", target.OrbitOffSetYear);
            myTarget.CurrentOrbitPos = EditorGUILayout.Slider("Orbital Position: ", myTarget.CurrentOrbitPos, 0, 360);

            EditorGUILayout.Space();
            myTarget.KeepTime = EditorGUILayout.Toggle("Keep Local Time:", myTarget.KeepTime);

            if (myTarget.KeepTime == true)
            {
                //EditorGUIUtility.LookLikeInspector();
                myTarget.CounterYear = EditorGUILayout.IntField("	Orbits: ", myTarget.CounterYear);
                if (!myTarget.TidalLock)
                {
                    myTarget.CounterDay = EditorGUILayout.IntField("	Rotations: ", myTarget.CounterDay);

                    EditorGUILayout.Space();

                    myTarget.RotInOrbit = EditorGUILayout.IntField("	Rotations Per Orbit: ", myTarget.RotInOrbit);
                    myTarget.HoursInDay = EditorGUILayout.IntField("	Hours Per Rotation: ", myTarget.HoursInDay);

                    EditorGUILayout.Space();
                    GUILayout.Label("Current Local Time");
                    myTarget.CounterHour   = (int)EditorGUILayout.FloatField("	Hours: ", myTarget.CounterHour);
                    myTarget.CounterMinute = (int)EditorGUILayout.FloatField("	Minutes: ", myTarget.CounterMinute);
                    myTarget.CounterSecond = EditorGUILayout.FloatField("	Seconds: ", myTarget.CounterSecond);
                }
            }
        }
    }
示例#10
0
    public override void OnInspectorGUI()
    {
        MegaWrap mod = (MegaWrap)target;

#if !UNITY_5 && !UNITY_2017 && !UNITY_2018 && !UNITY_2019 && !UNITY_2020
        EditorGUIUtility.LookLikeControls();
#endif
        mod.WrapEnabled = EditorGUILayout.Toggle("Enabled", mod.WrapEnabled);
        mod.target      = (MegaModifyObject)EditorGUILayout.ObjectField("Target", mod.target, typeof(MegaModifyObject), true);

        float max = 1.0f;
        if (mod.target)
        {
            max = mod.target.bbox.size.magnitude;
        }

        mod.maxdist = EditorGUILayout.Slider("Max Dist", mod.maxdist, 0.0f, max);               //2.0f);	//mod.maxdist);
        if (mod.maxdist < 0.0f)
        {
            mod.maxdist = 0.0f;
        }

        mod.maxpoints = EditorGUILayout.IntField("Max Points", mod.maxpoints);          //mod.maxdist);
        if (mod.maxpoints < 1)
        {
            mod.maxpoints = 1;
        }

        Color col = GUI.backgroundColor;
        EditorGUILayout.BeginHorizontal();
        if (mod.bindverts == null)
        {
            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("Map"))
            {
                Attach(mod.target);
            }
        }
        else
        {
            GUI.backgroundColor = Color.green;
            if (GUILayout.Button("ReMap"))
            {
                Attach(mod.target);
            }
        }

        GUI.backgroundColor = col;
        if (GUILayout.Button("Reset"))
        {
            mod.ResetMesh();
        }

        EditorGUILayout.EndHorizontal();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(mod);
        }

        mod.gap    = EditorGUILayout.FloatField("Gap", mod.gap);
        mod.shrink = EditorGUILayout.Slider("Shrink", mod.shrink, 0.0f, 1.0f);
        mod.size   = EditorGUILayout.Slider("Size", mod.size, 0.001f, 0.04f);
        if (mod.bindverts != null)
        {
            mod.vertindex = EditorGUILayout.IntSlider("Vert Index", mod.vertindex, 0, mod.bindverts.Length - 1);
        }
        mod.offset = EditorGUILayout.Vector3Field("Offset", mod.offset);

        mod.NormalMethod = (MegaNormalMethod)EditorGUILayout.EnumPopup("Normal Method", mod.NormalMethod);
#if UNITY_5 || UNITY_2017 || UNITY_2018 || UNITY_2019 || UNITY_2020
        mod.UseBakedMesh = EditorGUILayout.Toggle("Use Baked Mesh", mod.UseBakedMesh);
#endif

        if (mod.bindverts == null || mod.target == null)
        {
            EditorGUILayout.LabelField("Object not wrapped");
        }
        else
        {
            EditorGUILayout.LabelField("UnMapped", mod.nomapcount.ToString());
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(mod);
        }
    }
示例#11
0
    /// <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";
        }

        EditorGUIUtility.LookLikeControls(80f);
        NGUIEditorTools.DrawHeader("Input");

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

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

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

#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 they will always be drawn in a separate draw call. You WILL need to adjust transform position's Z rather than depth!", MessageType.Warning);

            if (NGUISettings.dynamicFont != null)
            {
                NGUIEditorTools.DrawSeparator();

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.backgroundColor = Color.green;

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

                if (go != null)
                {
                    if (go.GetComponent <NGUIFont>() != null)
                    {
                        GUI.backgroundColor = Color.red;
                        if (GUILayout.Button("Replace the Font", GUILayout.Width(140f)))
                        {
                            create = 1;
                        }
                    }
                    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 = 1;
                    }
                }

                GUI.backgroundColor = Color.white;
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
#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;

            // 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");

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

                ComponentSelector.Draw <NGUIFont>("Select", NGUISettings.font, OnSelectFont);
                ComponentSelector.Draw <NGUIAtlas>(NGUISettings.atlas, OnSelectAtlas);
            }
            NGUIEditorTools.DrawSeparator();

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

                NGUIEditorTools.DrawSeparator();

                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 <NGUIFont>() != 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)
                {
                    NGUIAtlasMaker.AddOrUpdate(NGUISettings.atlas, NGUISettings.fontTexture);
                }

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

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

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

                    // Select the atlas
                    go = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;
                    NGUISettings.font = go.GetComponent <NGUIFont>();
                }
                else
                {
                    NGUISettings.font = go.GetComponent <NGUIFont>();
                    CreateFont(NGUISettings.font, create, mat);
                }
                MarkAsChanged();
            }
        }
    }
示例#12
0
    override public void OnInspectorGUI()
    {
        mFont = target as UIFont;
        EditorGUIUtility.LookLikeControls(80f);

        NGUIEditorTools.DrawSeparator();

        if (mFont.replacement != null)
        {
            mType        = FontType.Reference;
            mReplacement = mFont.replacement;
        }

        FontType after = (FontType)EditorGUILayout.EnumPopup("Font Type", mType);

        if (mType != after)
        {
            if (after == FontType.Normal)
            {
                OnSelectFont(null);
            }
            else
            {
                mType = FontType.Reference;
            }
        }

        if (mType == FontType.Reference)
        {
            ComponentSelector.Draw <UIFont>(mFont.replacement, OnSelectFont);

            NGUIEditorTools.DrawSeparator();
            GUILayout.Label("You can have one font simply point to\n" +
                            "another one. This is useful if you want to be\n" +
                            "able to quickly replace the contents of one\n" +
                            "font with another one, for example for\n" +
                            "swapping an SD font with an HD one, or\n" +
                            "replacing an English font with a Chinese\n" +
                            "one. All the labels referencing this font\n" +
                            "will update their references to the new one.");

            if (mReplacement != mFont && mFont.replacement != mReplacement)
            {
                NGUIEditorTools.RegisterUndo("Font Change", mFont);
                mFont.replacement = mReplacement;
                UnityEditor.EditorUtility.SetDirty(mFont);
            }
            return;
        }

        NGUIEditorTools.DrawSeparator();
        ComponentSelector.Draw <UIAtlas>(mFont.atlas, OnSelectAtlas);

        if (mFont.atlas != null)
        {
            if (mFont.bmFont.LegacyCheck())
            {
                Debug.Log(mFont.name + " uses a legacy font data structure. Upgrading, please save.");
                EditorUtility.SetDirty(mFont);
            }

            if (mFont.bmFont.isValid)
            {
                NGUIEditorTools.AdvancedSpriteField(mFont.atlas, mFont.spriteName, SelectSprite, false);
            }
        }
        else
        {
            // No atlas specified -- set the material and texture rectangle directly
            Material mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material;

            if (mFont.material != mat)
            {
                NGUIEditorTools.RegisterUndo("Font Material", mFont);
                mFont.material = mat;
            }
        }

        bool resetWidthHeight = false;

        if (mFont.atlas != null || mFont.material != null)
        {
            TextAsset data = EditorGUILayout.ObjectField("Import Font", null, typeof(TextAsset), false) as TextAsset;

            if (data != null)
            {
                NGUIEditorTools.RegisterUndo("Import Font Data", mFont);
                BMFontReader.Load(mFont.bmFont, NGUITools.GetHierarchy(mFont.gameObject), data.bytes);
                mFont.MarkAsDirty();
                resetWidthHeight = true;
                Debug.Log("Imported " + mFont.bmFont.glyphCount + " characters");
            }
        }

        if (mFont.bmFont.isValid)
        {
            Color     green = new Color(0.4f, 1f, 0f, 1f);
            Texture2D tex   = mFont.texture;

            if (tex != null)
            {
                if (mFont.atlas == null)
                {
                    // Pixels are easier to work with than UVs
                    Rect pixels = NGUIMath.ConvertToPixels(mFont.uvRect, tex.width, tex.height, false);

                    // Automatically set the width and height of the rectangle to be the original font texture's dimensions
                    if (resetWidthHeight)
                    {
                        pixels.width  = mFont.texWidth;
                        pixels.height = mFont.texHeight;
                    }

                    // Font sprite rectangle
                    GUI.backgroundColor = green;
                    pixels = EditorGUILayout.RectField("Pixel Rect", pixels);
                    GUI.backgroundColor = Color.white;

                    // Create a button that can make the coordinates pixel-perfect on click
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Correction", GUILayout.Width(75f));

                        Rect corrected = NGUIMath.MakePixelPerfect(pixels);

                        if (corrected == pixels)
                        {
                            GUI.color = Color.grey;
                            GUILayout.Button("Make Pixel-Perfect");
                            GUI.color = Color.white;
                        }
                        else if (GUILayout.Button("Make Pixel-Perfect"))
                        {
                            pixels      = corrected;
                            GUI.changed = true;
                        }
                    }
                    GUILayout.EndHorizontal();

                    // Convert the pixel coordinates back to UV coordinates
                    Rect uvRect = NGUIMath.ConvertToTexCoords(pixels, tex.width, tex.height);

                    if (mFont.uvRect != uvRect)
                    {
                        NGUIEditorTools.RegisterUndo("Font Pixel Rect", mFont);
                        mFont.uvRect = uvRect;
                    }
                }

                // Font spacing
                GUILayout.BeginHorizontal();
                {
                    EditorGUIUtility.LookLikeControls(0f);
                    GUILayout.Label("Spacing", GUILayout.Width(60f));
                    GUILayout.Label("X", GUILayout.Width(12f));
                    int x = EditorGUILayout.IntField(mFont.horizontalSpacing);
                    GUILayout.Label("Y", GUILayout.Width(12f));
                    int y = EditorGUILayout.IntField(mFont.verticalSpacing);
                    EditorGUIUtility.LookLikeControls(80f);

                    if (mFont.horizontalSpacing != x || mFont.verticalSpacing != y)
                    {
                        NGUIEditorTools.RegisterUndo("Font Spacing", mFont);
                        mFont.horizontalSpacing = x;
                        mFont.verticalSpacing   = y;
                    }
                }
                GUILayout.EndHorizontal();

                EditorGUILayout.Separator();

                GUILayout.BeginHorizontal();
                {
                    mView = (View)EditorGUILayout.EnumPopup("Show", mView);
                    GUILayout.Label("Shader", GUILayout.Width(45f));

                    if (mUseShader != EditorGUILayout.Toggle(mUseShader, GUILayout.Width(20f)))
                    {
                        mUseShader = !mUseShader;

                        if (mUseShader && mView == View.Font)
                        {
                            // TODO: Remove this when Unity fixes the bug with DrawPreviewTexture not being affected by BeginGroup
                            Debug.LogWarning("There is a bug in Unity that prevents the texture from getting clipped properly.\n" +
                                             "Until it's fixed by Unity, your texture may spill onto the rest of the Unity's GUI while using this mode.");
                        }
                    }
                }
                GUILayout.EndHorizontal();

                if (mView != View.Nothing)
                {
                    // Draw the atlas
                    EditorGUILayout.Separator();
                    Material m    = mUseShader ? mFont.material : null;
                    Rect     rect = (mView == View.Atlas) ? NGUIEditorTools.DrawAtlas(tex, m) : NGUIEditorTools.DrawSprite(tex, mFont.uvRect, m);
                    NGUIEditorTools.DrawOutline(rect, mFont.uvRect, green);

                    rect = GUILayoutUtility.GetRect(Screen.width, 18f);
                    EditorGUI.DropShadowLabel(rect, "Font Size: " + mFont.size);
                }
            }
        }
    }
示例#13
0
    public override void OnInspectorGUI()
    {
        Transform t = (Transform)target;

        if (GUILayout.Button("Reset Transforms"))
        {
            Undo.RecordObject(t, "Reset Transforms " + t.name);
            if (t.parent == null)
            {
                t.transform.position   = Vector3.zero;
                t.transform.rotation   = Quaternion.identity;
                t.transform.localScale = Vector3.one;
            }
            else
            {
                t.transform.localPosition = Vector3.zero;
                t.transform.localRotation = Quaternion.identity;
                t.transform.localScale    = Vector3.one;
            }
        }

        if (GUILayout.Button("Reset Position"))
        {
            Undo.RecordObject(t, "Reset Position " + t.name);
            if (t.parent == null)
            {
                t.transform.position = Vector3.zero;
            }
            else
            {
                t.transform.localPosition = Vector3.zero;
            }
        }

        if (GUILayout.Button("Reset Rotation"))
        {
            Undo.RecordObject(t, "Reset Rotation " + t.name);
            if (t.parent == null)
            {
                t.transform.rotation = Quaternion.identity;
            }
            else
            {
                t.transform.localRotation = Quaternion.identity;
            }
        }

        if (GUILayout.Button("Reset Scale"))
        {
            Undo.RecordObject(t, "Reset Scale " + t.name);
            t.transform.localScale = Vector3.one;
        }

        // Replicate the standard transform inspector gui
        EditorGUIUtility.LookLikeControls();
        EditorGUI.indentLevel = 0;
        Vector3 position    = EditorGUILayout.Vector3Field("Position", t.localPosition);
        Vector3 eulerAngles = EditorGUILayout.Vector3Field("Rotation", t.localEulerAngles);
        Vector3 scale       = EditorGUILayout.Vector3Field("Scale", t.localScale);

        EditorGUIUtility.LookLikeControls();
        if (GUI.changed)
        {
            Undo.RecordObject(t, "Transform Change");
            t.localPosition    = FixIfNaN(position);
            t.localEulerAngles = FixIfNaN(eulerAngles);
            t.localScale       = FixIfNaN(scale);
        }
    }
        protected override void OnGUIButtons()
        {
            DebugContext.SetViews(ViewOption.Grid | ViewOption.Selection | ViewOption.Mesh);

            NavmeshBuild build = Context.Build;

            if (!build)
            {
                return;
            }

            TileBuildData tdata = build.BuildData;

            if (tdata == null)
            {
                return;
            }

            TileSelection selection = Context.Selection;

            bool hasSelection  = selection.Validate();
            bool needBaking    = (tdata.NeedsBakingCount() > 0);
            int  activeCount   = Context.TaskCount;
            int  bakeableCount = tdata.BakeableCount();

            bool origGUIEnabled = GUI.enabled;

            bool guiEnabled = !IsBaseBusy;

            GUI.enabled = guiEnabled;

            ControlUtil.BeginButtonArea(Context.ButtonArea);

            if (GUILayout.Button("Build All"))
            {
                HandleBuildRequest(true);
            }

            GUI.enabled = guiEnabled && hasSelection;

            if (GUILayout.Button("Build Zone"))
            {
                HandleBuildRequest(false);
            }

            ////////////////////////////////////////////////////////////////////
            GUILayout.Space(MarginSize);

            // Only disable baking if there is nothing at all that can be baked.
            GUI.enabled = guiEnabled && activeCount == 0 && (bakeableCount > 0);

            GUIStyle style = (bakeableCount > 0 && activeCount == 0)
                ? ControlUtil.HighlightedButton : GUI.skin.button;

            if (GUILayout.Button("Bake All", style))
            {
                HandleBake();
            }

            ////////////////////////////////////////////////////////////////////
            GUILayout.Space(MarginSize);

            // Note: Technically only the last condition is needed.  But checking the
            // other conditions first saves processing time.
            GUI.enabled = guiEnabled && activeCount == 0 &&
                          tdata.GetStateCount(TileBuildState.NotBuilt) < tdata.Width * tdata.Depth;

            if (GUILayout.Button((needBaking ? "Revert Unbaked" : "Clear All")))
            {
                HandleClear();
            }

            GUI.enabled = guiEnabled && (activeCount != 0);

            if (GUILayout.Button("Abort Builds"))
            {
                Context.AbortAllReqests("User requested.");
            }

            ////////////////////////////////////////////////////////////////////
            GUILayout.Space(ControlUtil.MarginSize);

            GUI.enabled = guiEnabled;
            if (OnGUIStandardButtons())
            {
                // Special case.  Build was discarded.
                ControlUtil.EndButtonArea();
                return;
            }

            ///////////////////////////////////////////////////////////////////
            GUILayout.Space(MarginSize);

            GUI.enabled = guiEnabled && hasSelection;

            EditorGUIUtility.LookLikeControls(100);
            selection.ZoneSize = EditorGUILayout.IntField("Zone Size", selection.ZoneSize);
            EditorGUIUtility.LookLikeControls();

            GUI.enabled = guiEnabled;

            ////////////////////////////////////////////////////////////////////
            GUILayout.Space(MarginSize);

            GUILayout.Label("Bakeable Tiles: " + bakeableCount);

            ControlUtil.OnGUIStandardButtons(Context, DebugContext, true);

            ControlUtil.EndButtonArea();

            GUI.enabled = origGUIEnabled;
        }
示例#15
0
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeControls();

        Mode oldMode = mode;

        mode = (Mode)EditorGUIUtils.Toolbar(mode);
        EditorGUILayout.Separator();
        if (mode != oldMode)
        {
            EditorGUIUtility.keyboardControl = 0;
        }

        if (mode == Mode.AtlasSet)
        {
            DrawAtlasesList(blockSet);
            if (blockSet.GetAtlas(selectedAtlas) != null)
            {
                DrawAtlasEditor(blockSet.GetAtlas(selectedAtlas));
            }
        }
        if (mode == Mode.BlockSet)
        {
            DrawBlockSet(blockSet);
            EditorGUILayout.Separator();

            if (selectedBlock < blockSet.GetBlockCount() && blockSet.GetBlock(selectedBlock) != null)
            {
                BlockEditor.DrawBlockEditor(blockSet.GetBlock(selectedBlock), blockSet);
            }
            if (selectedBlock >= blockSet.GetBlockCount() && blockSet.GetItem(selectedBlock - blockSet.GetBlockCount()) != null)
            {
                BlockEditor.DrawItemEditor(blockSet.GetItem(selectedBlock - blockSet.GetBlockCount()), blockSet);
            }
        }
        if (mode == Mode.XML)
        {
            if (oldMode != mode)
            {
                xml = blockSet.GetData();
            }

            xmlScrollPosition = GUILayout.BeginScrollView(xmlScrollPosition);
            GUIStyle style = new GUIStyle(GUI.skin.box);
            style.alignment = TextAnchor.UpperLeft;
            xml             = EditorGUILayout.TextArea(xml, GUILayout.ExpandWidth(true));
            blockSet.SetData(xml);
            GUILayout.EndScrollView();

            if (GUILayout.Button("Import"))
            {
                BlockSetImport.Import(blockSet, blockSet.GetData());
                GUI.changed = true;
            }
        }

        if (GUI.changed)
        {
            string data = BlockSetExport.Export(blockSet);
            blockSet.SetData(data);
            EditorUtility.SetDirty(blockSet);
        }
    }
        public bool Draw(List <SpriteCollectionEditorEntry> selectedEntries)
        {
            if (selectedEntries.Count == 0 || selectedEntries[0].type != SpriteCollectionEditorEntry.Type.SpriteSheet)
            {
                return(false);
            }

            var entry       = selectedEntries[selectedEntries.Count - 1];
            var spriteSheet = SpriteCollection.spriteSheets[entry.index];

            if (activeSpriteSheetSource != spriteSheet)
            {
                // reset state data
                selectedSprites.Clear();
                activeSelectedSprites.Clear();
                rectSelectX             = rectSelectY = -1;
                textureViewScrollBar    = Vector2.zero;
                inspectorScrollBar      = Vector2.zero;
                activeSpriteSheetSource = spriteSheet;
                selectedMode            = EditMode.Edit;
            }

            if (spriteSheet.tileWidth == 0 || spriteSheet.tileHeight == 0)
            {
                selectedMode = EditMode.Config;
            }

            bool doDelete = false;

            GUILayout.BeginHorizontal();

            // Texture View
            GUILayout.BeginVertical(tk2dEditorSkin.SC_BodyBackground, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
            textureViewScrollBar = GUILayout.BeginScrollView(textureViewScrollBar);
            if (spriteSheet.texture != null)
            {
                spriteSheet.texture.filterMode = FilterMode.Point;
                DrawTextureView(spriteSheet);
                host.OnSpriteCollectionChanged(true);
            }
            GUILayout.EndScrollView();
            GUILayout.EndVertical();

            // Inspector
            EditorGUIUtility.LookLikeControls(100.0f, 100.0f);
            inspectorScrollBar = GUILayout.BeginScrollView(inspectorScrollBar, GUILayout.ExpandHeight(true), GUILayout.Width(host.InspectorWidth));

            // Header
            GUILayout.BeginVertical(tk2dEditorSkin.SC_InspectorHeaderBG, GUILayout.ExpandWidth(true));
            GUILayout.Label("Sprite Sheet");
            GUILayout.BeginHorizontal();
            Texture2D newTexture = EditorGUILayout.ObjectField("Texture", spriteSheet.texture, typeof(Texture2D), false) as Texture2D;

            if (newTexture != spriteSheet.texture)
            {
                spriteSheet.texture = newTexture;
                host.OnSpriteCollectionSortChanged();
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Delete", EditorStyles.miniButton))
            {
                doDelete = true;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            bool textureReady = false;

            if (spriteSheet.texture != null)
            {
                GUILayout.BeginVertical(tk2dEditorSkin.SC_InspectorBG, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(false));
                string assetPath = AssetDatabase.GetAssetPath(spriteSheet.texture);
                if (assetPath.Length > 0)
                {
                    // make sure the source texture is npot and readable, and uncompressed
                    if (tk2dSpriteCollectionBuilder.IsTextureImporterSetUp(assetPath))
                    {
                        textureReady = true;
                    }
                    else
                    {
                        if (tk2dGuiUtility.InfoBoxWithButtons(
                                "The texture importer needs to be reconfigured to be used as a sprite sheet source. " +
                                "Please note that this will globally change this texture importer.",
                                tk2dGuiUtility.WarningLevel.Info,
                                "Set up") != -1)
                        {
                            tk2dSpriteCollectionBuilder.ConfigureSpriteTextureImporter(assetPath);
                            AssetDatabase.ImportAsset(assetPath);
                        }
                    }
                }
                GUILayout.EndVertical();
            }

            // Body
            if (textureReady)
            {
                GUILayout.BeginVertical(tk2dEditorSkin.SC_InspectorBG, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(false));
                selectedMode = (EditMode)GUILayout.Toolbar((int)selectedMode, new string[] { "Edit", "Config" });
                EditorGUILayout.Space();
                GUILayout.EndVertical();

                if (selectedMode == EditMode.Edit)
                {
                    if (Event.current.type == EventType.Layout)
                    {
                        activeSelectedSprites = new List <SpriteCollectionEditorEntry>(selectedSprites);
                    }

                    if (activeSelectedSprites.Count > 0)
                    {
                        host.SpriteView.DrawSpriteEditorInspector(activeSelectedSprites, true, true);
                    }
                }
                else
                {
                    GUILayout.BeginVertical(tk2dEditorSkin.SC_InspectorBG, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(false));

                    spriteSheet.tileWidth    = EditorGUILayout.IntField("Tile Width", spriteSheet.tileWidth);
                    spriteSheet.tileHeight   = EditorGUILayout.IntField("Tile Height", spriteSheet.tileHeight);
                    spriteSheet.tileMarginX  = EditorGUILayout.IntField("Tile Margin X", spriteSheet.tileMarginX);
                    spriteSheet.tileMarginY  = EditorGUILayout.IntField("Tile Margin Y", spriteSheet.tileMarginY);
                    spriteSheet.tileSpacingX = EditorGUILayout.IntField("Tile Spacing X", spriteSheet.tileSpacingX);
                    spriteSheet.tileSpacingY = EditorGUILayout.IntField("Tile Spacing Y", spriteSheet.tileSpacingY);

                    // Apply button
                    GUILayout.Space(8);
                    GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace();
                    if (spriteSheet.texture != null &&
                        spriteSheet.tileWidth > 0 && spriteSheet.tileWidth <= spriteSheet.texture.width &&
                        spriteSheet.tileHeight > 0 && spriteSheet.tileHeight <= spriteSheet.texture.height &&
                        GUILayout.Button("Apply", EditorStyles.miniButton))
                    {
                        AddSprites(spriteSheet);
                        selectedMode = EditMode.Edit;
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();
                }
            }

            GUILayout.BeginVertical(tk2dEditorSkin.SC_InspectorBG, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            GUILayout.EndVertical();


            // /Body
            GUILayout.EndScrollView();
            GUILayout.EndHorizontal();

            if (doDelete)
            {
                string message = "Deleting a sprite sheet will delete all sprites sourced from this sprite sheet. " +
                                 "Are you sure you want to do this?";
                if (EditorUtility.DisplayDialog("Delete sprite sheet", message, "Yes", "No"))
                {
                    SpriteCollection.DeleteSpriteSheet(spriteSheet);
                    host.OnSpriteCollectionChanged(false);
                }
            }

            return(true);
        }
示例#17
0
    /// <summary>
    /// Draw the inspector widget.
    /// </summary>

    public override void OnInspectorGUI()
    {
        UIPanel panel = target as UIPanel;
        BetterList <UIDrawCall> drawcalls = panel.drawCalls;

        EditorGUIUtility.LookLikeControls(80f);

        //NGUIEditorTools.DrawSeparator();
        EditorGUILayout.Space();

        float alpha = EditorGUILayout.Slider("Alpha", panel.alpha, 0f, 1f);

        if (alpha != panel.alpha)
        {
            NGUIEditorTools.RegisterUndo("Panel Alpha", panel);
            panel.alpha = alpha;
        }

        if (panel.showInPanelTool != EditorGUILayout.Toggle("Panel Tool", panel.showInPanelTool))
        {
            panel.showInPanelTool = !panel.showInPanelTool;
            EditorUtility.SetDirty(panel);
            EditorWindow.FocusWindowIfItsOpen <UIPanelTool>();
        }

        GUILayout.BeginHorizontal();
        bool norms = EditorGUILayout.Toggle("Normals", panel.generateNormals, GUILayout.Width(100f));

        GUILayout.Label("Needed for lit shaders");
        GUILayout.EndHorizontal();

        if (panel.generateNormals != norms)
        {
            panel.generateNormals = norms;
            panel.UpdateDrawcalls();
            EditorUtility.SetDirty(panel);
        }

        GUILayout.BeginHorizontal();
        bool depth = EditorGUILayout.Toggle("Depth Pass", panel.depthPass, GUILayout.Width(100f));

        GUILayout.Label("Extra draw call, saves fillrate");
        GUILayout.EndHorizontal();

        if (panel.depthPass != depth)
        {
            panel.depthPass = depth;
            panel.UpdateDrawcalls();
            EditorUtility.SetDirty(panel);
        }

        GUILayout.BeginHorizontal();
        bool stat = EditorGUILayout.Toggle("Static", panel.widgetsAreStatic, GUILayout.Width(100f));

        GUILayout.Label("Check if widgets won't move");
        GUILayout.EndHorizontal();

        if (panel.widgetsAreStatic != stat)
        {
            panel.widgetsAreStatic = stat;
            panel.UpdateDrawcalls();
            EditorUtility.SetDirty(panel);
        }

        EditorGUILayout.LabelField("Widgets", panel.widgets.size.ToString());
        EditorGUILayout.LabelField("Draw Calls", drawcalls.size.ToString());

        UIPanel.DebugInfo di = (UIPanel.DebugInfo)EditorGUILayout.EnumPopup("Debug Info", panel.debugInfo);

        if (panel.debugInfo != di)
        {
            panel.debugInfo = di;
            EditorUtility.SetDirty(panel);
        }

        UIDrawCall.Clipping clipping = (UIDrawCall.Clipping)EditorGUILayout.EnumPopup("Clipping", panel.clipping);

        if (panel.clipping != clipping)
        {
            panel.clipping = clipping;
            EditorUtility.SetDirty(panel);
        }

        if (panel.clipping != UIDrawCall.Clipping.None)
        {
            Vector4 range = panel.clipRange;

            GUILayout.BeginHorizontal();
            GUILayout.Space(80f);
            Vector2 pos = EditorGUILayout.Vector2Field("Center", new Vector2(range.x, range.y));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(80f);
            Vector2 size = EditorGUILayout.Vector2Field("Size", new Vector2(range.z, range.w));
            GUILayout.EndHorizontal();

            if (size.x < 0f)
            {
                size.x = 0f;
            }
            if (size.y < 0f)
            {
                size.y = 0f;
            }

            range.x = pos.x;
            range.y = pos.y;
            range.z = size.x;
            range.w = size.y;

            if (panel.clipRange != range)
            {
                NGUIEditorTools.RegisterUndo("Clipping Change", panel);
                panel.clipRange = range;
                EditorUtility.SetDirty(panel);
            }

            if (panel.clipping == UIDrawCall.Clipping.SoftClip)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(80f);
                Vector2 soft = EditorGUILayout.Vector2Field("Softness", panel.clipSoftness);
                GUILayout.EndHorizontal();

                if (soft.x < 1f)
                {
                    soft.x = 1f;
                }
                if (soft.y < 1f)
                {
                    soft.y = 1f;
                }

                if (panel.clipSoftness != soft)
                {
                    NGUIEditorTools.RegisterUndo("Clipping Change", panel);
                    panel.clipSoftness = soft;
                    EditorUtility.SetDirty(panel);
                }
            }
        }

        if (clipping == UIDrawCall.Clipping.HardClip)
        {
            EditorGUILayout.HelpBox("Hard clipping has been removed due to major performance issues on certain Android devices. Alpha clipping will be used instead.", MessageType.Warning);
        }

        if (clipping != UIDrawCall.Clipping.None && !NGUIEditorTools.IsUniform(panel.transform.lossyScale))
        {
            EditorGUILayout.HelpBox("Clipped panels must have a uniform scale, or clipping won't work properly!", MessageType.Error);

            if (GUILayout.Button("Auto-fix"))
            {
                NGUIEditorTools.FixUniform(panel.gameObject);
            }
        }

        foreach (UIDrawCall dc in drawcalls)
        {
            NGUIEditorTools.DrawSeparator();
            EditorGUILayout.ObjectField("Material", dc.material, typeof(Material), false);
            EditorGUILayout.LabelField("Triangles", dc.triangles.ToString());

            if (clipping != UIDrawCall.Clipping.None && !dc.isClipped)
            {
                EditorGUILayout.HelpBox("You must switch this material's shader to Unlit/Transparent Colored or Unlit/Premultiplied Colored in order for clipping to work.",
                                        MessageType.Warning);
            }
        }
    }
示例#18
0
    public override void OnInspectorGUI()
    {
        MegaCacheOBJ mod = (MegaCacheOBJ)target;

        serializedObject.Update();

        EditorGUIUtility.LookLikeControls();

        EditorGUILayout.BeginVertical("box");
        mod.showdataimport = EditorGUILayout.Foldout(mod.showdataimport, "Data Import");

        if (mod.showdataimport)
        {
            EditorGUILayout.PropertyField(_prop_firstframe, new GUIContent("First"));
            EditorGUILayout.PropertyField(_prop_lastframe, new GUIContent("Last"));
            EditorGUILayout.PropertyField(_prop_skip, new GUIContent("Skip"));

            int val = 0;
            mod.decformat = EditorGUILayout.IntSlider("Format name" + val.ToString("D" + mod.decformat) + ".obj", mod.decformat, 1, 6);
            mod.namesplit = EditorGUILayout.TextField("Name Split Char", mod.namesplit);
            EditorGUILayout.PropertyField(_prop_scale, new GUIContent("Import Scale"));
            EditorGUILayout.PropertyField(_prop_adjustcords, new GUIContent("Adjust Coords"));
            EditorGUILayout.PropertyField(_prop_buildtangents, new GUIContent("Build Tangents"));
            EditorGUILayout.PropertyField(_prop_updatecollider, new GUIContent("Update Collider"));
            EditorGUILayout.PropertyField(_prop_loadmtls, new GUIContent("Load Materials"));

            if (GUILayout.Button("Load Frames"))
            {
                string file = EditorUtility.OpenFilePanel("OBJ File", mod.lastpath, "obj");

                if (file != null && file.Length > 1)
                {
                    mod.lastpath = file;
                    LoadOBJ(mod, file, mod.firstframe, mod.lastframe, mod.skip);
                }
            }

            if (mod.meshes.Count > 0)
            {
                if (GUILayout.Button("Clear Stored Meshes"))
                {
                    mod.DestroyMeshes();
                }
            }

            EditorGUILayout.EndVertical();
        }

        mod.showdata = EditorGUILayout.Foldout(mod.showdata, "Data");

        if (mod.showdata)
        {
            MegaCacheData src = (MegaCacheData)EditorGUILayout.EnumPopup("Data Source", mod.datasource);

            if (src != mod.datasource)
            {
                mod.ChangeSource(src);
            }

            switch (mod.datasource)
            {
            case MegaCacheData.Mesh:
                if (mod.meshes.Count > 0)
                {
                    EditorGUILayout.BeginVertical("box");
                    EditorGUILayout.PropertyField(_prop_saveuvs, new GUIContent("Save Uvs"));
                    EditorGUILayout.PropertyField(_prop_savenormals, new GUIContent("Save Normals"));
                    EditorGUILayout.PropertyField(_prop_savetangents, new GUIContent("Save Tangents"));
                    EditorGUILayout.PropertyField(_prop_optimize, new GUIContent("Optimize Data"));

                    if (GUILayout.Button("Save MegaCache File"))
                    {
                        string file = EditorUtility.SaveFilePanel("MegaCache File", mod.lastpath, mod.name, "mgc");

                        if (file != null && file.Length > 1)
                        {
                            mod.CloseCache();
                            CreateCacheFile(file);
                            if (mod.cachefile.Length == 0)
                            {
                                mod.cachefile = file;
                            }
                        }
                    }

                    if (GUILayout.Button("Create Image"))
                    {
                        CreateCacheImage();
                    }

                    EditorGUILayout.EndVertical();
                }
                break;

            case MegaCacheData.File:
                EditorGUILayout.BeginVertical("box");
                EditorGUILayout.TextArea("Cache File: " + mod.cachefile);

                if (GUILayout.Button("Select MegaCache File"))
                {
                    string file = EditorUtility.OpenFilePanel("MegaCache File", mod.lastpath, "mgc");

                    if (file != null && file.Length > 1)
                    {
                        mod.CloseCache();
                        mod.cachefile = file;
                        mod.update    = true;
                        mod.OpenCache(mod.cachefile);
                    }
                }

                EditorGUILayout.PropertyField(_prop_runtimefolder, new GUIContent("Runtime Folder"));

                if (mod.cachefile.Length > 0)
                {
                    if (GUILayout.Button("Create Image From Cache"))
                    {
                        bool doit = true;
                        if (mod.cacheimage)
                        {
                            if (!EditorUtility.DisplayDialog("Add to or Replace", "Image already loaded do you want to Replace?", "Yes", "No"))
                            {
                                doit = false;
                            }
                        }

                        if (doit)
                        {
                            mod.CreateImageFromCacheFile();
                        }
                    }
                }

                EditorGUILayout.EndVertical();
                break;

            case MegaCacheData.Image:
                if (mod.cacheimage)
                {
                    EditorGUILayout.BeginVertical("box");
#if !UNITY_FLASH && !UNITY_PS3 && !UNITY_METRO && !UNITY_WP8
                    mod.cacheimage.threadupdate = EditorGUILayout.Toggle("Preload", mod.cacheimage.threadupdate);
#endif
                    if (GUILayout.Button("Delete Image"))
                    {
                        mod.DestroyImage();                                     // = null;
                    }
                    EditorGUILayout.EndVertical();
                }
                break;
            }

            string info = "";

            info += "Frame Verts: " + mod.framevertcount + "\nFrame Tris: " + (mod.frametricount / 3);

            if (mod.datasource == MegaCacheData.Image)
            {
                if (mod.cacheimage)
                {
                    info += "\nMemory: " + mod.cacheimage.memoryuse / (1024 * 1024) + "MB";
                }
                else
                {
                    info += "\nNo Image File";
                }
            }

            EditorGUILayout.HelpBox(info, MessageType.None);
        }

        mod.showanimation = EditorGUILayout.Foldout(mod.showanimation, "Animation");

        if (mod.showanimation)
        {
            EditorGUILayout.BeginVertical("box");

            int fc = 0;
            switch (mod.datasource)
            {
            case MegaCacheData.Mesh: fc = mod.meshes.Count - 1; break;

            case MegaCacheData.File: fc = mod.framecount - 1; break;

            case MegaCacheData.Image:
                if (mod.cacheimage && mod.cacheimage.frames != null)
                {
                    fc = mod.cacheimage.frames.Count - 1;
                }
                break;
            }

            if (fc > 0)
            {
                EditorGUILayout.IntSlider(_prop_frame, 0, fc);
            }

            mod.animate = EditorGUILayout.BeginToggleGroup("Animate", mod.animate);
            EditorGUILayout.PropertyField(_prop_time, new GUIContent("Time"));
            EditorGUILayout.PropertyField(_prop_fps, new GUIContent("Fps"));
            EditorGUILayout.PropertyField(_prop_speed, new GUIContent("Speed"));
            EditorGUILayout.PropertyField(_prop_loopmode, new GUIContent("Loop Mode"));

            EditorGUILayout.EndToggleGroup();
            EditorGUILayout.EndVertical();
        }

        mod.showextras = EditorGUILayout.Foldout(mod.showextras, "Extra Options");

        if (mod.showextras)
        {
            mod.shownormals = EditorGUILayout.BeginToggleGroup("Show Normals", mod.shownormals);
            mod.normallen   = EditorGUILayout.FloatField("Normal Length", mod.normallen);
            EditorGUILayout.EndToggleGroup();
        }

        if (GUI.changed)
        {
            serializedObject.ApplyModifiedProperties();
            EditorUtility.SetDirty(target);
        }
    }
示例#19
0
        public override void OnInspectorGUI()
        {
            //show default variables of manager
            DrawDefaultInspector();
            //get manager reference
            script = (WaypointManager)target;

            //get sceneview to auto-detect 2D mode
            SceneView view = GetSceneView();

            mode2D = view.in2DMode;

            EditorGUIUtility.LookLikeControls();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();

            //draw path text label
            GUILayout.Label("Enter Path Name: ", GUILayout.Height(15));
            //display text field for creating a path with that name
            pathName = EditorGUILayout.TextField(pathName, GUILayout.Height(15));

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();

            //draw path type selection enum
            GUILayout.Label("Select Path Type: ", GUILayout.Height(15));
            pathType = (PathType)EditorGUILayout.EnumPopup(pathType);

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            //display label of current mode
            if (mode2D)
            {
                GUILayout.Label("2D Mode Detected.", GUILayout.Height(15));
            }
            else
            {
                GUILayout.Label("3D Mode Detected.", GUILayout.Height(15));
            }
            EditorGUILayout.Space();

            //draw path creation button
            if (!placing && GUILayout.Button("Start Path", GUILayout.Height(40)))
            {
                if (pathName == "")
                {
                    Debug.LogWarning("No path name defined. Cancelling.");
                    return;
                }

                if (script.transform.FindChild(pathName) != null)
                {
                    Debug.LogWarning("Path name already given. Cancelling.");
                    return;
                }

                //create a new container transform which will hold all new waypoints
                path = new GameObject(pathName);
                //reset position and parent container gameobject to this manager gameobject
                path.transform.position = script.gameObject.transform.position;
                path.transform.parent   = script.gameObject.transform;
                StartPath();

                //we passed all prior checks, toggle waypoint placement
                placing = true;
                //focus sceneview for placement
                view.Focus();
            }

            GUI.backgroundColor = Color.yellow;

            //finish path button
            if (placing && GUILayout.Button("Finish Editing", GUILayout.Height(40)))
            {
                if (wpList.Count < 2)
                {
                    Debug.LogWarning("Not enough waypoints placed. Cancelling.");
                    //if we have created a path already, destroy it again
                    if (path)
                    {
                        DestroyImmediate(path);
                    }
                }

                //toggle placement off
                placing = false;
                //clear list with temporary waypoint references,
                //we only needed this for getting the waypoint count
                wpList.Clear();
                //reset path name input field
                pathName = "";
                //make the new path the active selection
                Selection.activeGameObject = path;
            }

            GUI.backgroundColor = Color.white;
            EditorGUILayout.Space();
            //draw instructions
            GUILayout.TextArea("Hint:\nPress 'Start Path' to begin a new path, then press 'p' on "
                               + "your keyboard to place new waypoints in the SceneView. In 3D Mode "
                               + "you have to place waypoints onto objects with colliders. You can "
                               + "also place waypoints at the scene view position by pressing 'c'."
                               + "\n\nPress 'Finish Editing' to end your path.");
        }
示例#20
0
    /// <summary>
    /// Draw the UI for this tool.
    /// </summary>

    void OnGUI()
    {
        bool create  = false;
        bool update  = false;
        bool replace = false;

        string prefabPath = "";
        string matPath    = "";

        // If we have an atlas to work with, see if we can figure out the path for it and its material
        if (NGUISettings.atlas != null && NGUISettings.atlas.name == NGUISettings.atlasName)
        {
            prefabPath = AssetDatabase.GetAssetPath(NGUISettings.atlas.gameObject.GetInstanceID());
            if (NGUISettings.atlas.spriteMaterial != null)
            {
                matPath = AssetDatabase.GetAssetPath(NGUISettings.atlas.spriteMaterial.GetInstanceID());
            }
        }

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

        // Try to load the prefab
        GameObject go = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;

        if (NGUISettings.atlas == null && go != null)
        {
            NGUISettings.atlas = go.GetComponent <UIAtlas>();
        }

        EditorGUIUtility.LookLikeControls(80f);

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

        if (go == null)
        {
            GUI.backgroundColor = Color.green;
            create = GUILayout.Button("Create", GUILayout.Width(76f));
        }
        else
        {
            GUI.backgroundColor = Color.red;
            create = GUILayout.Button("Replace", GUILayout.Width(76f));
        }

        GUI.backgroundColor    = Color.white;
        NGUISettings.atlasName = GUILayout.TextField(NGUISettings.atlasName);
        GUILayout.EndHorizontal();

        if (create)
        {
            // If the prefab already exists, confirm that we want to overwrite it
            if (go == null || EditorUtility.DisplayDialog("Are you sure?", "Are you sure you want to replace the contents of the " +
                                                          NGUISettings.atlasName + " atlas with the textures currently selected in the Project View? All other sprites will be deleted.", "Yes", "No"))
            {
                replace = true;

                // Try to load the material
                Material mat = AssetDatabase.LoadAssetAtPath(matPath, typeof(Material)) as Material;

                // If the material doesn't exist, create it
                if (mat == null)
                {
                    Shader shader = Shader.Find(NGUISettings.atlasPMA ? "Unlit/Premultiplied Colored" : "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;
                }

                if (NGUISettings.atlas == null || NGUISettings.atlas.name != NGUISettings.atlasName)
                {
                    // Create a new prefab for the atlas
                    Object prefab = (go != null) ? go : PrefabUtility.CreateEmptyPrefab(prefabPath);

                    // Create a new game object for the atlas
                    go = new GameObject(NGUISettings.atlasName);
                    go.AddComponent <UIAtlas>().spriteMaterial = mat;

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

                    // Select the atlas
                    go = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;
                    NGUISettings.atlas = go.GetComponent <UIAtlas>();
                }
            }
        }

        ComponentSelector.Draw <UIAtlas>("Select", NGUISettings.atlas, OnSelectAtlas);

        List <Texture> textures = GetSelectedTextures();

        if (NGUISettings.atlas != null && NGUISettings.atlas.name == NGUISettings.atlasName)
        {
            Material mat = NGUISettings.atlas.spriteMaterial;
            Texture  tex = NGUISettings.atlas.texture;

            // Material information
            GUILayout.BeginHorizontal();
            {
                if (mat != null)
                {
                    if (GUILayout.Button("Material", GUILayout.Width(76f)))
                    {
                        Selection.activeObject = mat;
                    }
                    GUILayout.Label(" " + mat.name);
                }
                else
                {
                    GUI.color = Color.grey;
                    GUILayout.Button("Material", GUILayout.Width(76f));
                    GUI.color = Color.white;
                    GUILayout.Label(" N/A");
                }
            }
            GUILayout.EndHorizontal();

            // Texture atlas information
            GUILayout.BeginHorizontal();
            {
                if (tex != null)
                {
                    if (GUILayout.Button("Texture", GUILayout.Width(76f)))
                    {
                        Selection.activeObject = tex;
                    }
                    GUILayout.Label(" " + tex.width + "x" + tex.height);
                }
                else
                {
                    GUI.color = Color.grey;
                    GUILayout.Button("Texture", GUILayout.Width(76f));
                    GUI.color = Color.white;
                    GUILayout.Label(" N/A");
                }
            }
            GUILayout.EndHorizontal();
        }

        GUILayout.BeginHorizontal();
        NGUISettings.atlasPadding = Mathf.Clamp(EditorGUILayout.IntField("Padding", NGUISettings.atlasPadding, GUILayout.Width(100f)), 0, 8);
        GUILayout.Label((NGUISettings.atlasPadding == 1 ? "pixel" : "pixels") + " in-between of sprites");
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        NGUISettings.atlasTrimming = EditorGUILayout.Toggle("Trim Alpha", NGUISettings.atlasTrimming, GUILayout.Width(100f));
        GUILayout.Label("Remove empty space");
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        NGUISettings.atlasPMA = EditorGUILayout.Toggle("PMA Shader", NGUISettings.atlasPMA, GUILayout.Width(100f));
        GUILayout.Label("Pre-multiply color by alpha");
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        NGUISettings.unityPacking = EditorGUILayout.Toggle("Unity Packer", NGUISettings.unityPacking, GUILayout.Width(100f));
        GUILayout.Label("if off, use a custom packer");
        GUILayout.EndHorizontal();

        if (!NGUISettings.unityPacking)
        {
            GUILayout.BeginHorizontal();
            NGUISettings.forceSquareAtlas = EditorGUILayout.Toggle("Force Square", NGUISettings.forceSquareAtlas, GUILayout.Width(100f));
            GUILayout.Label("if on, forces a square atlas texture");
            GUILayout.EndHorizontal();
        }

#if UNITY_IPHONE || UNITY_ANDROID
        GUILayout.BeginHorizontal();
        NGUISettings.allow4096 = EditorGUILayout.Toggle("4096x4096", NGUISettings.allow4096, GUILayout.Width(100f));
        GUILayout.Label("if off, limit atlases to 2048x2048");
        GUILayout.EndHorizontal();
#endif
        if (NGUISettings.atlas != null && NGUISettings.atlas.name == NGUISettings.atlasName)
        {
            if (textures.Count > 0)
            {
                GUI.backgroundColor = Color.green;
                update = GUILayout.Button("Add/Update All");
                GUI.backgroundColor = Color.white;
            }
            else
            {
                EditorGUILayout.HelpBox("You can reveal more options by selecting one or more textures in the Project View window.", MessageType.Info);
            }
        }
        else
        {
            EditorGUILayout.HelpBox("You can create a new atlas by selecting one or more textures in the Project View window, then clicking \"Create\".", MessageType.Info);
        }

        string selection = null;
        Dictionary <string, int> spriteList = GetSpriteList(textures);

        if (spriteList.Count > 0)
        {
            NGUIEditorTools.DrawHeader("Sprites");
            GUILayout.Space(-7f);

            mScroll = GUILayout.BeginScrollView(mScroll);

            bool delete = false;
            int  index  = 0;
            foreach (KeyValuePair <string, int> iter in spriteList)
            {
                ++index;

                GUILayout.Space(-1f);
                bool highlight = (UIAtlasInspector.instance != null) && (NGUISettings.selectedSprite == iter.Key);
                GUI.backgroundColor = highlight ? Color.white : new Color(0.8f, 0.8f, 0.8f);
                GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
                GUI.backgroundColor = Color.white;
                GUILayout.Label(index.ToString(), GUILayout.Width(24f));

                if (GUILayout.Button(iter.Key, "OL TextField", GUILayout.Height(20f)))
                {
                    selection = iter.Key;
                }

                if (iter.Value == 2)
                {
                    GUI.color = Color.green;
                    GUILayout.Label("Add", GUILayout.Width(27f));
                    GUI.color = Color.white;
                }
                else if (iter.Value == 1)
                {
                    GUI.color = Color.cyan;
                    GUILayout.Label("Update", GUILayout.Width(45f));
                    GUI.color = Color.white;
                }
                else
                {
                    if (mDelNames.Contains(iter.Key))
                    {
                        GUI.backgroundColor = Color.red;

                        if (GUILayout.Button("Delete", GUILayout.Width(60f)))
                        {
                            delete = true;
                        }
                        GUI.backgroundColor = Color.green;
                        if (GUILayout.Button("X", GUILayout.Width(22f)))
                        {
                            mDelNames.Remove(iter.Key);
                            delete = false;
                        }
                        GUI.backgroundColor = Color.white;
                    }
                    else
                    {
                        // If we have not yet selected a sprite for deletion, show a small "X" button
                        if (GUILayout.Button("X", GUILayout.Width(22f)))
                        {
                            mDelNames.Add(iter.Key);
                        }
                    }
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();

            // If this sprite was marked for deletion, remove it from the atlas
            if (delete)
            {
                List <SpriteEntry> sprites = new List <SpriteEntry>();
                ExtractSprites(NGUISettings.atlas, sprites);

                for (int i = sprites.Count; i > 0;)
                {
                    SpriteEntry ent = sprites[--i];
                    if (mDelNames.Contains(ent.name))
                    {
                        sprites.RemoveAt(i);
                    }
                }
                UpdateAtlas(NGUISettings.atlas, sprites);
                mDelNames.Clear();
            }
            else if (update)
            {
                UpdateAtlas(textures, true);
            }
            else if (replace)
            {
                UpdateAtlas(textures, false);
            }

            if (NGUISettings.atlas != null && !string.IsNullOrEmpty(selection))
            {
                NGUISettings.selectedSprite = selection;
                Selection.activeGameObject  = NGUISettings.atlas.gameObject;

                if (UIAtlasInspector.instance != null)
                {
                    UIAtlasInspector.instance.Repaint();
                }
            }
        }
    }
示例#21
0
    public override void OnInspectorGUI()
    {
        so.Update();
        RefreshVars();

        EditorGUIUtility.LookLikeControls(135.0f, 50.0f);

        for (int i = 0; i < properties.Length; i += 1)
        {
            InspectorPlusVar v = vars[i];

            if (v.active && properties[i] != null)
            {
                SerializedProperty sp = properties [i]; string s = v.type;
                bool skip = false;
                name     = v.name;
                dispName = v.dispName;

                GUI.enabled = v.canWrite;

                GUILayout.BeginHorizontal();

                if (v.toggleLevel != 0)
                {
                    GUILayout.Space(v.toggleLevel * 10.0f);
                }

                if (s == typeof(float).Name)
                {
                    FloatField(sp, v);
                    skip = true;
                }
                if (s == typeof(int).Name)
                {
                    IntField(sp, v);
                    skip = true;
                }
                if (s == typeof(bool).Name)
                {
                    i   += BoolField(sp, v);
                    skip = true;
                }
                if (!skip)
                {
                    PropertyField(sp, name);
                }
                GUILayout.EndHorizontal();
                GUI.enabled = true;
            }
        }
        so.ApplyModifiedProperties();
        //NOTE NOTE NOTE: WATERMARK HERE
        //You are free to remove this
        //START REMOVE HERE
        GUILayout.BeginHorizontal();
        GUI.color = new Color(1.0f, 1.0f, 1.0f, 0.3f);
        GUILayout.FlexibleSpace();
        GUILayout.Label("Created with");
        GUI.color = new Color(1.0f, 1.0f, 1.0f, 0.6f);
        if (GUILayout.Button("Inspector++"))
        {
            Application.OpenURL("http://forum.unity3d.com/threads/136727-Inspector-Meh-to-WOW-inspectors");
        }
        GUI.color = new Color(1.0f, 1.0f, 1.0f);
        GUILayout.EndHorizontal();
        //END REMOVE HERE
    }
示例#22
0
        public override void OnInspectorGUI(NavGraph target)
        {
            PointGraph graph = target as PointGraph;

            /*
             #if UNITY_3_3
             *              graph.root = (Transform)EditorGUILayout.ObjectField (new GUIContent ("Root","All childs of this object will be used as nodes, if it is not set, a tag search will be used instead (see below)"),graph.root,typeof(Transform));
             #else
             *              graph.root = (Transform)EditorGUILayout.ObjectField (new GUIContent ("Root","All childs of this object will be used as nodes, if it is not set, a tag search will be used instead (see below)"),graph.root,typeof(Transform),true);
             #endif
             */
            //Debug.Log (EditorGUI.indentLevel);

            graph.root = ObjectField(new GUIContent("Root", "All childs of this object will be used as nodes, if it is not set, a tag search will be used instead (see below)"), graph.root, typeof(Transform), true) as Transform;

            graph.recursive = EditorGUILayout.Toggle(new GUIContent("Recursive", "Should childs of the childs in the root GameObject be searched"), graph.recursive);
            graph.searchTag = EditorGUILayout.TagField(new GUIContent("Tag", "If root is not set, all objects with this tag will be used as nodes"), graph.searchTag);

        #if UNITY_4
            if (graph.root != null)
            {
                EditorGUILayout.HelpBox("All childs " + (graph.recursive ? "and sub-childs ":"") + "of 'root' will be used as nodes\nSet root to null to use a tag search instead", MessageType.None);
            }
            else
            {
                EditorGUILayout.HelpBox("All object with the tag '" + graph.searchTag + "' will be used as nodes" + (graph.searchTag == "Untagged" ? "\nNote: the tag 'Untagged' cannot be used" : ""), MessageType.None);
            }
        #else
            if (graph.root != null)
            {
                GUILayout.Label("All childs " + (graph.recursive ? "and sub-childs ":"") + "of 'root' will be used as nodes\nSet root to null to use a tag search instead", AstarPathEditor.helpBox);
            }
            else
            {
                GUILayout.Label("All object with the tag '" + graph.searchTag + "' will be used as nodes" + (graph.searchTag == "Untagged" ? "\nNote: the tag 'Untagged' cannot be used" : ""), AstarPathEditor.helpBox);
            }
        #endif

            graph.maxDistance = EditorGUILayout.FloatField(new GUIContent("Max Distance", "The max distance in world space for a connection to be valid. A zero counts as infinity"), graph.maxDistance);

        #if UNITY_LE_4_3
            EditorGUIUtility.LookLikeControls();
        #endif
        #if UNITY_4
            graph.limits = EditorGUILayout.Vector3Field("Max Distance (axis aligned)", graph.limits);
        #else
            EditorGUILayoutx.BeginIndent();
            graph.limits = EditorGUILayout.Vector3Field("Max Distance (axis aligned)", graph.limits);
            EditorGUILayoutx.EndIndent();
        #endif
        #if UNITY_LE_4_3
            EditorGUIUtility.LookLikeInspector();
        #endif

            graph.raycast = EditorGUILayout.Toggle(new GUIContent("Raycast", "Use raycasting to check if connections are valid between each pair of nodes"), graph.raycast);

            //EditorGUILayoutx.FadeArea fade = editor.GUILayoutx.BeginFadeArea (graph.raycast,"raycast");
            //if ( fade.Show () ) {
            if (graph.raycast)
            {
                EditorGUI.indentLevel++;

                graph.thickRaycast = EditorGUILayout.Toggle(new GUIContent("Thick Raycast", "A thick raycast checks along a thick line with radius instead of just along a line"), graph.thickRaycast);

                //editor.GUILayoutx.BeginFadeArea (graph.thickRaycast,"thickRaycast");
                if (graph.thickRaycast)
                {
                    graph.thickRaycastRadius = EditorGUILayout.FloatField(new GUIContent("Raycast Radius", "The radius in world units for the thick raycast"), graph.thickRaycastRadius);
                }
                //editor.GUILayoutx.EndFadeArea ();

                //graph.mask = 1 << EditorGUILayout.LayerField ("Mask",(int)Mathf.Log (graph.mask,2));
                graph.mask = EditorGUILayoutx.LayerMaskField(/*new GUIContent (*/ "Mask" /*,"Used to mask which layers should be checked")*/, graph.mask);
                EditorGUI.indentLevel--;
            }

            //editor.GUILayoutx.EndFadeArea ();
        }
    //-------------------------------------------------------------------------
    void OnGUI()
    {
        AssetPostprocessorDetectTK2DCommit.TargetColliderGenTK2DWindow = this;

        bool isFirstOnGuiCallOfLayoutRenderPair = Event.current.type == EventType.Layout;

        if (isFirstOnGuiCallOfLayoutRenderPair)
        {
            CheckForSelectedSpriteCollectionAndSprites();
            CheckForValuesToUpdate();
        }

        EditorGUIUtility.LookLikeControls(150.0f);

        mScrollViewVector = GUILayout.BeginScrollView(mScrollViewVector);

        mLiveUpdate = EditorGUILayout.Toggle(mEditorLiveUpdateLabel, mLiveUpdate);

        // int [3..100] max point count
        mAlgorithmHelper.MaxPointCountOfFirstEnabledRegion = GuiHelper.IntSliderGuiElement(mColliderPointCountLabel, mAlgorithmHelper.MaxPointCountOfFirstEnabledRegion, 3, mPointCountSliderMax, ref mColliderPointCountChanged);

        // Note: Removed since it was not intuitive enough to use.
        // float [0..max(width, height)] Accepted Distance
        //float imageMinExtent = Mathf.Min(targetObject.mTextureWidth, targetObject.mTextureHeight);
        //targetObject.mVertexReductionDistanceTolerance = EditorGUILayout.Slider("Accepted Distance", targetObject.mVertexReductionDistanceTolerance, 0.0f, imageMinExtent/2);

        // float [0..1] Alpha Opaque Threshold
        mAlgorithmHelper.RegionIndependentParams.AlphaOpaqueThreshold = GuiHelper.FloatSliderGuiElement(mAlphaOpaqueThresholdLabel, mAlgorithmHelper.RegionIndependentParams.AlphaOpaqueThreshold, 0.0f, 1.0f, ref mNormalizedAlphaOpaqueThresholdChanged);

        mAlgorithmHelper.RegionIndependentParams.Convex = GuiHelper.ToggleGuiElement(mConvexLabel, mAlgorithmHelper.RegionIndependentParams.Convex, ref mConvexChanged);

        mAlgorithmHelper.RegionIndependentParams.FlipInsideOutside = GuiHelper.ToggleGuiElement(mFlipInsideOutsideLabel, mAlgorithmHelper.RegionIndependentParams.FlipInsideOutside, ref mFlipInsideOutsideChanged);

        // Advanced settings
        mShowAdvanced = EditorGUILayout.Foldout(mShowAdvanced, mAdvancedSettingsLabel);
        if (mShowAdvanced)
        {
            EditorGUI.indentLevel++;

            mAlgorithmHelper.RegionIndependentParams.CustomTex = (Texture2D)GuiHelper.ObjectFieldGuiElement(mCustomImageLabel, mAlgorithmHelper.RegionIndependentParams.CustomTex, typeof(Texture2D), false, ref mCustomTexChanged);

            mAlgorithmHelper.RegionIndependentParams.CustomScale  = GuiHelper.Vector2FieldGuiElement(mCustomScaleLabel, mAlgorithmHelper.RegionIndependentParams.CustomScale, ref mCustomScaleChanged);
            mAlgorithmHelper.RegionIndependentParams.CustomOffset = GuiHelper.Vector2FieldGuiElement(mCustomOffsetLabel, mAlgorithmHelper.RegionIndependentParams.CustomOffset, ref mCustomOffsetChanged);

            EditorGUI.indentLevel--;
        }

        bool haveColliderRegionEnabledChanged       = false;
        bool haveColliderRegionMaxPointCountChanged = false;
        bool haveColliderRegionConvexChanged        = false;

        OnInspectorGuiHolesAndIslandsSection(out haveColliderRegionEnabledChanged, out haveColliderRegionMaxPointCountChanged, out haveColliderRegionConvexChanged);

        if (GUILayout.Button(mCalculateOutlineVerticesLabel))
        {
            RecalculateSelectedColliders();
        }

        GUILayout.EndScrollView();

        if (mLiveUpdate && mSpriteCollectionProxyToEdit != null && mSpriteIDsToEdit != null)
        {
            bool pointCountNeedsUpdate = (mColliderPointCountChanged /*&& (mColliderPointCount > 2)*/);             // when typing 28, it would otherwise update at the first digit '2'.
            if (pointCountNeedsUpdate ||
                mFlipInsideOutsideChanged ||
                mConvexChanged ||
                mNormalizedAlphaOpaqueThresholdChanged ||
                mCustomTexChanged ||
                mCustomScaleChanged ||
                mCustomOffsetChanged ||
                haveColliderRegionEnabledChanged || haveColliderRegionMaxPointCountChanged || haveColliderRegionConvexChanged)
            {
                RecalculateSelectedColliders();
            }
        }
    }
示例#24
0
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeControls();

        BuildingCreation building_creation = (BuildingCreation)target as BuildingCreation;



        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.Separator();
        EditorGUILayout.Separator();
        EditorGUILayout.PrefixLabel("Generate All Buildings");
        building_creation.generateAllBuildings = EditorGUILayout.Toggle(building_creation.generateAllBuildings);

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Separator();



        EditorGUILayout.Separator();

        EditorGUILayout.Separator();
        EditorGUILayout.BeginHorizontal();
        building_creation.buildingsToGenerate = (int)EditorGUILayout.IntSlider("Buildings to Generate", building_creation.buildingsToGenerate, 1, number_of_buildings);
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.Separator();

        EditorGUILayout.Separator();
        EditorGUILayout.BeginHorizontal();
        building_creation.scalingFactor = (float)EditorGUILayout.Slider("Scaling Factor", building_creation.scalingFactor, 1, 100);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();
        Rect startButton = EditorGUILayout.BeginHorizontal();

        startButton.x      = startButton.width / 2 - 100;
        startButton.width  = 200;
        startButton.height = 18;

        if (!enter)
        {
            setNumberOfBuildings();
            enter = true;
        }
        if (GUI.Button(startButton, "Create Buildings"))
        {
            building_creation.createBuilding();

            GUIUtility.ExitGUI();
        }



        if (GUI.changed)
        {
            EditorUtility.SetDirty(building_creation);
        }
    }
示例#25
0
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeControls(80f);
        mList = target as UIPopupList;

        ComponentSelector.Draw <UIAtlas>(mList.atlas, OnSelectAtlas);
        ComponentSelector.Draw <UIFont>(mList.font, OnSelectFont);

        UILabel lbl = EditorGUILayout.ObjectField("Text Label", mList.textLabel, typeof(UILabel), true) as UILabel;

        if (mList.textLabel != lbl)
        {
            RegisterUndo();
            mList.textLabel = lbl;
            if (lbl != null)
            {
                lbl.text = mList.selection;
            }
        }

        if (mList.atlas != null)
        {
            string bg = UISpriteInspector.SpriteField(mList.atlas, "Background", mList.backgroundSprite);
            string hl = UISpriteInspector.SpriteField(mList.atlas, "Highlight", mList.highlightSprite);

            if (mList.backgroundSprite != bg || mList.highlightSprite != hl)
            {
                RegisterUndo();
                mList.backgroundSprite = bg;
                mList.highlightSprite  = hl;
            }

            GUILayout.BeginHorizontal();
            GUILayout.Space(6f);
            GUILayout.Label("Options");
            GUILayout.EndHorizontal();

            string text = "";
            foreach (string s in mList.items)
            {
                text += s + "\n";
            }

            GUILayout.Space(-22f);
            GUILayout.BeginHorizontal();
            GUILayout.Space(84f);
            string modified = EditorGUILayout.TextArea(text, GUILayout.Height(100f));
            GUILayout.EndHorizontal();

            if (modified != text)
            {
                RegisterUndo();
                string[] split = modified.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries);
                mList.items.Clear();
                foreach (string s in split)
                {
                    mList.items.Add(s);
                }

                if (string.IsNullOrEmpty(mList.selection) || !mList.items.Contains(mList.selection))
                {
                    mList.selection = mList.items.Count > 0 ? mList.items[0] : "";
                }
            }

            string sel = NGUIEditorTools.DrawList("Selection", mList.items.ToArray(), mList.selection);

            if (mList.selection != sel)
            {
                RegisterUndo();
                mList.selection = sel;
            }

            float ts = EditorGUILayout.FloatField("Text Scale", mList.textScale);
            Color tc = EditorGUILayout.ColorField("Text Color", mList.textColor);
            Color bc = EditorGUILayout.ColorField("Background", mList.backgroundColor);
            Color hc = EditorGUILayout.ColorField("Highlight", mList.highlightColor);

            GUILayout.BeginHorizontal();
            bool isLocalized = EditorGUILayout.Toggle("Localized", mList.isLocalized, GUILayout.Width(100f));
            bool isAnimated  = EditorGUILayout.Toggle("Animated", mList.isAnimated);
            GUILayout.EndHorizontal();

            if (mList.textScale != ts ||
                mList.textColor != tc ||
                mList.highlightColor != hc ||
                mList.backgroundColor != bc ||
                mList.isLocalized != isLocalized ||
                mList.isAnimated != isAnimated)
            {
                RegisterUndo();
                mList.textScale       = ts;
                mList.textColor       = tc;
                mList.backgroundColor = bc;
                mList.highlightColor  = hc;
                mList.isLocalized     = isLocalized;
                mList.isAnimated      = isAnimated;
            }

            NGUIEditorTools.DrawSeparator();

            GUILayout.BeginHorizontal();
            GUILayout.Space(6f);
            GUILayout.Label("Padding", GUILayout.Width(76f));
            GUILayout.BeginVertical();
            GUILayout.Space(-12f);
            Vector2 padding = EditorGUILayout.Vector2Field("", mList.padding);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            if (mList.padding != padding)
            {
                RegisterUndo();
                mList.padding = padding;
            }

            EditorGUIUtility.LookLikeControls(100f);

            GameObject go = EditorGUILayout.ObjectField("Event Receiver", mList.eventReceiver,
                                                        typeof(GameObject), true) as GameObject;

            string fn = EditorGUILayout.TextField("Function Name", mList.functionName);

            if (mList.eventReceiver != go || mList.functionName != fn)
            {
                RegisterUndo();
                mList.eventReceiver = go;
                mList.functionName  = fn;
            }
        }
    }
    public override void OnInspectorGUI()
    {
        this.m_Target = (PhotonView)target;
        bool isProjectPrefab = EditorUtility.IsPersistent(this.m_Target.gameObject);

        if (this.m_Target.ObservedComponents == null)
        {
            this.m_Target.ObservedComponents = new System.Collections.Generic.List <Component>();
        }

        if (this.m_Target.ObservedComponents.Count == 0)
        {
            this.m_Target.ObservedComponents.Add(null);
        }

        EditorGUILayout.BeginHorizontal();
        // Owner
        if (isProjectPrefab)
        {
            EditorGUILayout.LabelField("Owner:", "Set at runtime");
        }
        else if (!this.m_Target.isOwnerActive)
        {
            EditorGUILayout.LabelField("Owner", "Scene");
        }
        else
        {
            PhotonPlayer owner     = this.m_Target.owner;
            string       ownerInfo = (owner != null) ? owner.NickName : "<no PhotonPlayer found>";

            if (string.IsNullOrEmpty(ownerInfo))
            {
                ownerInfo = "<no playername set>";
            }

            EditorGUILayout.LabelField("Owner", "[" + this.m_Target.ownerId + "] " + ownerInfo);
        }

        // ownership requests
        EditorGUI.BeginDisabledGroup(Application.isPlaying);
        OwnershipOption own = (OwnershipOption)EditorGUILayout.EnumPopup(this.m_Target.ownershipTransfer, GUILayout.Width(100));

        if (own != this.m_Target.ownershipTransfer)
        {
            // jf: fixed 5 and up prefab not accepting changes if you quit Unity straight after change.
            // not touching the define nor the rest of the code to avoid bringing more problem than solving.
            EditorUtility.SetDirty(this.m_Target);

            Undo.RecordObject(this.m_Target, "Change PhotonView Ownership Transfer");
            this.m_Target.ownershipTransfer = own;
        }
        EditorGUI.EndDisabledGroup();

        EditorGUILayout.EndHorizontal();


        // View ID
        if (isProjectPrefab)
        {
            EditorGUILayout.LabelField("View ID", "Set at runtime");
        }
        else if (EditorApplication.isPlaying)
        {
            EditorGUILayout.LabelField("View ID", this.m_Target.viewID.ToString());
        }
        else
        {
            int idValue = EditorGUILayout.IntField("View ID [1.." + (PhotonNetworkManager.MAX_VIEW_IDS - 1) + "]", this.m_Target.viewID);
            if (this.m_Target.viewID != idValue)
            {
                Undo.RecordObject(this.m_Target, "Change PhotonView viewID");
                this.m_Target.viewID = idValue;
            }
        }

        // Locally Controlled
        if (EditorApplication.isPlaying)
        {
            string masterClientHint = PhotonNetworkManager.isMasterClient ? "(master)" : "";
            EditorGUILayout.Toggle("Controlled locally: " + masterClientHint, this.m_Target.isMine);
        }

        // ViewSynchronization (reliability)
        if (this.m_Target.synchronization == ViewSynchronization.Off)
        {
            GUI.color = Color.grey;
        }

        EditorGUILayout.PropertyField(serializedObject.FindProperty("synchronization"), new GUIContent("Observe option:"));

        if (this.m_Target.synchronization != ViewSynchronization.Off && this.m_Target.ObservedComponents.FindAll(item => item != null).Count == 0)
        {
            GUILayout.BeginVertical(GUI.skin.box);
            GUILayout.Label("Warning", EditorStyles.boldLabel);
            GUILayout.Label("Setting the synchronization option only makes sense if you observe something.");
            GUILayout.EndVertical();
        }

        DrawSpecificTypeSerializationOptions();

        GUI.color = Color.white;
        DrawObservedComponentsList();

        // Cleanup: save and fix look
        if (GUI.changed)
        {
            #if !UNITY_MIN_5_3
            EditorUtility.SetDirty(this.m_Target);
            #endif
            PhotonViewHandler.HierarchyChange(); // TODO: check if needed
        }

        GUI.color = Color.white;
        #if !UNITY_MIN_5_3
        EditorGUIUtility.LookLikeControls();
        #endif
    }
示例#27
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        bool changeOccurred = false;

        EditorGUIUtility.LookLikeControls(180);
        tk2dUIItem btn = (tk2dUIItem)target;

        bool newIsChildOfAnotherMenuBtn = EditorGUILayout.Toggle("Child of Another UIItem?", btn.InternalGetIsChildOfAnotherUIItem());

        if (newIsChildOfAnotherMenuBtn != btn.InternalGetIsChildOfAnotherUIItem())
        {
            changeOccurred = true;
            btn.InternalSetIsChildOfAnotherUIItem(newIsChildOfAnotherMenuBtn);
        }

        btn.registerPressFromChildren = EditorGUILayout.Toggle("Register Events From Children", btn.registerPressFromChildren);

        btn.isHoverEnabled = EditorGUILayout.Toggle("Is Hover Events Enabled?", btn.isHoverEnabled);

        GUILayout.Label("Send Message", EditorStyles.boldLabel);
        EditorGUI.indentLevel++;

        GameObject newSendMessageTarget = EditorGUILayout.ObjectField("Target", btn.sendMessageTarget, typeof(GameObject), true, null) as GameObject;

        if (newSendMessageTarget != btn.sendMessageTarget)
        {
            changeOccurred        = true;
            btn.sendMessageTarget = newSendMessageTarget;
        }
        if (btn.sendMessageTarget != null && EditorUtility.IsPersistent(btn.sendMessageTarget))
        {
            changeOccurred        = true;
            btn.sendMessageTarget = null;
        }
        if (btn.sendMessageTarget != null)
        {
            btn.SendMessageOnDownMethodName    = EditorGUILayout.TextField("On Down Method Name", btn.SendMessageOnDownMethodName);
            btn.SendMessageOnUpMethodName      = EditorGUILayout.TextField("On Up Method Name", btn.SendMessageOnUpMethodName);
            btn.SendMessageOnClickMethodName   = EditorGUILayout.TextField("On Clicked Method Name", btn.SendMessageOnClickMethodName);
            btn.SendMessageOnReleaseMethodName = EditorGUILayout.TextField("On Release Method Name", btn.SendMessageOnReleaseMethodName);
        }
        EditorGUI.indentLevel--;

        if (btn.GetComponent <Collider>() != null)
        {
            GUILayout.Label("Collider", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;

            GUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Automatic Fit");
            if (GUILayout.Button("Fit", GUILayout.MaxWidth(100)))
            {
                tk2dUIItemBoundsHelper.FixColliderBounds(btn);
            }
            GUILayout.EndHorizontal();

            ArrayProperty("Extra Bounds", extraBoundsProp);
            ArrayProperty("Ignore Bounds", ignoreBoundsProp);

            EditorGUI.indentLevel--;
        }

        serializedObject.ApplyModifiedProperties();
        if (GUI.changed || changeOccurred)
        {
            EditorUtility.SetDirty(btn);
        }
    }
示例#28
0
    /// <summary>
    /// Draw the inspector.
    /// </summary>

    public override void OnInspectorGUI()
    {
#if UNITY_4_3
        EditorGUIUtility.LookLikeControls(130f);
#else
        EditorGUIUtility.labelWidth = 130f;
#endif
        m = target as NJGMapZone;

        NJGEditorTools.DrawEditMap();

        GUILayout.BeginHorizontal("AppToolbar");
        EditorGUILayout.LabelField(new GUIContent("Zone Name Preview", ""), GUILayout.Width(130f));
        GUI.contentColor = m.color;
        EditorGUILayout.LabelField(new GUIContent(m.zone, ""), EditorStyles.boldLabel);
        GUI.contentColor = Color.white;
        GUILayout.EndHorizontal();

        string level             = NJGEditorTools.DrawList("Level", NJGMapBase.instance.GetLevels(), m.level);
        string zone              = NJGEditorTools.DrawList("Zone", NJGMapBase.instance.GetZones(m.level), m.zone);
        string triggerTag        = EditorGUILayout.TagField("Trigger Tag", m.triggerTag);
        int    colliderRadius    = (int)EditorGUILayout.Slider("Collider Radius", m.colliderRadius, 1, 1000);
        bool   generateOnTrigger = EditorGUILayout.Toggle("Generate On Trigger", m.generateOnTrigger);

        string name = "Zone - [" + NJGMapZone.list.IndexOf(m) + "] " + m.zone;

        if (m.name != name ||
            m.level != level ||
            m.zone != zone ||
            m.triggerTag != triggerTag ||
            m.colliderRadius != colliderRadius ||
            m.generateOnTrigger != generateOnTrigger)
        {
            m.name                = name;
            m.level               = level;
            m.zone                = zone;
            m.triggerTag          = triggerTag;
            m.colliderRadius      = colliderRadius;
            m.zoneCollider.radius = colliderRadius;
            m.generateOnTrigger   = generateOnTrigger;

            NJGEditorTools.RegisterUndo("NJG Zone Update", m);
        }

        /*if (NJGMapBase.instance != null)
         * {
         *      if (NJGMapBase.instance.atlas != null)
         *      {
         *              extraSpace = Mathf.Max(0f, extraSpace - 30f);
         *      }
         * }*/

        NJGEditorTools.DrawSeparator();

        GUILayout.BeginHorizontal();

        GUI.backgroundColor = Color.green;
        if (GUILayout.Button("Add New Zone"))
        {
            NJGMenu.AddMapZone();
        }
        GUI.backgroundColor = Color.white;

        GUI.backgroundColor = Color.red;
        if (GUILayout.Button("Delete Zone"))
        {
            Delete();
        }
        GUI.backgroundColor = Color.white;

        GUILayout.EndHorizontal();

        EditorGUILayout.Separator();
    }
    /// <summary>
    /// Draw the custom wizard.
    /// </summary>

    void OnGUI()
    {
        // Load the saved preferences
        if (!mLoaded)
        {
            mLoaded = true; Load();
        }

        EditorGUIUtility.LookLikeControls(80f);
        GameObject go = NGUIEditorTools.SelectedRoot();

        if (go == null)
        {
            GUILayout.Label("You must create a UI first.");

            if (GUILayout.Button("Open the New UI Wizard"))
            {
                EditorWindow.GetWindow <UICreateNewUIWizard>(false, "New UI", true);
            }
        }
        else
        {
            GUILayout.Space(4f);

            GUILayout.BeginHorizontal();
            ComponentSelector.Draw <UIAtlas>(NGUISettings.atlas, OnSelectAtlas, GUILayout.Width(140f));
            GUILayout.Label("Texture atlas used by widgets", GUILayout.MinWidth(10000f));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            ComponentSelector.Draw <UIFont>(NGUISettings.font, OnSelectFont, GUILayout.Width(140f));
            GUILayout.Label("Font used by labels", GUILayout.MinWidth(10000f));
            GUILayout.EndHorizontal();

            GUILayout.Space(-2f);
            NGUIEditorTools.DrawSeparator();

            GUILayout.BeginHorizontal();
            WidgetType wt = (WidgetType)EditorGUILayout.EnumPopup("Template", mType, GUILayout.Width(200f));
            GUILayout.Space(20f);
            GUILayout.Label("Select a widget template to use");
            GUILayout.EndHorizontal();

            if (mType != wt)
            {
                mType = wt; Save();
            }

            switch (mType)
            {
            case WidgetType.Label:                  CreateLabel(go); break;

            case WidgetType.Sprite:                 CreateSprite(go, mSprite); break;

            case WidgetType.Texture:                CreateSimpleTexture(go); break;

            case WidgetType.Button:                 CreateButton(go); break;

            case WidgetType.ImageButton:    CreateImageButton(go); break;

            case WidgetType.Checkbox:               CreateCheckbox(go); break;

            case WidgetType.ProgressBar:    CreateSlider(go, false); break;

            case WidgetType.Slider:                 CreateSlider(go, true); break;

            case WidgetType.Input:                  CreateInput(go); break;

            case WidgetType.PopupList:              CreatePopup(go, true); break;

            case WidgetType.PopupMenu:              CreatePopup(go, false); break;

            case WidgetType.ScrollBar:              CreateScrollBar(go); break;
            }
        }
    }
示例#30
0
 private void DrawConditionsHeader(Rect headerRect)
 {
     EditorGUIUtility.LookLikeControls();
     GUI.Label(headerRect, new GUIContent("Conditions"));
 }