/// <summary> /// Spawns a new entity /// </summary> /// <param name="entityName"> </param> /// <param name="className"> </param> /// <param name="pos"> </param> /// <param name="rot"> </param> /// <param name="scale"> </param> /// <param name="autoInit"> </param> /// <param name="flags"> </param> /// <returns> </returns> public static EntityBase Spawn(string entityName, string className = "Default", Vector3?pos = null, Quaternion?rot = null, Vector3?scale = null, bool autoInit = true, EntityFlags flags = EntityFlags.CastShadow, params object[] args) { EntityInitializationParams info; var ent = EntityInterop.SpawnEntity( new EntitySpawnParams { Name = entityName, Class = className, Position = pos ?? new Vector3(1, 1, 1), Rotation = rot ?? Quaternion.Identity, Scale = scale ?? new Vector3(1, 1, 1), Flags = flags }, autoInit, out info) as Entity; if (ent != null) { ent.OnPostSpawn(args); return(ent); } if (info.Id != 0) { return(CreateNativeEntity(info.Id, info.IEntityPtr) as Entity); } Debug.LogAlways("[Entity.Spawn] Failed to spawn entity of class {0} with name {1}", className, entityName); return(null); }