private void InitUICanvas() { if (UIRoot == null) { return; } if (m_MiddleUIRoot != null)//表示已经创建过[重登陆] { return; } m_MiddleUIRoot = UGUITools.AddChild(UIRoot.gameObject, NormalUIRoot.gameObject, false, UINodeName.MiddleUIRootName).transform; m_TopUIRoot = UGUITools.AddChild(UIRoot.gameObject, NormalUIRoot.gameObject, false, UINodeName.TopUIRootName).transform; m_T2Root = UGUITools.AddChild(UIRoot.gameObject, NormalUIRoot.gameObject, false, UINodeName.T2RootName).transform; m_T3Root = UGUITools.AddChild(UIRoot.gameObject, NormalUIRoot.gameObject, false, UINodeName.T3RootName).transform; //Canvas2D SetUICanvas2Ds(); //Canvas3D //SetUICanvas3D(CamerasMgr.CameraMain); //Show3DUI(true); //UICamera SetUICamera(); }
private static void Activate(Transform t, bool compatibilityMode) { UGUITools.SetActiveSelf(t.get_gameObject(), true); if (compatibilityMode) { int i = 0; int childCount = t.get_childCount(); while (i < childCount) { Transform child = t.GetChild(i); if (child.get_gameObject().get_activeSelf()) { return; } i++; } int j = 0; int childCount2 = t.get_childCount(); while (j < childCount2) { Transform child2 = t.GetChild(j); UGUITools.Activate(child2, true); j++; } } }
public void OnResLoaded() { string layerName = mLayerName; if (string.IsNullOrEmpty(layerName) == true) { layerName = "InterObject"; } int parentLayer = LayerMask.NameToLayer("InterObject"); int layer = LayerMask.NameToLayer(layerName); Transform trans = this.transform; for (int i = 0; i < trans.childCount; ++i) { Transform child = trans.GetChild(i); child.gameObject.layer = parentLayer; UGUITools.SetChildLayer(child, layer); } Collider collider = gameObject.GetComponentInChildren <Collider>(); if (collider != null) { collider.isTrigger = true; } }
private GameObject DoInstantiate(int index) { GameObject gameObject; if (this.temp != null) { gameObject = UGUITools.AddChild(base.get_gameObject(), this.temp, false); gameObject.set_name(this.temp.get_name() + index.ToString()); } else { gameObject = ResourceManager.GetInstantiate2Prefab(this.temp_prefabname); UGUITools.SetParent(base.get_gameObject(), gameObject, false); gameObject.set_name(this.temp_prefabname + index.ToString()); } if (this.isAnimation) { gameObject.GetComponent <RectTransform>().set_anchoredPosition((index < this.maxShow * this.lineContainNum) ? (this.GetPos(index) + this.moveing) : this.GetPos(index)); } else if (!this.IsContainLayoutWidget) { gameObject.GetComponent <RectTransform>().set_anchoredPosition(this.GetPos(index)); } return(gameObject); }
/// <summary> /// 播放/暂停音效 /// </summary> /// <param name="play"></param> public void PauseSFX(bool pause) { if (m_Listener != null && m_Listener.enabled && UGUITools.GetActive(m_Listener.gameObject)) { AudioSource source = m_Listener.GetComponent <AudioSource>(); if (source == null) { source = m_Listener.gameObject.AddComponent <AudioSource>(); } if (!pause) { source.Play(); } else { source.Pause(); } BattleSFXAudioSource battleSFXAudioSource = GetSFXAudioSource(); if (source != null) { if (!pause) { battleSFXAudioSource.Play(); } else { battleSFXAudioSource.Pause(); } } } }
protected void GetAsyncModel(Transform root, int modelID, Action callback) { AvatarModel avatarModelData = DataReader <AvatarModel> .Get(modelID); if (avatarModelData == null) { return; } this.asyncModelIDs.Add(GameObjectLoader.Instance.Get(avatarModelData.path, delegate(GameObject obj) { if (obj == null) { Debug.LogError(string.Format("马上联系左总,GameObjectLoader.Instance.Get拿到空值,路径是{0}", avatarModelData.path)); return; } obj.SetActive(true); obj.set_name(modelID.ToString()); root.set_localScale(Vector3.get_one() * avatarModelData.scale); UGUITools.ResetTransform(obj.get_transform(), root); Animator[] componentsInChildren = obj.GetComponentsInChildren <Animator>(true); if (componentsInChildren.Length > 0) { componentsInChildren[0].set_cullingMode((avatarModelData.alwaysVisible <= 0) ? 1 : 0); AssetManager.AssetOfControllerManager.SetController(componentsInChildren[0], modelID, false); } if (callback != null) { callback.Invoke(); } })); }
protected virtual void OnInit() { if (templateRect == null) { if (CacheTransform.childCount > 0) { templateRect = CacheTransform.GetChild(0) as RectTransform; } } if (templateRect != null) { UGUITools.SetVisible(templateRect, false); } if (rowCount < 1) { rowCount = 1; } if (columnCount < 1) { columnCount = 1; } if (!NoScroll) { ScrollRect = UGUITools.SecureComponetInParent <ScrollRect>(CacheRectTransform); } if (ScrollRect != null) { ScrollRect.horizontal = !IsVertical; ScrollRect.vertical = IsVertical; } _Pool = new GNewPrivatePool <LayoutItem>(PoolSize); }
private void LoadFaces() { List <ChatManager.FaceSuit> faceSuits = ChatManager.Instance.GetFaceSuits(); for (int i = 0; i < faceSuits.get_Count(); i++) { GameObject instantiate2Prefab = ResourceManager.GetInstantiate2Prefab("Item2FaceSuit"); UGUITools.SetParent(this.m_tranFaceSuits.get_gameObject(), instantiate2Prefab, false, "Item2Face" + i); Item2FaceSuit item2FaceSuit = instantiate2Prefab.AddUniqueComponent <Item2FaceSuit>(); item2FaceSuit.SetFaceScale(1.5f); RectTransform rectTransform = item2FaceSuit.get_transform() as RectTransform; rectTransform.set_anchorMin(new Vector2(0.5f, 0.5f)); rectTransform.set_anchorMax(new Vector2(0.5f, 0.5f)); rectTransform.set_pivot(new Vector2(0.5f, 0.5f)); rectTransform.set_sizeDelta(new Vector2(0f, 0f)); UGUITools.ResetTransform(rectTransform); int num = faceSuits.get_Item(i).num; item2FaceSuit.SetFaces(faceSuits.get_Item(i).icons, delegate { if (ChatUIViewModel.Instance != null && ChatUIView.Instance != null) { if (ChatUIView.Instance.m_ChatInputUnit.FaceNum >= ChatManager.MAX_NUM_2_FACE) { FloatTextAddManager.Instance.AddFloatText(GameDataUtils.GetChineseContent(502063, false), Color.get_green()); } else { ChatUIViewModel expr_5D = ChatUIViewModel.Instance; expr_5D.SendContent += ChatManager.FacePlaceholder + num.ToString("D2"); } } }); } }
public void RefreshChats(List <ChatManager.ChatInfo> chatInfos) { this.ClearChats(); if (chatInfos.get_Count() == 0) { return; } for (int i = 0; i < chatInfos.get_Count(); i++) { ChatInfoBase chatInfoBase = ChatManager.CreatePrefab2TipChatInfo(string.Empty); chatInfoBase.ShowInfo(chatInfos.get_Item(i)); this.Chats.Add(chatInfoBase); } while (this.Chats.get_Count() > 0 && this.CalHeight4Chats(this.Chats.get_Count()) > 88f) { ChatManager.Reuse2TipChatInfoPool(this.Chats.get_Item(0)); this.Chats.RemoveAt(0); } for (int j = 0; j < this.Chats.get_Count(); j++) { RectTransform rectTransform = this.Chats.get_Item(j).get_transform() as RectTransform; UGUITools.ResetTransform(rectTransform.get_transform(), this.m_tranContent); rectTransform.set_anchoredPosition(new Vector2(0f, -this.CalHeight4Chats(j))); } }
private void updatePageItemActive() { if (this.pageList == null) { return; } if (this.pageList.Count == 0) { return; } if (this.pageCount > 3) { foreach (GameObject t in this.pageList) { if (t.gameObject.name == "page" + 0) { UGUITools.SetVisible(t.transform, false); } else if (t.gameObject.name == "page" + (this.pageCount + 1)) { UGUITools.SetVisible(t.transform, false); } else { UGUITools.SetVisible(t.transform, true); } } } }
private UpgradePreviewUnit Create(Transform parent) { GameObject instantiate2Prefab = ResourceManager.GetInstantiate2Prefab("UpgradePreviewUnit"); UGUITools.SetParent(parent.get_gameObject(), instantiate2Prefab, true); return(instantiate2Prefab.GetComponent <UpgradePreviewUnit>()); }
public static void CreateCameraOfBattleSpine() { if (CamerasMgr.CameraOfBattleSpine != null && CamerasMgr.CameraOfBattleSpine.get_transform() != null) { CamerasMgr.CameraOfBattleSpine.get_gameObject().SetActive(true); } else { GameObject gameObject = new GameObject(); gameObject.set_name("Camera2BattleSpineScreen"); gameObject.get_transform().set_parent(null); CamerasMgr.CameraOfBattleSpine = gameObject.AddComponent <Camera>(); CamerasMgr.CameraOfBattleSpine.set_clearFlags(1); CamerasMgr.CameraOfBattleSpine.set_cullingMask(LayerSystem.GetMask(CamerasMgr.battle_spine_layerss)); CamerasMgr.CameraOfBattleSpine.set_depth(CamerasMgr.CameraMain.get_depth() - 1f); GameObject gameObject2 = AssetManager.AssetOfNoPool.LoadAssetNowNoAB("UGUI/Prefabs/GlobalUI/UICanvasNoEvents", typeof(Object)) as GameObject; if (gameObject2 == null) { return; } CamerasMgr._canvasOfBattleSpine = UGUITools.AddChild(CamerasMgr.CameraOfBattleSpine.get_gameObject(), gameObject2, false, "_canvasOfBattleSpine").get_transform(); Canvas component = CamerasMgr._canvasOfBattleSpine.GetComponent <Canvas>(); if (component != null) { component.set_worldCamera(CamerasMgr.CameraOfBattleSpine); component.get_gameObject().SetActive(true); component.set_planeDistance(100f); component.set_sortingOrder(1000); } } }
private static void CreatePools() { FloatTextAddManager.Pool2FloatText = new GameObject("Pool2FloatText").get_transform(); FloatTextAddManager.Pool2FloatText.set_parent(UINodesManager.T2RootOfSpecial); UGUITools.ResetTransform(FloatTextAddManager.Pool2FloatText); FloatTextAddManager.FloatTextPool = new UIPool("FloatTextAddUI", FloatTextAddManager.Pool2FloatText, false); }
private PetTaskResultModel Create(Transform parent) { GameObject instantiate2Prefab = ResourceManager.GetInstantiate2Prefab("PetTaskResultModel"); UGUITools.SetParent(parent.get_gameObject(), instantiate2Prefab, true); return(instantiate2Prefab.GetComponent <PetTaskResultModel>()); }
private void CreateAttr(int key, int value, bool isShowNext = false, int nextValue = 0) { GameObject gameObject = this.mAttrList.Find((GameObject e) => e.get_name() == "Unused"); if (gameObject == null) { gameObject = Object.Instantiate <GameObject>(this.mGoAttrPrefab); UGUITools.SetParent(this.mAttrPanel, gameObject, false); this.mAttrList.Add(gameObject); } gameObject.get_gameObject().set_name(key.ToString()); gameObject.get_gameObject().SetActive(true); gameObject.get_transform().FindChild("Attr").GetComponentInChildren <Text>().set_text(AttrUtility.GetStandardDesc(key, value, "ff7d4b")); GameObject gameObject2 = gameObject.get_transform().FindChild("Next").get_gameObject(); if (isShowNext) { gameObject2.SetActive(true); gameObject2.GetComponentInChildren <Text>().set_text(AttrUtility.GetAttrValueDisplay(key, nextValue)); } else { gameObject2.SetActive(false); } }
public static void SetActiveChildren(GameObject go, bool state) { Transform transform = go.get_transform(); if (state) { int i = 0; int childCount = transform.get_childCount(); while (i < childCount) { Transform child = transform.GetChild(i); UGUITools.Activate(child, true); i++; } } else { int j = 0; int childCount2 = transform.get_childCount(); while (j < childCount2) { Transform child2 = transform.GetChild(j); UGUITools.Deactivate(child2); j++; } } }
private void refreshPage(int pageindex, bool isright) { if (this.CurPageIndex == 1) { return; } List <GameObject> itemList = this.pageItemList[pageindex]; int count = itemList.Count; if (isright && this.CurPageIndex == (this.pageCount - 1) && this.lastPageItemCount != 0) { for (int i = 0; i < count; i++) { var item = itemList[i]; if (i < this.lastPageItemCount) { UGUITools.SetVisible(item.transform, true); this.m_updateItem?.Invoke(item, i, this.CurPageIndex + 1); } else { UGUITools.SetVisible(item.transform, false); } } } else { for (int i = 0; i < count; i++) { var item = itemList[i]; UGUITools.SetVisible(item.transform, true); this.m_updateItem?.Invoke(item, i, isright?this.CurPageIndex + 1:this.CurPageIndex - 1); } } }
public GameObject AddToPopCanvas() { var obj = UGUITools.AddChild(UIManager.PopCanvasRoot, (GameObject)uiPrefab); obj.name = uiPrefab.name; return(obj); }
public GamePlayUI(GamePlayContext context) { _Context = context; _PlayerGestureInput = new PlayerGestureInput(); _InGameUI = UGUITools.AddUI <MonoInGameUI>(MonoInGameUI.PATH); _InGameUI.Regist(_PlayerGestureInput); _PlayerGestureInput.Regist(_Context); }
public static void SetParent(GameObject parent, GameObject goInstantiate, bool forceShow, string name) { if (goInstantiate != null && !string.IsNullOrEmpty(name)) { goInstantiate.set_name(name); } UGUITools.SetParent(parent, goInstantiate, forceShow); }
private static void CreateWaveBloodUnitPool() { WaveBloodManager.Pool2WaveBloodUnit = new GameObject("Pool2WaveBloodUnit").get_transform(); WaveBloodManager.Pool2WaveBloodUnit.set_parent(UINodesManager.NoEventsUIRoot); WaveBloodManager.Pool2WaveBloodUnit.get_gameObject().SetActive(false); UGUITools.ResetTransform(WaveBloodManager.Pool2WaveBloodUnit); WaveBloodManager.WaveBloodUnitPool = new UIPool("WaveBloodUnit", WaveBloodManager.Pool2WaveBloodUnit, true); }
// Create STexture public static STexture AddTexture(GameObject gameObject) { STexture texture = UGUITools.AddChild <STexture>(gameObject); (texture as RawImage).raycastTarget = false; UGUITools.ResetGameObject(texture.gameObject); return(texture); }
private static void CreatePools() { Transform transform = new GameObject("Pool2FloatTip").get_transform(); transform.set_parent(UINodesManager.NoEventsUIRoot); transform.get_gameObject().set_layer(LayerSystem.NameToLayer("UI")); FloatTipManager.Pool2FloatTip = transform; UGUITools.ResetTransform(FloatTipManager.Pool2FloatTip); FloatTipManager.FloatTipPool = new UIPool("FloatTipUnit", FloatTipManager.Pool2FloatTip, false); }
private static void CreatePools() { Transform transform = new GameObject("Pool2EnemyArrow").get_transform(); transform.set_parent(UINodesManager.NoEventsUIRoot); transform.get_gameObject().set_layer(LayerSystem.NameToLayer("UI")); ArrowManager.Pool2EnemyArrow = transform; UGUITools.ResetTransform(ArrowManager.Pool2EnemyArrow); ArrowManager.EnemyArrowPool = new UIPool("EnemyInScreenUnit", ArrowManager.Pool2EnemyArrow, false); }
public void InitPushToggle() { for (int i = 1; i <= 4; i++) { GameObject instantiate2Prefab = ResourceManager.GetInstantiate2Prefab("SettingToggle"); UGUITools.SetParent(base.FindTransform("PushOn0" + i).get_gameObject(), instantiate2Prefab, true); this.mSettingToggles.Add(instantiate2Prefab.GetComponent <SettingToggle>()); } this.SetPushToggle(); }
private static void CreateWaveBloodControlPool() { Transform transform = new GameObject("Pool2WaveBloodControl").get_transform(); transform.set_parent(UINodesManager.NoEventsUIRoot); transform.get_gameObject().set_layer(LayerSystem.NameToLayer("UI")); WaveBloodManager.Pool2WaveBloodControl = transform; UGUITools.ResetTransform(WaveBloodManager.Pool2WaveBloodControl); WaveBloodManager.WaveBloodControlPool = new UIPool("WaveBloodControl", WaveBloodManager.Pool2WaveBloodControl, false); }
public static GameObject AddChild(GameObject parent, GameObject asset, bool forceShow, string name) { GameObject gameObject = UGUITools.AddChild(parent, asset, forceShow); if (gameObject != null && !string.IsNullOrEmpty(name)) { gameObject.set_name(name); } return(gameObject); }
// Create SImage public static SImage AddImage(GameObject gameObject) { SImage image = UGUITools.AddChild <SImage>(gameObject); image.Atlas = atlas; image.SpriteName = selectedSprite; image.raycastTarget = false; UGUITools.ResetGameObject(image.gameObject); return(image); }
public GameObject OpenUI(string prefabName, Transform parent = null, bool forceShow = false) { GameObject ui = CResourceSys.Instance.LoadUI(prefabName); if (parent == null) { parent = NormalUIRoot; } UGUITools.SetParent(parent.gameObject, ui, forceShow); return(ui); }
public ActorNPC CreateNPC(int id, int modelID, NPCBehavior npcEvent) { GameObject gameObject = new GameObject(); UGUITools.ResetTransform(gameObject.get_transform(), NPCPool.Instance.root.get_transform()); ActorNPC actorNPC = gameObject.AddUniqueComponent <ActorNPC>(); actorNPC.Init(id, modelID, npcEvent); this.npcLogicList.Add(actorNPC); return(actorNPC); }