Created
February 16, 2017 09:17
-
-
Save DomDomHaas/518d60d388bc593b2ffa5975abb9172b to your computer and use it in GitHub Desktop.
Unity C# Script to change all the ColorPalettes in a scene. (Is only working with the ColorPalettes u3d.as/bFr extension)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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