Hello!
How can I modify a variable from an editor script at editor time?
Example: I have a variable "Foo" of type number, and a Editor script that needs to set this variable to a certain number at editor time.
Thanks!
How to modifiy variable from editor script (not runtime)
How to modifiy variable from editor script (not runtime)
Currently working on ->Squeakross: Home Squeak Home<- Using Dialogue System Save System and other features.
Previous game made with Dialogue system ->The Spirit and The mouse<-
Previous game made with Dialogue system ->The Spirit and The mouse<-
Re: How to modifiy variable from editor script (not runtime)
Hi,
At runtime, the dialogue database variables are copied to Lua variables, so you'd use DialogueLua.SetVariable().
At editor time, on the other hand, they're still just dialogue database variables. There is no Lua environment at editor time. You need a reference to your dialogue database. If you don't have one, EditorTools.FindInitialDatabase() will return the database that's assigned to the open scene's Dialogue Manager:
Then you can call DialogueDatabase.GetVariable() to get the variable and set its value:
At runtime, the dialogue database variables are copied to Lua variables, so you'd use DialogueLua.SetVariable().
At editor time, on the other hand, they're still just dialogue database variables. There is no Lua environment at editor time. You need a reference to your dialogue database. If you don't have one, EditorTools.FindInitialDatabase() will return the database that's assigned to the open scene's Dialogue Manager:
Code: Select all
DialogueDatabase db = PixelCrushers.DialogueSystem.EditorTools.FindInitialDatabase();
Code: Select all
PixelCrushers.DialogueSystem.Variable variable = db.GetVariable("Foo");
variable.InitialFloatValue = 42;
Re: How to modifiy variable from editor script (not runtime)
perfect, thanks! That's exactly what I was looking for
Currently working on ->Squeakross: Home Squeak Home<- Using Dialogue System Save System and other features.
Previous game made with Dialogue system ->The Spirit and The mouse<-
Previous game made with Dialogue system ->The Spirit and The mouse<-