public override async ETTask Run(EventType.AfterUnitCreate args) { // Unit View层 ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); GameObject prefab = bundleGameObject.Get <GameObject>("Skeleton"); GameObject go = UnityEngine.Object.Instantiate(prefab); args.Unit.AddComponent <AnimatorComponent>(); }
public override void Run(Unit unit) { // Unit View层 ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); GameObject prefab = bundleGameObject.Get <GameObject>("Skeleton"); GameObject go = UnityEngine.Object.Instantiate(prefab); unit.AddComponent <AnimatorComponent>(); }
public override async ETTask <UI> OnCreate(UIComponent uiComponent) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); await resourcesComponent.LoadBundleAsync(UIType.UILogin.StringToAB()); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UIType.UILogin.StringToAB(), UIType.UILogin); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); UI ui = EntityFactory.Create <UI, string, GameObject>(uiComponent.Domain, UIType.UILogin, gameObject); ui.AddComponent <UILoginComponent>(); return(ui); }
protected override async ETTask Run(EventType.AfterUnitCreate args) { // Unit View层 ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); GameObject prefab = bundleGameObject.Get <GameObject>("Skeleton"); GameObject go = UnityEngine.Object.Instantiate(prefab); GameObject.DontDestroyOnLoad(go); args.Unit.GameObject = go; args.Unit.AddComponent <AnimatorComponent>(); await ETTask.CompletedTask; }
public static UI Create() { try { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle(UIType.UILobby.StringToAB()); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UIType.UILobby.StringToAB(), UIType.UILobby); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); UI ui = EntityFactory.Create <UI, string, GameObject>(Game.Scene, UIType.UILobby, gameObject); ui.AddComponent <UILobbyComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public static Unit Create(Entity domain, UnitInfo unitInfo) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); GameObject prefab = bundleGameObject.Get <GameObject>("Skeleton"); GameObject go = UnityEngine.Object.Instantiate(prefab); Unit unit = EntityFactory.CreateWithId <Unit, GameObject>(domain, unitInfo.UnitId, go); unit.Position = new Vector3(unitInfo.X, unitInfo.Y, unitInfo.Z); unit.AddComponent <MoveComponent>(); unit.AddComponent <TurnComponent>(); unit.AddComponent <UnitPathComponent>(); unit.AddComponent <AnimatorComponent>(); UnitComponent unitComponent = Game.Scene.GetComponent <UnitComponent>(); unitComponent.Add(unit); return(unit); }