/// <summary> /// UnSelect toggle color(NGUI_QFord) /// </summary> void ResetLabelColor(UIToggle toggle, int r, int g, int b) { UILabel label = toggle.GetComponentInChildren <UILabel>(); if (label != null) { label.applyGradient = false; NGUIUtil.SetLableColor(label, r, g, b); } }
/// <summary> /// Select toggle gradient color(NGUI_QFord) /// </summary> void SetLableColorGradient(UIToggle toggle) { UILabel label = toggle.GetComponentInChildren <UILabel>(); if (label != null) { Color top = ColorUtils.FromArgb(255, 251, 255, 0); Color bottom = ColorUtils.FromArgb(255, 255, 121, 0); NGUIUtil.SetLableGradientColor(label, top, bottom); } }
public void Init() { //设置大小 templateObjPar.SetActive(false); int mapIconSize = gridSize - 2 * iconEdgeSize; blockTemplate.width = mapIconSize; blockTemplate.height = mapIconSize; startPointTemplate.width = mapIconSize; startPointTemplate.height = mapIconSize; endPointTemplate.width = mapIconSize; endPointTemplate.height = mapIconSize; lineTemplate.width = mapIconSize; lineTemplate.height = mapIconSize; pathTemplate.width = mapIconSize; pathTemplate.height = mapIconSize; //保存初始化输入框提示 mInputInitValue = inputSaveName.value; //描画背景 int bgWidth = gridSize * (int)MapManager.Instant.MapWidth + edgeSize * 2; int bgHeight = gridSize * (int)MapManager.Instant.MapHeight + edgeSize * 2; sprBg.transform.localPosition = new Vector3(0f, 0f, 0f); sprBg.width = bgWidth; sprBg.height = bgHeight; BoxCollider collider = sprBg.GetComponent <BoxCollider> (); collider.size = new Vector3(MapManager.Instant.MapWidth * gridSize, MapManager.Instant.MapHeight * gridSize, 0f); collider.center = new Vector3(bgWidth / 2f, -bgHeight / 2f, 0f); UIEventListener.Get(collider.gameObject).onClick = OnBgClick; //描画格子 float topPos = -edgeSize; float leftPos = edgeSize; float bottomPos = topPos - MapManager.Instant.MapHeight * gridSize; float rightPos = leftPos + MapManager.Instant.MapWidth * gridSize; //竖线 for (int i = 0; i <= MapManager.Instant.MapWidth; ++i) { float posX = i * gridSize + leftPos; UISprite sprLine = CreateLine(); sprLine.width = (int)(topPos - bottomPos); sprLine.transform.localEulerAngles = new Vector3(0f, 0f, -90f); sprLine.transform.localPosition = new Vector3(posX, topPos, 0f); } //横线 for (int i = 0; i <= MapManager.Instant.MapHeight; ++i) { float posY = topPos - i * gridSize; UISprite sprLine = CreateLine(); sprLine.width = (int)(rightPos - leftPos); sprLine.transform.localEulerAngles = new Vector3(0f, 0f, 0f); sprLine.transform.localPosition = new Vector3(leftPos, posY, 0f); } //创建起始点 mStartPoint = GameObject.Instantiate(startPointTemplate) as UISprite; mStartPoint.transform.parent = transView; mStartPoint.transform.localScale = Vector3.one; HideStartPoint(); //创建结束点 mEndPoint = GameObject.Instantiate(endPointTemplate) as UISprite; mEndPoint.transform.parent = transView; mEndPoint.transform.localScale = Vector3.one; HideEndPoint(); //选择列表 Array array = Enum.GetValues(typeof(GridType)); for (int i = 0; i < array.Length; ++i) { GridType type = (GridType)array.GetValue(i); UIToggle tog = GameObject.Instantiate(togTemplate) as UIToggle; tog.transform.parent = togParent; tog.transform.localScale = Vector3.one; tog.transform.localPosition = new Vector3(0f, -togHeight * i, 0f); tog.name = type.ToString(); tog.GetComponentInChildren <UILabel> ().text = type.ToString(); mTogList.Add(tog); } mTogList [0].value = true; UIEventListener.Get(btnFindPath.gameObject).onClick = OnFindPathClicked; UIEventListener.Get(btnClearFindPath.gameObject).onClick = OnClearPathClicked; UIEventListener.Get(btnSaveData.gameObject).onClick = OnSaveData; UIEventListener.Get(btnLoadData.gameObject).onClick = OnLoadData; RefreshBlock(); }