public void Awake() { instance = this; thisObj = gameObject; canvasGroup = thisObj.GetComponent <CanvasGroup>(); if (canvasGroup == null) { canvasGroup = thisObj.AddComponent <CanvasGroup>(); } canvasGroup.alpha = 0; thisObj.SetActive(false); thisObj.GetComponent <RectTransform>().anchoredPosition = new Vector3(0, 0, 0); fpsItem.Init(); recticleSpreadDefaultSize = recticleSpreadRectT.sizeDelta; reloadProgressObj = imgReloadProgress.transform.parent.gameObject; reloadProgressObj.SetActive(false); UIItemCallback itemCallback = buttonFireObj.AddComponent <UIItemCallback>(); itemCallback.SetDownCallback(this.OnFireButtonDown); itemCallback.SetUpCallback(this.OnFireButtonUp); buttonExit.Init(); }
void Start() { if (!AbilityManager.IsOn() || AbilityManager.GetAbilityCount() == 0) { thisObj.SetActive(false); return; } List <Ability> abList = AbilityManager.GetAbilityList(); for (int i = 0; i < abList.Count; i++) { if (i == 0) { buttonList[0].Init(); } else if (i > 0) { buttonList.Add(UIButton.Clone(buttonList[0].rootObj, "AbilityButton" + (i + 1))); } buttonList[i].imgIcon.sprite = abList[i].icon; buttonList[i].imgHighlight.enabled = false; buttonList[i].label.text = ""; if (abList[i].usedRemained > 0) { buttonList[i].label.text = abList[i].usedRemained.ToString(); } //else buttonList[i].label.text="∞"; if (UIMainControl.InTouchMode()) { buttonList[i].SetCallback(null, null, this.OnAbilityButton, null); } else { buttonList[i].SetCallback(this.OnHoverButton, this.OnExitButton, this.OnAbilityButton, null); } } tooltipRscItem.Init(); butCancelCanvasG = butCancelObj.AddComponent <CanvasGroup>(); OnAbilitySelectingTarget(false); UIItemCallback cancelCallback = butCancelObj.AddComponent <UIItemCallback>(); cancelCallback.SetDownCallback(this.OnCancelAbilityButton); //cancelCallback.SetUpCallback(up); tooltipObj.SetActive(false); }
// Use this for initialization void Start() { GameObject lastSpaceObj = null; if (UIControl.IsGameScene()) { lifeItem.Init(); waveItem.Init(); UpdateLifeDisplay(GameControl.GetLife()); UpdateWaveDisplay(1); lastSpaceObj = spaceObjLife; } else { waveItem.rootObj.SetActive(false); spaceObjWave.SetActive(false); lifeItem.rootObj.SetActive(false); spaceObjLife.SetActive(false); } if (UIControl.IsGameScene() || PerkManager.UseRscManagerForCost()) { for (int i = 0; i < RscManager.GetResourceCount(); i++) { if (i > 0) { rscItemList.Add(new UIObject(UI.Clone(rscItemList[0].rootObj))); } rscItemList[i].Init(); rscItemList[i].imgMain.sprite = RscManager.GetRscIcon(i); rscItemList[i].rectT.SetSiblingIndex(rscItemList[0].rectT.GetSiblingIndex() + i); } UpdateResourceDisplay(RscManager.GetResourceList()); lastSpaceObj = spaceObjRsc; } else { rscItemList[0].rootObj.SetActive(false); spaceObjRsc.SetActive(false); } if (!UIControl.IsGameScene() || !AbilityManager.IsEnabled() || AbilityManager.UseRscManagerForCost()) { sliderAbilityRsc.gameObject.SetActive(false); spaceObjAbility.SetActive(false); } else { imgAbilityRsc.sprite = AbilityDB.GetRscIcon(); UpdateAbilityRscDisplay(AbilityManager.GetRsc()); lastSpaceObj = spaceObjAbility; } if (!PerkManager.IsEnabled() || PerkManager.UseRscManagerForCost()) { perkRscItem.rootObj.SetActive(false); //spaceObjPerk.SetActive(false); lastSpaceObj.SetActive(false); } else { perkRscItem.Init(); perkRscItem.imgMain.sprite = PerkDB.GetRscIcon(); UpdatePerkRscDisplay(PerkManager.GetRsc()); } //~ if(!UIControl.DisablePerkScreen()){ //~ buttonPerk.Init(); //~ buttonPerk.SetCallback(null, null, this.OnPerkButton, null); //~ } //~ else{ //~ if(buttonPerk.rootObj!=null) buttonPerk.rootObj.SetActive(false); //~ } //~ buttonFF.Init(); //~ buttonFF.SetCallback(null, null, this.OnFFButton, null); //~ buttonPause.Init(); //~ buttonPause.SetCallback(null, null, this.OnPauseButton, null); }