Пример #1
0
 public static UnityEngine.Object CreateInstance(Type type)
 {
     ObjectFactory.CheckTypeValidity(type);
     if (type == typeof(GameObject))
     {
         throw new ArgumentException("GameObject type must be created using ObjectFactory.CreateGameObject instead : " + type.FullName);
     }
     if (type.IsSubclassOf(typeof(Component)))
     {
         throw new ArgumentException("Component type must be created using ObjectFactory.AddComponent instead : " + type.FullName);
     }
     if (type.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, Type.EmptyTypes, null) != null)
     {
         throw new ArgumentException(type.FullName + " constructor is not accessible which prevent this type from being used in ObjectFactory.");
     }
     return(ObjectFactory.CreateDefaultInstance(type));
 }