public UI Create(Scene scene, string type, GameObject parent) { try { Debug.Log("UIRoom_Factory"); ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); AltasComponent altasComponent = Game.Scene.GetComponent <AltasComponent>(); resourcesComponent.LoadBundle($"{ type}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); GameObject obj = UnityEngine.Object.Instantiate(bundleGameObject); UI ui = ComponentFactory.Create <UI, GameObject>(obj); ui.AddUiComponent <UIRoom_Component>(); //加载扑克图集 resourcesComponent.LoadBundle($"{AltasType.PukeAltas}.unity3d"); GameObject AltasGameObject = (GameObject)resourcesComponent.GetAsset($"{AltasType.PukeAltas}.unity3d", $"{AltasType.PukeAltas}"); GameObject Altas = UnityEngine.Object.Instantiate(AltasGameObject, altasComponent.ParentAltas.transform); altasComponent.AddAltas(AltasType.PukeAltas, Altas); //加载字体图集 resourcesComponent.LoadBundle($"{AltasType.FontAltas}.unity3d"); GameObject FontAltasGameObject = (GameObject)resourcesComponent.GetAsset($"{AltasType.FontAltas}.unity3d", $"{AltasType.FontAltas}"); GameObject FontAltas = UnityEngine.Object.Instantiate(FontAltasGameObject, altasComponent.ParentAltas.transform); altasComponent.AddAltas(AltasType.FontAltas, FontAltas); return(ui); } catch (Exception e) { Debug.LogError(e.Message); return(null); } }
/// <summary> /// 结算显示手牌 /// </summary> public void ShowCards(int[] cards) { for (int i = 0; i < this.cards.Length; i++) { Sprite sprite = (Sprite)res.GetAsset(UICowCowAB.CowCow_Texture, CardHelper.GetCardAssetName(cards[i])); this.cards[i].sprite = sprite; } this.ShowHideHandCard(true); }
private void OnMusicSwitch() { if (musicSlider.value > 0) { // 当slider值改变时,会触发事件onValueChanged musicSlider.value = 0; musicBtn.GetComponent <Image>().sprite = (Sprite)res.GetAsset(UICowCowAB.CowCow_Texture, "set_btn_voice_off"); } else { musicSlider.value = 1; musicBtn.GetComponent <Image>().sprite = (Sprite)res.GetAsset(UICowCowAB.CowCow_Texture, "set_btn_voice_on"); } }
/// <summary> /// 创建预制体 /// </summary> public static GameObject Create(string abName) { ResourcesComponent rc = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); GameObject ab = (GameObject)rc.GetAsset(UICowCowAB.CowCow_Prefabs, abName); return(UnityEngine.Object.Instantiate(ab)); }
public void OpenPanelAsync(UIEnum panel, Action openFinish = null, object param = null) { PanelType panelType = uiTypes[panel]; string prefab = panelType.uiPrefab; if (this.uis.ContainsKey(prefab)) { return; } ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle(prefab.StringToAB()); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(prefab.StringToAB(), prefab); resourcesComponent.UnloadBundle(prefab.StringToAB()); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); UI ui = ComponentFactory.Create <UI, string, GameObject>(prefab, gameObject, false); UIBase uibase = (UIBase)ui.AddComponent(panelType.panelType); uibase.OnInit(param); this.uis.Add(ui.Name, ui); ui.GameObject.transform.SetParent(this.Root.transform, false); uibase.OnShow(param); //Add(ui); if (openFinish != null) { openFinish(); } }
/// <summary> /// 通过item的类型获得不同的bundle包 /// </summary> /// <param name="itemType"></param> /// <returns></returns> private GameObject GetItemBundleByType(string itemType) { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{itemType}.unity3d"); return((GameObject)resourcesComponent.GetAsset($"{itemType}.unity3d", $"{itemType}")); }
public HotfixTestObj() { ResourcesComponent resourcesComponent = ICE.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle("Cube".StringToAB().BundleNameToLower()); GameObject prefab = resourcesComponent.GetAsset("Cube".StringToAB().BundleNameToLower(), "Cube") as GameObject; GameObject cube1 = GameObject.Instantiate(prefab); cube1.name = "111"; GameObject = cube1; //moveComponent = ComponentFactory.Create<MoveComponent, GameObject>(GameObject); //moveComponent.GameObject.transform.SetParent(GameObject.transform, false); //rotationComponent = ComponentFactory.Create<RotationComponent, GameObject>(GameObject); //rotationComponent.GameObject.transform.SetParent(GameObject.transform, false); //scaleComponent = ComponentFactory.Create<ScaleComponent, GameObject>(GameObject); //scaleComponent.GameObject.transform.SetParent(GameObject.transform, false); var actor1 = Helper.AddHActor(cube1); Helper.AddHComponent <CubeComponent>(actor1); Helper.AddHComponent <CubeComponent2>(actor1); GameObject cube2 = GameObject.Instantiate(prefab); cube2.name = "222"; var actor2 = Helper.AddHActor(cube2); Helper.AddHComponent <CubeComponent2>(actor2); //resourcesComponent.UnLoadBundle("Cube".StringToAB().BundleNameToLower()); }
public static T Load <T>(string assetName) where T : class { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle(assetName.StringToAB()); return(resourcesComponent.GetAsset(assetName.StringToAB(), assetName) as T); }
Unit CreateMap(ResourcesComponent resourcesComponent, string abName, UnitComponent unitComponent, int MapSizeX, int MapSizeY) { GameObject bundleGameObjectMapGrid = (GameObject)resourcesComponent.GetAsset(abName.StringToAB(), "MapGrid"); // 添加格子 Unit mapGridUnit = null; MapGridData mapGridData = new MapGridData(); mapGridData.ABName = abName; for (int x = 0; x < MapSizeX; x++) { for (int y = 0; y < MapSizeY; y++) { GameObject gameObjectGrid = UnityEngine.Object.Instantiate(bundleGameObjectMapGrid); gameObjectGrid.name = string.Format("Grid[{0}][{1}]", x, y); // 创建地图格子实体 int id = gameObjectGrid.GetHashCode();// x * 1000 + y; Log.Debug("创建地图格子实体:{0} ", id); mapGridUnit = ETModel.ComponentFactory.CreateWithId <ETModel.Unit, GameObject>( id, gameObjectGrid); // 添加地图格子组件 mapGridData.GridX = x; mapGridData.GridY = y; mapGridData.BgName = "Desert"; MapGridComponent mapGridComponent = ETModel.ComponentFactory.CreateWithParent <MapGridComponent, MapGridData>( mapGridUnit, mapGridData); mapGridUnit.AddComponent(mapGridComponent); // add unitComponent.Add(mapGridUnit); } } return(mapGridUnit); }
public static UI Create() { try { //从模型层的资源组件,然后加载Login的AB包 ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle(UIType.UIMainPanel.StringToAB()); //StringToAB() 变小写加unity3d 如:uilogin.unity3d //拿到预制体 GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UIType.UIMainPanel.StringToAB(), UIType.UIMainPanel); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); //通过组件化工厂创建UI UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UIMainPanel, gameObject, false); //添加UILogin的逻辑组件 ui.AddComponent <UIMainPanelComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public UI Create(Scene scene, string type, GameObject gameObject) { try { Debug.Log("14124"); //获取资源管理组件 ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); //加载对应的Ab资源包并加载 resourcesComponent.LoadBundle($"{type}.unity3d"); //获取对象资源物体 GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); //创建对象UI GameObject lobby = UnityEngine.Object.Instantiate(bundleGameObject); //设定UI层 lobby.layer = LayerMask.NameToLayer(LayerNames.UI); //调用组件工厂创建UI lobby大厅 UI ui = ComponentFactory.Create <UI, GameObject>(lobby); //给该ui挂载UI大厅组件 ui.AddComponent <MyUILobbyComponent>(); //组装完毕返回出去 return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public UI Create(Scene scene, string type, GameObject parent) { try { //加载AB包 ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{type}.unity3d"); //加载大厅界面预设并生成实例 GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); GameObject lobby = UnityEngine.Object.Instantiate(bundleGameObject); //设置UI层级,只有UI摄像机可以渲染 lobby.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(lobby); ui.AddComponent <LandlordsLobbyComponent>(); return(ui); } catch (Exception e) { Log.Error(e.ToStr()); return(null); } }
public void Awake() { UI ui = this.GetEntity <UI>(); ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle("LandlordCreateRoom.unity3d"); GameObject bundleGameObject = resourcesComponent.GetAsset <GameObject>("LandlordCreateRoom.unity3d", "LandlordCreateRoom"); GameObject LandlordCreateRoom = UnityEngine.Object.Instantiate(bundleGameObject); LandlordCreateRoom.layer = LayerMask.NameToLayer(LayerNames.UI); LandlordCreateRoom.transform.SetParent(Hotfix.Scene.GetComponent <UIComponent>().GetCanvas(ui), false); mRc = LandlordCreateRoom.GetComponent <ReferenceCollector>(); Hide(); Button btn_close = mRc.Get <GameObject>("btn_close").GetComponent <Button>(); btn_close.onClick.Add(() => { Hide(); }); Button btn_ok = mRc.Get <GameObject>("btn_ok").GetComponent <Button>(); btn_ok.onClick.Add(() => { SessionComponent.Instance.Session.Send(new C2G_CreateLandlordRoom()); }); }
public void Awake(GameObject parent) { microphone = Game.Scene.GetComponent <MicrophoneComponent>(); res = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); res.LoadBundle(UICowCowAB.CowCow_Prefabs); res.LoadBundle(UICowCowAB.CowCow_Texture); GameObject ab = (GameObject)res.GetAsset(UICowCowAB.CowCow_Prefabs, UICowCowType.CowCowGameSetting); this.GameObject = UnityEngine.Object.Instantiate(ab); this.GameObject.transform.SetParent(parent.transform, false); this.GameObject.name = UICowCowType.CowCowGameSetting; ReferenceCollector rc = this.GameObject.GetComponent <ReferenceCollector>(); uiVoiceSetting = rc.Get <GameObject>("UIVoiceSetting").GetComponent <CanvasGroup>(); musicSlider = rc.Get <GameObject>("MusicSlider").GetComponent <Slider>(); soundSlider = rc.Get <GameObject>("SoundSlider").GetComponent <Slider>(); musicSwitchBtn = rc.Get <GameObject>("MusicSwitchButton").GetComponent <Button>(); soundSwitchBtn = rc.Get <GameObject>("SoundSwitchButton").GetComponent <Button>(); Button helpBtn = rc.Get <GameObject>("HelpBtn").GetComponent <Button>(); Button comfirmBtn = rc.Get <GameObject>("ComfirmBtn").GetComponent <Button>(); uiHelp = rc.Get <GameObject>("UIHelp").GetComponent <CanvasGroup>(); Button hCloseBtn = rc.Get <GameObject>("HCloseBtn").GetComponent <Button>(); musicSlider.onValueChanged.Add(OnMusicSlider); soundSlider.onValueChanged.Add(OnSoundSlider); musicSwitchBtn.onClick.Add(OnMusicSwitch); soundSwitchBtn.onClick.Add(OnSoundSwitch); helpBtn.onClick.Add(OnHelp); comfirmBtn.onClick.Add(OnComfirm); hCloseBtn.onClick.Add(OnHClose); }
public static UI Create() { try { //获取主工程的ResourcesComponent组件 ResourcesComponent resourcesComponent = ETModel.Game.Scene. GetComponent <ResourcesComponent>(); //加载AB resourcesComponent.LoadBundle(UIType.UILogin.StringToAB()); //获取资源 GameObject bundleGameObject = (GameObject)resourcesComponent. GetAsset(UIType.UILogin.StringToAB(), UIType.UILogin); //克隆物体 GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); //创建实体,并且内部调用了Awake方法 UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UILogin, gameObject, false); //给实体增加组件 ui.AddComponent <UILoginComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public static UnityEngine.Object[] GetAll(string asName) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(asName + ".unity3d", "Unit"); UnityEngine.Object[] prefabs = bundleGameObject.GetAll <GameObject>(); return(prefabs); }
static public GameObject getGameObjByBundle(string bundleName) { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{bundleName}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{bundleName}.unity3d", $"{bundleName}"); return(bundleGameObject); }
private async void BeginPlayAni(string key) { if (this == null || this.InstanceId == 0) { Log.Error("此FXComponent 组件已经被销毁,请不要再调用此方法"); return; } if (!this.FXAnis.TryGetValue(key, out FXAnimationData item)) { Log.Error($"播放传入的key:{key} 没有对应的播放数据"); return; } //如果没有,则加载一次 if (item.FXTarget == null) { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(item.AtlasName.StringToAB(), key); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject, item.ParentTarget); gameObject.transform.localPosition = Vector3.zero; GameObject.transform.localScale = Vector3.one; item.FXTarget = gameObject.transform; } await Task.Delay((int)item.Delay * 1000); item.FXTarget.gameObject.SetActive(true); await Task.Delay((int)item.PlayTime * 1000); item.IsPlaying = false; if (item.CacheFX) { item.FXTarget.gameObject.SetActive(false); } else { //如果不缓存,直接删掉 GameObject.Destroy(item.FXTarget.gameObject); item.FXTarget = null; } if (AniTypeEnd.TryGetValue(key, out Action endAction)) { endAction(); } }
public static GameObject Get(string type) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("unit.unity3d", "Unit"); GameObject prefab = bundleGameObject.Get <GameObject>($"{type}"); return(prefab); }
public void Awake(GameObject parent) { ResourcesComponent res = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); GameObject ab = (GameObject)res.GetAsset(UICowCowAB.CowCow_Prefabs, UICowCowType.CowcowChat); this.GameObject = UnityEngine.Object.Instantiate(ab); this.GameObject.transform.SetParent(parent.transform, false); this.GameObject.name = UICowCowType.CowcowChat; ReferenceCollector rc = this.GameObject.GetComponent <ReferenceCollector>(); chatContent = rc.Get <GameObject>("ChatContent").GetComponent <CanvasGroup>(); GameObject content = rc.Get <GameObject>("Content"); emoji = rc.Get <GameObject>("Emoji").GetComponent <CanvasGroup>(); InputField inputChatContent = rc.Get <GameObject>("InputChatContent").GetComponent <InputField>(); Button sendBtn = rc.Get <GameObject>("SendBtn").GetComponent <Button>(); Button[] emojiBtn = new Button[emojiLen]; int seatId = Game.Scene.GetComponent <UIComponent>().Get(UICowCowType.CowCowGameRoom).GetComponent <UICowCow_GameRoomComponent>().GamerComponent.LocalSeatID; for (int i = 0; i < emojiBtn.Length; i++) { int n = i; emojiBtn[i] = rc.Get <GameObject>($"EmojiBtn{i}").GetComponent <Button>(); emojiBtn[i].onClick.Add(() => { Actor_SendChatMessageHelper.SendEmoji(n, seatId).Coroutine(); this.ShowHideEmoji(false); }); } sendBtn.onClick.Add(() => { Actor_SendChatMessageHelper.SendFont(customMessage, seatId, inputChatContent.text).Coroutine(); inputChatContent.text = string.Empty; this.ShowHideChatFont(false); }); this.GameObject.GetComponent <Button>().onClick.Add(() => { this.ShowHideChatFont(false); this.ShowHideEmoji(false); }); Button[] chatContentBtn = new Button[systemText.Count]; GameObject prefab = (GameObject)ETModel.Game.Scene.GetComponent <ResourcesComponent>().GetAsset(UICowCowAB.CowCow_Prefabs, UICowCowType.CowCowChatContentBtn); for (int i = 0; i < chatContentBtn.Length; i++) { int n = i; chatContentBtn[i] = UnityEngine.Object.Instantiate(prefab).GetComponent <Button>(); chatContentBtn[i].transform.SetParent(content.transform, false); chatContentBtn[i].transform.GetChild(0).GetComponent <Text>().text = systemText[i]; chatContentBtn[i].onClick.Add(() => { Actor_SendChatMessageHelper.SendFont(n, seatId, systemText[n]).Coroutine(); this.ShowHideChatFont(false); }); } }
public void Initialize() { button = GameObject.Find("Button").GetComponent <Button>(); button.onClick.AddListener(OnClickButton); ResourcesComponent resourcesComponent = ICE.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle("Cube".StringToAB().BundleNameToLower()); prefab = resourcesComponent.GetAsset("Cube".StringToAB().BundleNameToLower(), "Cube") as GameObject; }
/// <summary> /// 从通用资源加载预置 /// </summary> /// <param name="uiType"></param> /// <returns></returns> public GameObject LoadUIAsset(string uiType) { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UIType.CommonUI.StringToAB(), uiType); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); return(gameObject); }
static public string getTextFileByBundle(string bundleName, string fileName) { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{bundleName}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{bundleName}.unity3d", $"{bundleName}"); TextAsset go = bundleGameObject.Get <TextAsset>($"{fileName}"); return(go.text); }
static public Sprite getSpriteByBundle(string bundleName, string fileName) { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{bundleName}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{bundleName}.unity3d", $"{bundleName}"); Sprite sprite = bundleGameObject.Get <Sprite>($"{fileName}"); return(sprite); }
public void Awake() { //从包里读取出组件,保证每次都是最新的文字 //ETModel.Game.Scene.GetComponent<ResourcesComponent>().LoadBundle("languagesource.unity3d"); ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle("languagesource.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("languagesource.unity3d", "LanguageSource"); GameObject.Instantiate(bundleGameObject); }
public Sprite GetSprite(String atlasName, string spriteName) { //string prefab = "Icon"; ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle(atlasName.StringToAB()); SpriteAtlas sprintAtlas = (SpriteAtlas)resourcesComponent.GetAsset(atlasName.StringToAB(), atlasName); return(sprintAtlas.GetSprite(spriteName)); }
public LobbyServer(GameObject parent) { ResourcesComponent res = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); GameObject go = UnityEngine.Object.Instantiate((GameObject)res.GetAsset(UICowCowAB.CowCow_Prefabs, UICowCowType.CowCowLobbyServer)); go.transform.SetParent(parent.transform, false); this.parent = go.GetComponent <CanvasGroup>(); Button closeBtn = this.parent.transform.Find("CloseBtn").GetComponent <Button>(); closeBtn.onClick.Add(() => this.ShowHideLobbyServer(false)); }
/* * 从ab包中获取预制体 * param: * objName:预制体名称 */ public static GameObject LoadPrefabFromAb(string objName) { GameObject g = null; ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{objName}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{objName}.unity3d", $"{objName}"); g = bundleGameObject; return(g); }
static public GameObject getGameObjByBundle(string bundleName, string fileName) { bundleName = bundleName.ToLower(); ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{bundleName}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{bundleName}.unity3d", $"{bundleName}"); GameObject go = bundleGameObject.Get <GameObject>($"{fileName}"); return(go); }
static public AudioClip getAudioClipByAssetBundle(string assetbundleName, string audioName) { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); //resourcesComponent.LoadBundle($"{assetbundleName}.unity3d"); AudioClip abAudioClip = (AudioClip)resourcesComponent.GetAsset($"{assetbundleName}.unity3d", $"{audioName}"); if (abAudioClip != null) { return(abAudioClip); } return(null); }