Esempio n. 1
0
        public static System.Drawing.Color GetColor(PaletteEnum palette, int index)
        {
            System.Drawing.Color c = System.Drawing.Color.Black;
            switch (palette)
            {
            case PaletteEnum.EarthTones:
                c = _earthToneColors[index % _earthToneColors.Length];
                break;

            case PaletteEnum.Excel:
                c = _excelColors[_excelChartLineColors[index % 8]];
                break;

            case PaletteEnum.GrayScale:
                c = System.Drawing.Color.FromArgb(0xFF, (index % 15) + 1, (index % 15) + 1, (index % 15) + 1);
                break;

            case PaletteEnum.Light:
                c = _lightColors[index % _lightColors.Length];
                break;

            case PaletteEnum.Pastel:
                c = _pastelColors[index % _pastelColors.Length];
                break;

            case PaletteEnum.SemiTransparent:
                c = _defaultColors[index % _defaultColors.Length];
                c = System.Drawing.Color.FromArgb(0x7F, c.R, c.G, c.B);
                break;

            default:
                c = _defaultColors[index % _defaultColors.Length];
                break;
            }
            return(c);
        }
    public override void OnInspectorGUI()
    {
        //base.OnInspectorGUI();

        EditorGUI.BeginChangeCheck();
        grid.spriteWidth  = CreateSlider("Width:", grid.spriteWidth);
        grid.spriteHeight = CreateSlider("Height:", grid.spriteHeight);
        Color newColor = EditorGUILayout.ColorField("Color:", grid.color);

        if (EditorGUI.EndChangeCheck())
        {
            grid.color = newColor;
        }

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

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

        // Tile Palette Index
        //paletteIndex = EditorGUILayout.IntField("Palette Index", paletteIndex);
        tilePalette = (PaletteEnum)EditorGUILayout.EnumPopup("Palette:", tilePalette);



        // Tile Map
        EditorGUI.BeginChangeCheck();
        TileSet 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();
            string[] names  = new string[grid.tileSet.prefabs.Length];
            int[]    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 : "";
                values[i] = i;
            }

            int 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.spriteWidth = width;
                    //grid.spriteHeight = height;
                }
            }
        }
    }