Пример #1
0
        public static ColormapPreset LoadColormapPreset(string presetName)
        {
            string         filepath = PRESETS_DIRECTORY_PATH + presetName;
            ColormapPreset preset   = (ColormapPreset)AssetDatabase.LoadAssetAtPath(filepath, typeof(ColormapPreset));

            return(preset);
        }
Пример #2
0
        void PresetMenuCallback(object obj)
        {
            string         presetName = obj as string;
            ColormapPreset preset     = FileUtils.LoadColormapPreset(presetName);

            //Debug.Log("preset: " + preset);
            _target.ApplyPreset(preset);
            dirty.forceDirty = true;
        }
Пример #3
0
        public void ApplyPreset(ColormapPreset preset)
        {
            if (preset != null)
            {
                numberOfColors = preset.palette.Length;

                for (int i = 0; i < 256; ++i)
                {
                    usedColors[i] = i < numberOfColors;
                }

                System.Array.Copy(preset.palette, palette, preset.palette.Length);
            }
        }
Пример #4
0
        static void CreateNewColormap()
        {
            string path = EditorUtility.SaveFilePanelInProject(MENU_ITEM_NAME, "New Colormap", "asset", MENU_ITEM_NAME);

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            Colormap       colormap = CreateInstance <Colormap>();
            ColormapPreset preset   = FileUtils.LoadColormapPreset("Classics/Breadbox 1982.asset");

            colormap.ApplyPreset(preset);

            AssetDatabase.CreateAsset(colormap, path);
            AssetDatabase.SaveAssets();
        }
Пример #5
0
        static void CreateNewColormap()
        {
            string path = EditorUtility.SaveFilePanel(MENU_ITEM_NAME, "Assets/", "New Colormap.asset", "asset");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            path = FileUtil.GetProjectRelativePath(path);

            Colormap colormap = CreateInstance <Colormap>();

            ColormapPreset preset = FileUtils.LoadColormapPreset("Classic6.asset");

            //Debug.Log("preset: " + preset);
            colormap.ApplyPreset(preset);

            AssetDatabase.CreateAsset(colormap, path);
            AssetDatabase.SaveAssets();
        }
Пример #6
0
        void SaveAsPreset()
        {
            string folderPath = Application.dataPath + "/Retro Pixel Pro/Colormap Presets/Custom";
            string path       = EditorUtility.SaveFilePanel("Save Colormap Preset", folderPath, "New Colormap Preset", "asset");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            int numUsedColor = 0;

            for (int i = 0; i < _target.usedColors.Length; ++i)
            {
                if (_target.usedColors[i])
                {
                    ++numUsedColor;
                }
            }

            ColormapPreset preset = CreateInstance <ColormapPreset>();

            preset.SetNumColors(numUsedColor);


            int j = 0;

            for (int i = 0; i < _target.numberOfColors; ++i)
            {
                if (_target.usedColors[i])
                {
                    preset.palette[j] = _target.palette[i];
                    ++j;
                }
            }

            AssetDatabase.CreateAsset(preset, path);
            AssetDatabase.SaveAssets();
        }
Пример #7
0
 void OnEnable()
 {
     _target = target as ColormapPreset;
 }