Just getting into Editor Scripting!
I need to mass update a set of textmesh fonts,
eg;
var newFont : Font;
GetComponent(TextMesh).font = newFont;
but how do I specify newFont in the editor script?
also I need to figure out how to set the Material for that font.
Thanks alot for your help in advance.
Look at the class scriptableWizard and the example in the docs. This is what you need.
Thanks spree, legend!
Heres what I learned in case it helps someone else, save it into Assets/Editor/WizardChangeFont.cs then find it under the GameObject Menu.
using UnityEngine;
using UnityEditor;
class WizardChangeFont : ScriptableWizard {
public Font daFont;
public Material daMaterial;
[MenuItem ("GameObject/Change Font")]
static void CreateWizard () {
ScriptableWizard.DisplayWizard<WizardChangeFont>("Change Font","Apply");
}
void OnWizardCreate () {
foreach (Object obj in Selection.objects) {
if (obj is GameObject) {
// Check which component you want to work on (in this case: Transform)
TextMesh objectio = ((GameObject)obj).GetComponent<TextMesh>();
if (objectio != null) {
// do whatever you like to do ;-)
objectio.font = daFont;
}
// Check which component you want to work on (in this case: Transform)
Renderer objectrio = ((GameObject)obj).GetComponent<Renderer>();
if (objectrio != null) {
objectrio.material = daMaterial;
}
}
}
}
void OnWizardUpdate () {
helpString = "Please set the font!";
}
}