hey i would like to know how get get component from a string
eg
public String ItemScriptName;
void Update ()
{
gameObject.GetComponent(ItemScriptName)().DoSomething();
}
i want to be able to set what the item script name is so i can make multiple objects with different scripts.
if that makes any sense
any help would be GREAT
PS is doesnt have to be a string just some way of declaring what component to get
Thanks Scott 
sooncat
2
two ways to do this:
using UnityEngine;
using System.Collections;
public class ScriptA : MonoBehaviour {
void ShowMessage(string m)
{
Debug.Log("A message = " + m);
}
}
using UnityEngine;
using System.Collections;
using System.Reflection;
public class ScriptB : MonoBehaviour {
void ShowMessage(string m)
{
Debug.Log("B message = " + m);
}
string destClassName = "ScriptA";
string destMethodName = "ShowMessage";
string destShowMessage = "123";
void OnGUI()
{
//firstWay
if(GUI.Button(new Rect(100,100,100,100), "firstWay"))
{
SendMessage(destMethodName, destShowMessage);
}
//secondWay
if(GUI.Button(new Rect(100,200,100,100), "SecondWay"))
{
Component c = gameObject.GetComponent(destClassName);
System.Type t = System.Type.GetType(destClassName);
MethodInfo mInfo = t.GetMethod(destMethodName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod);
mInfo.Invoke(c, new object[] { destShowMessage });
}
}
}