public static Component AddComponent(GameObject go, string sourceInfo, string name) { Debug.LogWarningFormat("Performing a potentially slow search for component {0}.", (object)name); System.Type componentType = APIUpdaterRuntimeServices.ResolveType(name, Assembly.GetCallingAssembly(), sourceInfo); if (componentType == null) { return((Component)null); } return(go.AddComponent(componentType)); }
public static Component AddComponent(GameObject go, string sourceInfo, string name) { Debug.LogWarningFormat("Performing a potentially slow search for component {0}.", new object[] { name }); Type type = APIUpdaterRuntimeServices.ResolveType(name, Assembly.GetCallingAssembly(), sourceInfo); return((type != null) ? go.AddComponent(type) : null); }
static int _CreateUnityEngineInternal_APIUpdaterRuntimeServices(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 0) { UnityEngineInternal.APIUpdaterRuntimeServices obj = new UnityEngineInternal.APIUpdaterRuntimeServices(); LuaScriptMgr.PushObject(L, obj); return 1; } else { LuaDLL.luaL_error(L, "invalid arguments to method: UnityEngineInternal.APIUpdaterRuntimeServices.New"); } return 0; }
private static Type ResolveType(string name, Assembly callingAssembly, string sourceInfo) { Type type = APIUpdaterRuntimeServices.ComponentsFromUnityEngine.FirstOrDefault((Type t) => (t.Name == name || t.FullName == name) && !APIUpdaterRuntimeServices.IsMarkedAsObsolete(t)); if (type != null) { Debug.LogWarningFormat("[{1}] Type '{0}' found in UnityEngine, consider replacing with go.AddComponent<{0}>();", new object[] { name, sourceInfo }); return(type); } Type type2 = callingAssembly.GetType(name); if (type2 != null) { Debug.LogWarningFormat("[{1}] Component type '{0}' found on caller assembly. Consider replacing the call method call with: AddComponent<{0}>()", new object[] { type2.FullName, sourceInfo }); return(type2); } type2 = AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly a) => a.GetTypes()).SingleOrDefault((Type t) => t.Name == name && typeof(Component).IsAssignableFrom(t)); if (type2 != null) { Debug.LogWarningFormat("[{2}] Component type '{0}' found on assembly {1}. Consider replacing the call method with: AddComponent<{0}>()", new object[] { type2.FullName, type2.Assembly.Location, sourceInfo }); return(type2); } Debug.LogErrorFormat("[{1}] Component Type '{0}' not found.", new object[] { name, sourceInfo }); return(null); }