Page 1 of 1

Room Variables not Working - Please Help

Posted: 05 Oct 2009, 10:44
by kaligus
Hello all,

please, I'm having a new issue... this one is related to room variables.
I made my login with a custom script. Then made a lobby room, etc.
When the user creates a new room (game room), it creates 2 variables. I checked into Admin Tool of SFS and the variables are all there, so, creating variables works.

But when I try to get the variables I got this error:

Code: Select all

InvalidCastException: Cannot cast from source type to destination type.
csFase_Core.OnGUI ()   (at Assets\Game\Scripts Gerais\Fases\csFase_Core.cs:207)
UnityEditor.EditorGUIUtility:RenderGameViewCameras(Rect, Rect, Boolean, Boolean)
UnityEditor.EditorGUIUtility:RenderGameViewCameras(Rect, Rect, Boolean, Boolean)
UnityEditor.GameView:OnGUI() (at C:\builds\unity-branches-2.5.x\unity-2.5.x\Editor\Mono\GameView\GameView.cs:192)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[])
System.Reflection.MonoMethod:InternalInvoke(Object, Object[])
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
UnityEditor.HostView:Invoke(String) (at C:\builds\unity-branches-2.5.x\unity-2.5.x\Editor\Mono\GUI\DockArea.cs:156)
UnityEditor.MaximizedHostView:OnGUI() (at C:\builds\unity-branches-2.5.x\unity-2.5.x\Editor\Mono\GUI\DockArea.cs:872)


The code where the errors occurs:

Code: Select all

Hashtable vars = room.GetVariables();
foreach (string v in vars.Values) {
   Debug.Log("Name: " + v + " Value: " + room.GetVariable(v));
}


The script above is the same from the documents...
What am I doing wrong? :cry:

Please help

Posted: 06 Oct 2009, 13:37
by kaligus
Please, anyone?

Posted: 06 Oct 2009, 17:31
by ThomasLund
A guess - is that the variable is of a type that cannot be cast to string without explicitly casting it.

Try to print the type of the variable key only and see if that gives a clue

/Thomas

Posted: 06 Oct 2009, 19:06
by kaligus
I tried to put into the Debug from Unity... but it returns me another error... can you give me an example, please, Thomas?

EDIT: the variables are numeric... do I need to convert to string? If yes, how can I convert? But even numeric numbers works in Debug Logs, like Debug.Log ("Test: " + someNumericINteger);

Posted: 06 Oct 2009, 20:33
by ThomasLund
If they are integers then try int.Parse(*string here*) - floats can do float.Parse() instead, but you might also have to set the Culture so that , and . as delimiters will be set correctly

/Thomas

Posted: 07 Oct 2009, 10:32
by kaligus
Hello Thomas, thanks for the reply.

I tried a lot of ways here :lol: and still same error... I also tried to use a string into the room variable, it creates good, but it returns me the same error...
Sorry, what do you mean "set culture"?

Do you think could be a bug? Can you make some tests on your own in there, please?

I just dont understand why this does not work.

Posted: 14 Oct 2009, 00:55
by kaligus
Hello again,

sorry keep bothering you guys with this, but it is getting anoying :lol:
I cant figure out what is the error...

Maybe a bug?

Posted: 26 Oct 2009, 16:12
by kaligus
Ok, no answers so far... this "feature" is a "must in" in my game and it does not work (so far I think its a bug, no one asnwered me again), I cant buy SFS and I cant use the API with Unity because of this! Is Unity API supported by SFS Team? So far I know Thomas was the guy who created this (wonderful job) and he is not inside SFS team...

I'm now considering trying other backend, because this does not work.

Anyone tried this? I made a simple test, with examples from docs, tried diferent sintaxes and nothing... it just does not work!

Posted: 21 Nov 2009, 13:39
by ThomasLund
Working on this one, and wanted to buzz you back that it seems like a genuine bug!

Last one on my list for stuff to fix, so expect new API version very soon

/Thomas

Posted: 21 Nov 2009, 14:12
by kaligus
Thank you, Thomas.
I'm still using SFS with Unity, but making only the IA and NPC stuff now.