1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System;
- using UnityEngine;
- [ExecuteInEditMode]
- [RequireComponent(typeof(UIWidget))]
- [AddComponentMenu("NGUI/Examples/Set Color on Selection")]
- public class SetColorOnSelection : MonoBehaviour
- {
- public void SetSpriteBySelection()
- {
- if (UIPopupList.current == null)
- {
- return;
- }
- if (this.mWidget == null)
- {
- this.mWidget = base.GetComponent<UIWidget>();
- }
- string value = UIPopupList.current.value;
- switch (value)
- {
- case "White":
- this.mWidget.color = Color.white;
- break;
- case "Red":
- this.mWidget.color = Color.red;
- break;
- case "Green":
- this.mWidget.color = Color.green;
- break;
- case "Blue":
- this.mWidget.color = Color.blue;
- break;
- case "Yellow":
- this.mWidget.color = Color.yellow;
- break;
- case "Cyan":
- this.mWidget.color = Color.cyan;
- break;
- case "Magenta":
- this.mWidget.color = Color.magenta;
- break;
- }
- }
- private UIWidget mWidget;
- }
|