public void ShowEnableEffect(GameObject effect, MainUI.UIType funcType) { if (m_btnEnableEffect != null) { Destroy(m_btnEnableEffect); } LocalSysButton btnComponent = null;// = btnArray.Single(P => P.ButtonFunc == funcType); for (int i = 0; i < btnArray.Count; i++) { if (btnArray[i].ButtonFunc == funcType) { btnComponent = btnArray[i]; } } if (btnComponent != null) { m_btnEnableEffect = Instantiate(effect) as GameObject; m_btnEnableEffect.transform.parent = btnComponent.transform; m_btnEnableEffect.transform.localScale = Vector3.one; m_btnEnableEffect.transform.localPosition = Vector3.zero; } }
public void InsertBtn(MainTownButtonConfigData item)//MainUI.UIType sysBtnType, MainBtnArea btnPos, int btnNum)//插入按钮,按钮位置,按钮序号,按钮序号从0开始 { //print("原预添加位置:"+btnNum); // if (item._ButtonIndex > btnArray.Count) // { // item._ButtonIndex = btnArray.Count; // } //print("实际添加位置:" +btnNum); LocalSysButton localBtnController = CreatObjectToNGUI.InstantiateObj(item.ButtonPrefab, transform).GetComponent <LocalSysButton>(); localBtnController.gameObject.RegisterBtnMappingId(item.ButtonFunc, BtnMapId_Sub.Empty); //new switch (item.ButtonArea) { case MainTownButtonArea.LeftUp: for (int i = 0; i < 10; i++) { if (i == item.Button_Row - 1) { if (m_insertLeftUpIFirst[i]) { m_insertLeftUpPos_x[i] = CommonDefineManager.Instance.CommonDefine.TownstartPoint1.BaseOffset.x; m_insertLeftUpIFirst[i] = false; //m_insertLeftUpPos_y=CommonDefineManager.Instance.CommonDefine.TownstartPoint1.BaseOffset.y; } else { m_insertLeftUpPos_x[i] += (item.ButtonRadius + m_insertLeftUpRadio[i]) * CommonDefineManager.Instance.CommonDefine.TownstartPoint1.Direction.x; } m_insertLeftUpPos_y = item.Button_RowIndex * CommonDefineManager.Instance.CommonDefine.TownstartPoint1.Direction.y; m_insertLeftUpRadio[i] = item.ButtonRadius; localBtnController.SetBtnAtrribute(item.ButtonFunc, new Vector3(m_insertLeftUpPos_x[i], m_insertLeftUpPos_y, 0), this.Showing, item.DefaultEnable == 1, item.ButtonSound); } } break; case MainTownButtonArea.RightUp: for (int i = 0; i < 10; i++) { if (i == item.Button_Row - 1) { if (m_insertRightUpFirst[i]) { m_insertRightUpPos_x[i] = CommonDefineManager.Instance.CommonDefine.TownstartPoint2.BaseOffset.x; m_insertRightUpFirst[i] = false; // m_insertRightUpPos_y=CommonDefineManager.Instance.CommonDefine.TownstartPoint2.BaseOffset.y; } else { m_insertRightUpPos_x[i] += (item.ButtonRadius + m_insertRightUpRadio[i]) * CommonDefineManager.Instance.CommonDefine.TownstartPoint2.Direction.x; } m_insertRightUpPos_y = item.Button_RowIndex * CommonDefineManager.Instance.CommonDefine.TownstartPoint2.Direction.y; m_insertRightUpRadio[i] = item.ButtonRadius; localBtnController.SetBtnAtrribute(item.ButtonFunc, new Vector3(m_insertRightUpPos_x[i], m_insertRightUpPos_y, 0), this.Showing, item.DefaultEnable == 1, item.ButtonSound); } } break; case MainTownButtonArea.RightDown: for (int i = 0; i < 10; i++) { if (i == item.Button_Row - 1) { if (m_insertRightDownFirst[i]) { if (i == 0) { m_insertRightDownPos_x[i] = CommonDefineManager.Instance.CommonDefine.TownstartPoint3.BaseOffset.x; } else { m_insertRightDownPos_x[i] = 0; } m_insertRightDownFirst[i] = false; // m_insertRightDownPos_y=CommonDefineManager.Instance.CommonDefine.TownstartPoint2.BaseOffset.y; } else { m_insertRightDownPos_x[i] += (item.ButtonRadius + m_insertRightDownRadio[i]) * CommonDefineManager.Instance.CommonDefine.TownstartPoint3.Direction.x; } m_insertRightDownPos_y = item.Button_RowIndex * CommonDefineManager.Instance.CommonDefine.TownstartPoint3.Direction.y; m_insertRightDownRadio[i] = item.ButtonRadius; localBtnController.SetBtnAtrribute(item.ButtonFunc, new Vector3(m_insertRightDownPos_x[i], m_insertRightDownPos_y, 0), this.Showing, item.DefaultEnable == 1, item.ButtonSound); } } break; default: break; } //localBtnController.SetBtnAtrribute(item.ButtonFunc, new Vector3(item.ButtonPositionOffset.x, item.ButtonPositionOffset.y, 0), this.Showing,item.DefaultEnable==1); //引导注入 #region old // switch (item._ButtonArea) // { // case MainBtnArea.TopLeft: // // m_insertBottomPos += -(item._ButtonRadius * 2); // localBtnController.SetBtnAtrribute(item._ButtonFunc, new Vector3(item._ButtonIndex.x, item._ButtonIndex.y, 0), this.Showing); // break; // case MainBtnArea.TopRight: // m_insertRightPos += (item._ButtonRadius * 2); // localBtnController.SetBtnAtrribute(item._ButtonFunc, new Vector3(0, m_insertRightPos, 0), this.Showing); // break; // default: // break; // } #endregion ///ssss btnArray.Add(localBtnController); //ResetBtnPosition(); int guideID = 0; //TODO GuideBtnManager.Instance.RegGuideButton(localBtnController.gameObject, item._ButtonFunc, SubType.MainButton, out guideID); m_guideBtnID.Add(guideID); }