示例#1
0
 static void InjectGameObjectReferences()
 {
     MultipleObjectClassifier += (attr, field, monoHolder) =>
     {
         if (attr.ComponentAddress != GetComponentFrom.TargetGameObject)
         {
             return;
         }
         GameObject targetObj = GameObject.Find(attr.TargetName);
         field.SetValue(monoHolder.t, targetObj.GetComponent(field.GetValue(monoHolder.t).GetType()));
     };
     Inject();
 }
示例#2
0
    static void InjectScriptReferences()
    {
        SingleObjectClassifier += (attr, field, obj) =>
        {
            switch (attr.ComponentAddress)
            {
            case GetComponentFrom.Self:
                field.SetValue(obj, obj.GetComponent(field.FieldType));
                break;

            case GetComponentFrom.SceneObject:
                field.SetValue(obj, MonoBehaviour.FindObjectOfType(field.FieldType));
                break;
            }
        };
        Inject();
    }