Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Unity C# Script to change all the ColorPalettes in a scene. (Is only working with the ColorPalettes u3d.as/bFr extension)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MrWhaleGames.ColorPalette
{
[ExecuteInEditMode]
public class ScenePaletteSwitcher : MonoBehaviour
{
public PaletteData PaletteData;
public void SwitchAllPalettes()
{
Palette[] paletteObjs = GameObject.FindObjectsOfType<Palette> ();
if (paletteObjs != null) {
foreach (var item in paletteObjs) {
item.Data = this.PaletteData;
#if UNITY_EDITOR
// is need to mark the object as changed
UnityEditor.EditorUtility.SetDirty (item);
#endif
}
}
PaletteImporter[] paletteImporterObjs = GameObject.FindObjectsOfType<PaletteImporter> ();
if (paletteImporterObjs != null) {
foreach (var item in paletteImporterObjs) {
item.Data = this.PaletteData;
#if UNITY_EDITOR
// is need to mark the object as changed
UnityEditor.EditorUtility.SetDirty (item);
#endif
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.