I have been able to do this successfully with Unityscript by declaring
var instanceName : ScriptName;
and then by using instanceName.variable
but I haven’t had any luck in trying to accomplish the same thing in C#.
Any one able to help me with this?
Thanks
Thanks :) always forget about that. Now I have this error: <pre> An object reference is required to access non-static member </pre> in my update call I'm trying to set a variable <pre> string result = SearchField.stringToEdit; </pre> where SearchField.stringToEdit calls a string from the SearchField class.
– gilgadaHave you declared and assigned the SearchField variable?
– farooqaaanever mind, the problem was I was calling the function of SearchField using SearchField.property rather than using the instance name of search.property Thanks guys :)
– gilgadaalso worth noting is that when the stringToEdit is changed, the inspector still shows result as being blank.
– gilgadaYour "search" variable is a private variable, do you assign any reference to this variable? i guess not(if that's the whole script). You should either make it public and drag & drop the correct script instance onto the variable, or use GameObject.Find and GetComponent to get the desired script-instance via code.
– Bunny83