Actually, unless you have a specific reason to do otherwise, iTween provides an excellent, easy to use hashtable “builder” utility.
A common syntax in iTween is:
iTween.ValueTo( gameObject, iTween.Hash(
"from" , 15,
"to" , 5,
"time" , 2,
"onUpdate", "UpdateSize",
"easeType", iTween.EaseType.easeOutSine
));
iTween’s Hash()
method will create the hashtable for you, all you need to do is make sure it has an even number of arguments, like in the above example: key, value, key, value, …
Also note that ValueTo()
, unlike most of iTween’s methods requires you to use “onUpdate” - so you must have a method called UpdateSize
if you follow the above example. This method should accept the same type as the “from” and “to” arguements, and you are supposed to take the actual tween step (i.e. use the value as is appropriate for your game), like this:
void UpdateSize( float size ) {
// Will be called each frame by iTween
// This is where you apply the size
...
}
Finally, in case you want to specifically use your own hashtable without iTween.Hash()
, all you need is to correct your hashtable code to something like this (not tested, but I believe it should work):
Hashtable hashtable = new Hashtable();
hashtable.Add("from", 15);
hashtable.Add("to", 5);
hashtable.Add("onUpdate", "UpdateSize");
iTween.ValueTo( gameObject, hashtable );
Although you asked specifically about the hashtable, the rest of your code also contains errors I believe (unless I missed some iTween overload). iTween wants a GameObject as a first parameter. So your recommended use would be to attach the script to a game object (say, your camera) and simply supply the variable gameObject
to it, or, if you want to supply a different object, then probably something like Camera.main.gameObject
should be your first iTween parameter.
Just thought I’d mention this as well.