Пример #1
0
    private void DrawPresetColors()
    {
        selectedPreset = EditorGUILayout.ObjectField("Selected preset", selectedPreset, typeof(ColorSwapPreset), false) as ColorSwapPreset;

        if (selectedPreset != null)
        {
            Rect originalColorRect = GUILayoutUtility.GetLastRect();
            originalColorRect.width = 40;

            Color guiColor = GUI.color;

            for (int i = 0; i < selectedPreset.colorVariants.Length; i++)
            {
                EditorGUILayout.BeginHorizontal();
                GUI.color            = targetScript.sourceColors [i];
                originalColorRect.y += 18;
                GUI.DrawTexture(originalColorRect, EditorGUIUtility.whiteTexture);

                GUILayout.Space(50);
                EditorGUILayout.LabelField(i.ToString(), GUILayout.Width(30));

                selectedPreset.colorVariants [i] = EditorGUILayout.ColorField(selectedPreset.colorVariants [i]);
                EditorGUILayout.EndHorizontal();
            }

            GUI.color = guiColor;

            targetScript.UpdateMaterial(selectedPreset);
            SceneView.RepaintAll();
        }
    }
Пример #2
0
    private void CreateNewPreset()
    {
        string targetScriptPath = AssetDatabase.GetAssetPath(target);

        targetScriptPath = targetScriptPath.Remove(targetScriptPath.Length - targetScript.name.Length - 7);
        string folderPath   = targetScriptPath + "/presets";
        bool   folderExists = AssetDatabase.IsValidFolder(folderPath);

        if (!folderExists)
        {
            AssetDatabase.CreateFolder(targetScriptPath, "presets");
        }

        string presetPath = folderPath + "/" + newPresetName + ".asset";

        ColorSwapPreset newPreset = ScriptableObject.CreateInstance <ColorSwapPreset> ();

        AssetDatabase.CreateAsset(newPreset, presetPath);
        newPreset.Initialize(targetScript, targetScript.presetMaterial, targetScript.sourceColors);

        targetScript.AddPreset(newPreset);
    }
Пример #3
0
 public void UpdateMaterial(ColorSwapPreset preset)
 {
     presetMaterial.SetInt("_Range", preset.colorVariants.Length);
     presetMaterial.SetColorArray("_ColorMatrix", preset.colorVariants);
 }
Пример #4
0
 public void AddPreset(ColorSwapPreset preset)
 {
     colorPresets.Add(preset);
     currentPreset = preset;
 }
Пример #5
0
 public void UpdateVisualData(ColorSwapPreset newPreset)
 {
     colorSwapPreset = newPreset;
     UpdateVisualData();
 }