public static void CreateColorPalette()
    {
        var activeObject = Selection.activeObject as Texture2D;

        if (activeObject != null)
        {
            var selectedTexture = activeObject;
            var selectedPath    = AssetDatabase.GetAssetPath(selectedTexture);
            selectedPath = selectedPath.Replace(".png", "-ColorPalette.asset");

            var newPalette = CustomAssetUtil.CreateAsset <ColorPalette>(selectedPath);
            newPalette.Source = selectedTexture;
            newPalette.ResetPalette();

            Debug.Log("Creating a Color Palette " + selectedPath);
        }
        else
        {
            Debug.Log("Can't create a Color Palette");
        }
    }
    public static void CreateCollorPalette()
    {
        if (Selection.activeObject is Texture2D)
        {
            Texture2D selectedTexture = Selection.activeObject as Texture2D;
            string    selectionPath   = AssetDatabase.GetAssetPath(selectedTexture);

            selectionPath = selectionPath.Replace(".png", "-color-palette.asset");

            ColorPalette newPalette = CustomAssetUtil.CreateAsset <ColorPalette>(selectionPath);

            newPalette.source = selectedTexture;
            newPalette.ResetPalette();

            Debug.Log("Created a Palette " + selectionPath);
        }
        else
        {
            Debug.Log("Failed to create a Color Palette");
        }
    }
Exemple #3
0
    public static void CreateColorPalette()
    {
        if (Selection.activeObject is Texture2D)
        {
            var selectedTexture = Selection.activeObject as Texture2D;
            var selectionPath   = AssetDatabase.GetAssetPath(selectedTexture);

            selectionPath = selectionPath.Replace(".png", "-color-palette.asset");

            var newPalette = CustomAssetUtil.CreateAsset <ColorPalette>(selectionPath);

            //pass a reference to the selected texture to the source of
            //the new palette that gets created
            newPalette.source = selectedTexture;
            newPalette.ResetPalette();
            Debug.Log("Creating a Palette");
        }
        else
        {
            Debug.Log("Can't create a Palette. Select a Texture2D");
        }
    }