Exemplo n.º 1
0
        private void ShowCostDrawing(Pathfinder myTarget)
        {
            EditorGUILayout.Space();
            if (myTarget.worldData.drawCost)
            {
                if (GUILayout.Button(" Close cost field "))
                {
                    myTarget.worldData.drawCost = false;
                    myTarget.costManager.RemoveCostField();
                }
            }
            else
            {
                if (GUILayout.Button(" Open/Create cost field "))
                {
                    myTarget.worldData.drawCost = true;
                    myTarget.costManager.SetupCostField();
                }
            }


            if (myTarget.worldData.drawCost)
            {
                myTarget.maxCostValue  = EditorGUILayout.IntSlider("Maximum Cost Value ", myTarget.maxCostValue, 1, 100);
                myTarget.brushStrength = EditorGUILayout.IntSlider("Brush Strength ", myTarget.brushStrength, 1, 100);


                myTarget.brushSize    = EditorGUILayout.IntPopup("Brush Size", myTarget.brushSize, brushScaleNames, brushScaleValues);
                myTarget.brushFallOff = EditorGUILayout.IntSlider("Brush Strength FallOff", myTarget.brushFallOff, 0, 10);
            }



            EditorGUILayout.Space();
            if (GUILayout.Button(" Save Cost Field "))
            {
                Debug.Log("save button pressed");
                myTarget.GetComponent <SaveLoad>().SaveLevel();
                EditorUtility.SetDirty(target);
            }

            if (GUILayout.Button(" Load Cost Field "))
            {
                myTarget.GenerateWorld(false, true);
            }
        }
Exemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            Pathfinder myTarget = (Pathfinder)target;

            Undo.RecordObject(myTarget, "modify settings on Pathfinder");

            EditorGUILayout.Space();
            Settings(myTarget);

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

            VisualDebugging(myTarget);


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

            CostDrawing(myTarget);



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



            GUI.backgroundColor = Color.yellow;
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            content.text    = "Generate Map";
            content.tooltip = "Gives you a preview of what the map will look like, and allows you to draw cost in the editor.";
            if (GUILayout.Button(content))
            {
                myTarget.GenerateWorld(false, false);
                EditorUtility.SetDirty(target);
            }


            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            content.text    = "Remove Existing CostField";
            content.tooltip = "Save an empty costfield over the existing one.";
            if (GUILayout.Button(content))
            {
                myTarget.worldData.costFields = new List <int[][]>();
                myTarget.GetComponent <SaveLoad>().SaveLevel();
            }



            //SECURITY!! only change if you understand what this changes, read documentation
            if (GUI.changed)
            {
                if (myTarget.generationClimbHeight > myTarget.characterHeight * 0.98f)
                {
                    myTarget.generationClimbHeight = myTarget.characterHeight * 0.98f;
                }

                //myTarget.characterClimbHeight = myTarget.generationClimbHeight;
                // if (myTarget.characterClimbHeight > myTarget.generationClimbHeight * 0.98f)
                //    myTarget.characterClimbHeight = myTarget.generationClimbHeight * 0.98f;



                //myTarget.tileSize = EditorGUILayout.FloatField("Tile Size ", myTarget.tileSize);
                // Undo.RegisterUndo(myTarget, "Tile Size");
                //Undo.RecordObject(myTarget, "Set Tile Size");
                EditorUtility.SetDirty(target);
            }
        }