init() public method

public init ( ) : void
return void
コード例 #1
0
    public override void OnInspectorGUI()
    {
        // Create the inspector UI slider for easy visualization
        theGridsGameVisual.m_gridWidth  = createTileSlider("Grid Width", theGridsGameVisual.m_gridWidth);
        theGridsGameVisual.m_gridHeight = createTileSlider("Grid Height", theGridsGameVisual.m_gridHeight);
        theGridsGameVisual.m_mapWidth   = createTileSlider("Map Width", theGridsGameVisual.m_mapWidth, 256f, 100000);
        theGridsGameVisual.m_mapHeight  = createTileSlider("Map Height", theGridsGameVisual.m_mapHeight, 256, 100000);

        if (GUILayout.Button("Open Grid Window"))
        {
            GridWindow theGridEditorWindow = EditorWindow.GetWindow <GridWindow>();
            theGridEditorWindow.init();
        }
    }
コード例 #2
0
ファイル: GridEditor.cs プロジェクト: lsoyul/JADproject
    public override void OnInspectorGUI()
    {
        grid.tileWidth  = createSlider("Grid Width", grid.tileWidth);
        grid.tileHeight = createSlider("Grid Height", grid.tileHeight);

        if (GUILayout.Button("Open Grid Window"))
        {
            GridWindow window = (GridWindow)EditorWindow.GetWindow(typeof(GridWindow));
            window.init();
        }

        // Tile prefab
        EditorGUI.BeginChangeCheck();
        var newTilePrefab = (Transform)EditorGUILayout.ObjectField("Tile Prefab", grid.tilePrefab, typeof(Transform), false);

        if (EditorGUI.EndChangeCheck())
        {
            grid.tilePrefab = newTilePrefab;
            Undo.RecordObject(target, "Grid Changed");
        }


        // Tile Map
        EditorGUI.BeginChangeCheck();
        var newTileSet = (TileSet)EditorGUILayout.ObjectField("Tile set", grid.tileSet, typeof(TileSet), false);

        if (EditorGUI.EndChangeCheck())
        {
            grid.tileSet = newTileSet;
            Undo.RecordObject(target, "Grid Changed");
        }


        if (grid.tileSet != null)
        {
            EditorGUI.BeginChangeCheck();
            var names  = new string[grid.tileSet.prefabs.Length];
            var values = new int[names.Length];

            for (int i = 0; i < names.Length; i++)
            {
                names[i]  = grid.tileSet.prefabs[i] != null ? grid.tileSet.prefabs[i].name : "Empty";
                values[i] = i;
            }

            var index = EditorGUILayout.IntPopup("Select Tile!", oldIndex, names, values);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "Grid Changed");
                if (oldIndex != index)
                {
                    oldIndex        = index;
                    grid.tilePrefab = grid.tileSet.prefabs[index];

                    float width  = grid.tilePrefab.GetComponent <Renderer>().bounds.size.x;
                    float height = grid.tilePrefab.GetComponent <Renderer>().bounds.size.y;

                    grid.tileWidth  = width;
                    grid.tileHeight = height;
                }
            }
        }
    }
コード例 #3
0
ファイル: GridEditor.cs プロジェクト: bang22/unity5_tileMap
    public override void OnInspectorGUI()//인스펙터에서
    {
        //base.OnInspectorGUI();

        grid.widht  = createSlider("Grid Width", grid.widht);
        grid.height = createSlider("Grid height", grid.height);

        if (GUILayout.Button("Open Grid Window"))
        {
            GridWindow window = (GridWindow)EditorWindow.GetWindow(typeof(GridWindow));
            window.init();
        }

        grid.zOrder = (int)Mathf.Floor(createSlider("Order in Layer", grid.zOrder));

        //타일 프리팹
        EditorGUI.BeginChangeCheck();
        var newTileprefap = (Transform)EditorGUILayout.ObjectField("Tile prefap", grid.tileprefab, typeof(Transform), false);

        if (EditorGUI.EndChangeCheck())
        {
            grid.tileprefab = newTileprefap;
            Undo.RecordObject(target, "Grid Changed");
        }

        //타일맵
        EditorGUI.BeginChangeCheck();
        var newTileSet = (TileSet)EditorGUILayout.ObjectField("TileSet", grid.tileSet, typeof(TileSet), false);

        if (EditorGUI.EndChangeCheck())
        {
            grid.tileSet = newTileSet;
            Undo.RecordObject(target, "Grid Changed");
        }

        if (grid.tileSet != null)//타일셋이 비어있지 않다면 타일셋의 목록을 만듬
        {
            EditorGUI.BeginChangeCheck();
            var names  = new string[grid.tileSet.prefaps.Length];
            var values = new int[names.Length];

            for (int i = 0; i < names.Length; i++)
            {
                names[i]  = grid.tileSet.prefaps[i] != null ? grid.tileSet.prefaps[i].name : "";
                values[i] = i;
            }
            var index = EditorGUILayout.IntPopup("Select Tile", oldindex, names, values);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "Grid Changed");
                if (oldindex != index)//리스트에서 선택된 프리팹이 이전과 다르다면 바꾸기
                {
                    oldindex        = index;
                    grid.tileprefab = grid.tileSet.prefaps[index];

                    float width  = grid.tileprefab.GetComponent <Renderer>().bounds.size.x;
                    float height = grid.tileprefab.GetComponent <Renderer>().bounds.size.y;

                    grid.widht  = width;
                    grid.height = height;
                }
            }
            //선택된 타일 프리뷰
            GUILayout.BeginHorizontal();
            GUILayout.Label("Preview");
            Texture2D myTexture = AssetPreview.GetAssetPreview((Object)grid.tileprefab.gameObject);
            GUILayout.Label(myTexture);
            GUILayout.EndHorizontal();
        }
    }