コード例 #1
0
 private static object findObj(object o, FieldInfo f, InjectAttribute ia)
 {
     if (ia.type == InjectAttribute.Type.global)
     {
         return(BeansRepo.bean(f.FieldType, ia.name));
     }
     else
     {
         if (!(o is MonoBehaviour))
         {
             throw new System.Exception("this not MonoBehaviour=" + o + " f=" + f);
         }
         MonoBehaviour mo = (MonoBehaviour)o;
         if (ia.type == InjectAttribute.Type.getcomponent)
         {
             return(mo.GetComponent(f.FieldType));
         }
         if (ia.type == InjectAttribute.Type.getcomponentinchildren)
         {
             return(mo.GetComponentInChildren(f.FieldType));
         }
         if (ia.type == InjectAttribute.Type.getComponentInParent)
         {
             return(mo.GetComponentInParent(f.FieldType));
         }
         throw new System.Exception("this not Support this type=" + ia.type);
     }
 }