Before updating to Windows 10 you may need to return your Pro license. More information here

Not updating when script value is changed by an editor script

I have an editor script that generates text based on a prefab created with SpriteText. My script successfully builds the instances of the SpriteText, but the objects are not updating for the new text string assigned programmatically.

// Executed within OnInspectorGUI var clone : GameObject = EditorUtility.InstantiatePrefab(target.WordPrefab); clone.name = ""+index+"_"+p; clone.transform.parent = words.transform;

var spriteText : SpriteText = clone.GetComponentInChildren(typeof(SpriteText)); spriteText.text = p; // assigning new text string

// trying to force an update EditorUtility.SetDirty(spriteText); EditorUtility.SetDirty(clone); spriteText.UpdateMesh();

When this code is executed, I get the new prefab instances, but they all appear with the default prefab text, despite that when I look at the inspector for each item they have been assigned the new text correctly. If I manually change the text, it then will finally update, but I can't seem to trigger an update from my editor script. The calls to UpdateMesh() and SendMessage() are simply my feeble attempts, but no luck.

Any ideas to force the script/object to update?

more ▼

asked Nov 01, 2010 at 07:40 PM

avatar image

Steven Walker
1.4k 80 72 142

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Are you applying [ExecuteInEditMode] on the SpriteText GameObject?

more ▼

answered Feb 11, 2011 at 05:59 PM

avatar image

41 4 3 11

I didn't make any changes to the any of the the SpriteText code.

Feb 12, 2011 at 04:37 PM Steven Walker
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Nov 01, 2010 at 07:40 PM

Seen: 2885 times

Last Updated: Nov 01, 2010 at 07:40 PM