void EventCreateUnit(object obj) { GenerateUnitInfo info = obj as GenerateUnitInfo; if (info == null) { return; } if (info.camp == m_Camp) { UnitInfo unitInfo = ResManager.Instance.unitTable.GetById(info.unitId); ResManager.Instance.LoadObject <GameObject>(unitInfo.modelPath, true, (go) => { go.transform.position = info.pos; BaseUnit bu = ComponentTools.AddComponent <BaseUnit>(go); bu.Init(unitInfo, m_Camp); if (unitInfo.unitType != (int)UnitType.Crystal && unitInfo.unitType != (int)UnitType.GuardTower) { ComponentTools.AddComponent <UnitPathFollower>(go); } m_unitList.Add(go); }); } }
protected override void ConfigComponents() { base.ConfigComponents(); #if UNITY_EDITOR enableOutlog = true; #else enableOutlog = true; #endif ComponentTools.AddComponent <AudioListener>(gameObject); if (Framework.Get <ResManager>() == null) { Framework.AddComponent <ResManager>(); } if (Framework.Get <AudioManager>() == null) { Framework.AddComponent <AudioManager>(); } #if UNITY_EDITOR #elif UNITY_IOS #elif UNITY_ANDROID #endif SMSceneManager sceneManager; sceneManager = AddComponent <SMSceneManager>(); sceneManager.TransitionPrefab = "Prefabs/SMTransitions/SMFadeTransition"; // sceneManager.SceneLoaded += OnSceneLoaded; }
// Use this for initialization void Start() { GameObject go = null; UnitCard uc = null; for (int i = 0; i < 4; i++) { go = ComponentTools.LoadUIObject(UIPartFilePath.UnitCard, m_grid_card.transform); uc = ComponentTools.AddComponent <UnitCard>(go); m_UnitCardList.Add(uc); m_grid_card.repositionNow = true; } Framework.SendEvent(ThisGameEvent.HideUI); }
void OnBattle(GameObject btn) { base.OnBack(btn); GameObject uibattle = null; WindowManager.ManageWinwodOpen(WindowAction.Open_UIBattle, null, uibattle); GameObject go = GameObject.Find("BattleManager"); if (go == null) { go = new GameObject(); go.name = "BattleManager"; } BattleManager bm = ComponentTools.AddComponent <BattleManager>(go); }
static T OpenWindow <T>(string uiPath, WindowType type, UILayer layer = UILayer.Default) where T : BaseUI { if (m_go_UIRoot == null) { m_go_UIRoot = GameObject.FindGameObjectWithTag("UIRoot"); } T com = null; ResManager.Instance.LoadObject <GameObject>(uiPath, true, (obj) => { obj.SetActive(true); obj.transform.SetParent(m_go_UIRoot.transform); obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; m_WindowList.Add(obj); com = ComponentTools.AddComponent <T>(obj); com.WinType = type; int nLayer = (int)layer; if (layer == UILayer.Default) { nLayer = CurUILayer; } UIPanel[] panels = obj.GetComponentsInChildren <UIPanel>(); if (panels != null) { for (int i = 0; i < panels.Length; i++) { panels[i].depth += nLayer * UIDepthFactor; } } }); return(com); }