Ejemplo n.º 1
0
 static void OnSceneChanged()
 {
     if (currentScene != EditorSceneManager.GetActiveScene().name)
     {
         toolEnabled = false;
         YuME_sceneGizmoFunctions.displayGizmoGrid();
         YuTools_Utils.showUnityGrid(true);
         currentScene = EditorSceneManager.GetActiveScene().name;
     }
 }
Ejemplo n.º 2
0
    void OnEnable()
    {
        editorData = ScriptableObject.CreateInstance <YuME_editorData>();
        AssetPreview.SetPreviewTextureCacheSize(1000);
        YuTools_Utils.disableTileGizmo(showGizmos);
        YuTools_Utils.addLayer("YuME_TileMap");

        YuME_brushFunctions.cleanSceneOfBrushObjects();

        string[] guids;

        // ----------------------------------------------------------------------------------------------------
        // ----- Load Editor Settings
        // ----------------------------------------------------------------------------------------------------

        guids      = AssetDatabase.FindAssets("YuME_editorSetupData");
        editorData = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guids[0]), typeof(YuME_editorData)) as YuME_editorData;

        importTileSets(false);
        loadPreviewTiles();
        loadCustomBrushes();

        _toolEnabled = toolEnabled;

        gridSceneObject = GameObject.Find("YuME_MapEditorObject");

        updateGridColors();

        gridHeight = 0;

        YuME_brushFunctions.createBrushTile();

        YuTools_Utils.showUnityGrid(true);
        SceneView.RepaintAll();

        // ----------------------------------------------------------------------------------------------------
        // ----- Setup Scene Delegates
        // ----------------------------------------------------------------------------------------------------

        currentScene = EditorSceneManager.GetActiveScene().name;

        SceneView.onSceneGUIDelegate -= OnSceneGUI;
        SceneView.onSceneGUIDelegate += OnSceneGUI;

        EditorApplication.hierarchyWindowChanged -= OnSceneChanged;
        EditorApplication.hierarchyWindowChanged += OnSceneChanged;
    }
Ejemplo n.º 3
0
    bool checkForForzenMap()
    {
        if (findTileMapParent())
        {
            foreach (Transform chid in tileMapParent.transform)
            {
                if (chid.gameObject.name == "frozenMap")
                {
                    toolEnabled = false;
                    YuTools_Utils.showUnityGrid(true);
                    return(true);
                }
            }
        }

        return(false);
    }
Ejemplo n.º 4
0
    void mainGUI()
    {
        if (Event.current != null)
        {
            // ----------------------------------------------------------------------------------------------------
            // ----- Check Keyboard and Mouse Shortcuts
            // ----------------------------------------------------------------------------------------------------

            YuME_keyboardShortcuts.checkKeyboardShortcuts(Event.current);
            YuME_mouseShorcuts.checkMouseShortcuts(Event.current);

            SceneView.RepaintAll();
        }

        EditorGUILayout.Space();

        GUILayout.Label(editorData.mapEditorHeader);

        EditorGUILayout.BeginVertical("box");

        if (GUILayout.Button("Get the full version of YuME", GUILayout.Height(30)))
        {
            Application.OpenURL("http://u3d.as/DrF");
        }

        EditorGUILayout.BeginHorizontal();

        toolEnabled = GUILayout.Toggle(toolEnabled, "Enable YuME", "Button", GUILayout.Height(30));

        if (_toolEnabled != toolEnabled)
        {
            if (!toolEnabled)
            {
                YuTools_Utils.showUnityGrid(true);
                YuME_tileFunctions.restoreIsolatedGridTiles();
                YuME_tileFunctions.restoreIsolatedLayerTiles();
            }
            else
            {
                setTileBrush(0);
                YuTools_Utils.showUnityGrid(false);
            }

            SceneView.RepaintAll();
        }

        _toolEnabled = toolEnabled;

        openConfig = GUILayout.Toggle(openConfig, editorData.configButton, "Button", GUILayout.Width(30), GUILayout.Height(30));

        if (openConfig == true)
        {
            YuME_editorConfig editorConfig = EditorWindow.GetWindow <YuME_editorConfig>(true, "Editor Config");
            editorConfig.titleContent.text = "Editor Config";
        }

        openConfig = false;

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

        EditorGUILayout.BeginVertical("box");
        gridDimensions = EditorGUILayout.Vector2Field("Grid Dimensions", gridDimensions);
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical("box");
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Grid Height: " + gridHeight.ToString());
        GUILayout.Label("Brush Size: (" + brushSize.x.ToString() + "," + brushSize.y.ToString() + "," + brushSize.z.ToString() + ")");
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical("box");
        EditorGUILayout.LabelField("Pick The Tile Set To Use", EditorStyles.boldLabel);
        currentTileSetIndex = EditorGUILayout.Popup("Choose Tileset", currentTileSetIndex, tileSetNames);

        if (currentTileSetIndex != _currentTileSetIndex)
        {
            loadPreviewTiles();
        }

        if (GUILayout.Button("Reload Available Tilesets", GUILayout.Height(30)))
        {
            importTileSets(true);
            loadCustomBrushes();
            loadPreviewTiles(); // this is in the wrong place - it needs to be triggered when the user picks a new tileset
        }

        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical("box");

        string[] buttonLabels = new string[] { "Tileset Brushes", "Custom Brushes" };

        brushPallete = (brushOptions)GUILayout.SelectionGrid(
            (int)brushPallete,
            buttonLabels,
            2,
            EditorStyles.toolbarButton
            );

        EditorGUILayout.EndVertical();

        drawTilePreviews();

        EditorGUILayout.BeginVertical("box");

        EditorGUILayout.LabelField("Tile Previw Columns", EditorStyles.boldLabel);
        tilePreviewColumnWidth = EditorGUILayout.IntSlider(tilePreviewColumnWidth, 1, 10);

        EditorGUILayout.EndVertical();

        updateGridColors();
        YuME_sceneGizmoFunctions.displayGizmoGrid();

        _currentTileSetIndex = currentTileSetIndex;
    }