public override void Init() { base.Init(); this.m_colliderCached = base.collider; if (null == this.m_colliderCached) { Debug.Log("null == m_colliderCached"); } this.m_uiButtonColor = base.GetComponent <UIButtonColor>(); this.m_uiButtonScale = base.GetComponent <UIButtonScale>(); this.m_uiButtonOffset = base.GetComponent <UIButtonOffset>(); this.m_uiButtoSounds = base.GetComponents <UIPlaySound>(); this.m_uiSprites = base.GetComponentsInChildren <UISprite>(true); this.m_uiTextures = base.GetComponentsInChildren <UITexture>(true); this.m_uiHovers = base.GetComponents <UIHover>(); this.m_ButtonKeyBinds = base.GetComponents <UIButtonKeyBinding>(); this.m_dicInitColorLabel.Clear(); UILabel[] componentsInChildren = base.GetComponentsInChildren <UILabel>(true); UILabel[] array = componentsInChildren; for (int i = 0; i < array.Length; i++) { UILabel uILabel = array[i]; if (null != uILabel && !this.m_dicInitColorLabel.ContainsKey(uILabel)) { this.m_dicInitColorLabel.Add(uILabel, uILabel.color); } } }
protected override void OnAwake() { base.OnAwake(); this.m_gameui = XSingleton <XInterfaceMgr> .singleton.GetInterface <IXGameUI>(XSingleton <XCommon> .singleton.XHash("XGameUI")); this.m_tutorial = XSingleton <XInterfaceMgr> .singleton.GetInterface <IXTutorial>(XSingleton <XCommon> .singleton.XHash("XTutorial")); this.m_operation = XSingleton <XInterfaceMgr> .singleton.GetInterface <IXOperationRecord>(XSingleton <XCommon> .singleton.XHash("XOperationRecord")); this.m_uiButton = base.GetComponent <UIButton>(); this.m_uiButtonColor = this.m_uiButton; this.m_uiButtonScale = base.GetComponent <UIButtonScale>(); this.m_uiButtonOffset = base.GetComponent <UIButtonOffset>(); this.m_uiSpriteBG = base.GetComponentInChildren <UISprite>(); if (this.m_uiButton != null) { this.m_colliderCached = this.m_uiButton.cacheCol; } else { this.m_colliderCached = base.GetComponent <Collider>(); } this.CloneFromTpl(); if (this.m_NeedAudio && (string.IsNullOrEmpty(this.audioClip) || !this.audioClip.StartsWith("Audio"))) { this.SetAudioClip("Audio/UI/UI_Button_ok"); } this.m_CD.SetClickCD(this.CustomClickCDGroup, this.CustomClickCD); if (this.m_uiButton != null) { this.m_uiButton.changeStateSprite = this.ChangeStateSprite; } }
static void ExportSelectionToSeparate() { Transform[] selection = Selection.GetTransforms(SelectionMode.Editable | SelectionMode.ExcludePrefab); if (selection.Length == 0) { EditorUtility.DisplayDialog("No source object selected!", "Please select one or more target objects", ""); return; } int modifyCount = 0; for (int i = 0; i < selection.Length; i++) { Transform selectTransform = selection[i]; UIButtonScale uiButtonScale = selectTransform.GetComponent <UIButtonScale>(); if (uiButtonScale == null && selectTransform.GetComponent <BoxCollider>() != null) { uiButtonScale = selectTransform.gameObject.AddComponent <UIButtonScale>(); } if (uiButtonScale != null) { uiButtonScale.hover = new Vector3(1f, 1f, 1f); uiButtonScale.pressed = new Vector3(0.9f, 0.9f, 0.9f); uiButtonScale.duration = 0.1f; modifyCount++; } } EditorUtility.DisplayDialog("AddScaleToGameObject", "Modify " + modifyCount + " objects", ""); }
void Awake() { uiButton = GetComponent <UIButton>(); uiButtonScale = GetComponent <UIButtonScale>(); uiButtonOffset = GetComponent <UIButtonOffset>(); uiButtonSound = GetComponent <UIButtonSound>(); }
private void OnEnable() { _trans = GetComponent <Transform>(); _card = GetComponent <CardScript>(); _sprUI = GetComponent <UISprite>(); _btnScale = GetComponent <UIButtonScale>(); // 버튼의 OnHover()가 OnDrag()일때는 호출이 안되서 이때는 끄고 직접 만들어줬다. _btnScale.enabled = false; //지그재그로 흔들리는 방향을 반대로 해주기 위해 설정 switch (_card.Idx) { case 0: case 2: case 5: case 7: _dir = SHAKE_DIR.SHAKE_LEFT; break; case 1: case 3: case 4: case 6: _dir = SHAKE_DIR.SHAKE_RIGHT; break; } }
public void OnCenterCallback(GameObject centeredObject) { if (null != mLastCenterObj) { RemoveMouseClickEvent(mLastCenterObj); UIButtonScale btnScale = mLastCenterObj.GetComponent <UIButtonScale>(); GameObject.DestroyImmediate(btnScale); mLastCenterObj.transform.localScale = Vector3.one; UIPanel uiPanel = mLastCenterObj.GetComponent <UIPanel>(); uiPanel.depth = 10; } centeredObject.transform.localScale = centeredObject.transform.localScale * 1.2f; UIButtonScale btnScale1 = centeredObject.AddComponent <UIButtonScale>(); btnScale1.hover = new Vector3(1.3f, 1.3f, 1.3f); UIPanel uiPanel1 = centeredObject.GetComponent <UIPanel>(); uiPanel1.depth = 100001; mLastCenterObj = centeredObject; Transform zombieModel = centeredObject.transform.Find("Zombie"); Transform demoModel = centeredObject.transform.Find("Demo"); if (null != demoModel) { AddMouseClickEvent(centeredObject, OnDemoClicked); } Transform teamModel = centeredObject.transform.Find("Team"); }
void Start() { if (null == gameObject.GetComponent <UIButtonScale>()) { UIButtonScale buttonScale = gameObject.AddComponent <UIButtonScale>(); buttonScale.tweenTarget = gameObject; } }
public override void Awake() { base.Awake(); ButtonScale = gameObject.GetComponent <UIButtonScale>(); Button = gameObject.GetComponent <UIButton>(); ButtonScale.enabled = false; Button.enabled = false; Collider = gameObject.GetComponent <BoxCollider>(); }
public NGUIButton(GameObject obj) { rootObj = obj; rootT = rootObj.transform; button = rootObj.GetComponent <UIButton>(); scale = rootObj.GetComponent <UIButtonScale>(); label = rootObj.GetComponentInChildren <UILabel>(); sprite = rootObj.GetComponentInChildren <UISprite>(); }
protected static void SetScale(UIButtonScale scale, bool scaleEnabled, Vector3 hover, Vector3 pressed, float duration) { if (scale != null) { scale.enabled = scaleEnabled; scale.hover = hover; scale.pressed = pressed; scale.duration = duration; } }
public MatchMsgBtn(GameObject inBtn, MatchMsg inMsg) { btn = inBtn; msg = inMsg; valid = true; timeCnt = 0; m_btnScale = btn.GetComponent <UIButtonScale>(); m_btnSound = btn.GetComponent <UIPlaySound>(); }
public override void Awake() { Panel = gameObject.GetComponent <UIPanel> (); Collider = gameObject.GetComponent <BoxCollider> (); if (ButtonScale == null) { ButtonScale = gameObject.GetComponent <UIButtonScale> (); } base.Awake(); }
static public int get_duration(IntPtr l) { try { UIButtonScale self = (UIButtonScale)checkSelf(l); pushValue(l, true); pushValue(l, self.duration); return(2); } catch (Exception e) { return(error(l, e)); } }
public void OnPointerUp(PointerEventData eventData) { isPointDown = false; if (OnRelease != null) { OnRelease.Invoke(); } UIButtonScale sc = gameObject.GetComponent <UIButtonScale>(); if (sc != null) { sc.OnPress(false); } }
static public int set_pressed(IntPtr l) { try { UIButtonScale self = (UIButtonScale)checkSelf(l); UnityEngine.Vector3 v; checkType(l, 2, out v); self.pressed = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_tweenTarget(IntPtr l) { try { UIButtonScale self = (UIButtonScale)checkSelf(l); UnityEngine.Transform v; checkType(l, 2, out v); self.tweenTarget = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_duration(IntPtr l) { try { UIButtonScale self = (UIButtonScale)checkSelf(l); System.Single v; checkType(l, 2, out v); self.duration = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public void OnPointerDown(PointerEventData eventData) { if (OnPress != null) { OnPress.Invoke(); } UIButtonScale sc = gameObject.GetComponent <UIButtonScale>(); if (sc != null) { sc.OnPress(true); } isPointDown = true; lastInvokeTime = Time.time; }
public void BtnSetting() { UIButton[] btns = GetComponentsInChildren <UIButton>(true); foreach (var btn in btns) { btn.hover = Color.white; btn.pressed = Color.white; UIButtonScale btnScale = btn.GetComponent <UIButtonScale>(); if (btnScale == null) { Debug.LogError("add UIButtonScale Component For Btn=" + btn.gameObject.name); btn.gameObject.AddComponent <UIButtonScale>(); } } }
public override void OnInspectorGUI() { EditorGUIUtility.labelWidth = 100f; EditorGUILayout.Space(); UIButtonScale mScale = target as UIButtonScale; Transform tweenTarget = EditorGUILayout.ObjectField("Tween Target", mScale.tweenTarget, typeof(Transform), true) as Transform; if (mScale.tweenTarget != tweenTarget) { mScale.tweenTarget = tweenTarget; } DrawPressed(); DrawDiverge(); }
// Use this for initialization private void Awake() { for (int i = 0; i < transform.childCount; ++i) { Transform childTrans = transform.GetChild(i); if ("Title" == childTrans.tag) { _lbTitle = childTrans.GetComponent <UILabel>(); continue; } UILabel lbValue = childTrans.GetComponentInChildren <UILabel>(); lbValue.text = Random.Range(1000, 10000).ToString(); } _btnScale = GetComponent <UIButtonScale>() as UIButtonScale; _scroll = GetComponent <VertHoriScrollScript>(); }
public void OnPointerDown(PointerEventData eventData) { if (polygonCollider != null && UICamera.currentCamera != null) { if (polygonCollider.OverlapPoint(UICamera.currentCamera.ScreenToWorldPoint(eventData.position))) { if (OnPress != null) { if (ChangeColor) { Img.color = hilight; } OnPress.Invoke(); } UIButtonScale sc = gameObject.GetComponent <UIButtonScale>(); if (sc != null) { sc.OnPress(true); } isPointDown = true; lastInvokeTime = Time.time; pointDownFrame = Time.frameCount; } } else { if (OnPress != null) { if (ChangeColor) { Img.color = hilight; } OnPress.Invoke(); } UIButtonScale sc = gameObject.GetComponent <UIButtonScale>(); if (sc != null) { sc.OnPress(true); } isPointDown = true; lastInvokeTime = Time.time; pointDownFrame = Time.frameCount; } }
public static float $Get2(object instance, int index) { UIButtonScale expr_06_cp_0 = (UIButtonScale)instance; switch (index) { case 0: return(expr_06_cp_0.pressed.x); case 1: return(expr_06_cp_0.pressed.y); case 2: return(expr_06_cp_0.pressed.z); default: throw new ArgumentOutOfRangeException("index"); } }
public void OnPointerUp(PointerEventData eventData) { if (isPointDown) { isPointDown = false; if (OnRelease != null) { if (ChangeColor) { Img.color = normal; } OnRelease.Invoke(); } UIButtonScale sc = gameObject.GetComponent <UIButtonScale>(); if (sc != null) { sc.OnPress(false); } } }
public static void $Set2(object instance, float value, int index) { UIButtonScale expr_06_cp_0 = (UIButtonScale)instance; switch (index) { case 0: expr_06_cp_0.pressed.x = value; return; case 1: expr_06_cp_0.pressed.y = value; return; case 2: expr_06_cp_0.pressed.z = value; return; default: throw new ArgumentOutOfRangeException("index"); } }
public static void SetButtonEnable(this GameObject obj, bool active) { UIButton button = obj.GetComponent <UIButton>(); if (button != null) { button.enabled = active; } UIButtonScale scale = obj.GetComponent <UIButtonScale>(); if (scale != null) { scale.enabled = active; } UIButtonColor color = obj.GetComponent <UIButtonColor>(); if (color != null) { color.enabled = active; } }
void OnEnable() { if (null == CardUse) { Debug.LogError("CardUse 프리팹이 없습니다. 넣어주세요"); Debug.Assert(false); } IsSelected = false; _sprCard = GetComponent <UISprite>(); _sprCardUse = CardUse.GetComponent <UISprite>(); _btnScale = GetComponent <UIButtonScale>(); _trans = GetComponent <Transform>(); _centerOnChild = GetComponent <UICenterOnChild>(); _dragDrop = GetComponent <UIDragDropItem>(); _shakeScript = GetComponent <ShakeObjectScript>(); _moveTo = GetComponent <MoveToScript>(); Cost = Random.Range(1, 9); _sprCard.spriteName = "Card_" + Cost.ToString(); }
private void DrawPressed() { UIButtonScale mScale = target as UIButtonScale; bool showPressed = EditorGUILayout.Toggle("Show Pressed", mScale.showPressed); if (mScale.showPressed != showPressed) { mScale.showPressed = showPressed; } if (mScale.showPressed) { if (NGUIEditorTools.DrawHeader("Pressed")) { NGUIEditorTools.BeginContents(); GUILayout.BeginVertical(); GUILayout.Space(4f); Vector3 pressed = EditorGUILayout.Vector3Field("Scale", mScale.pressed); if (mScale.pressed != pressed) { mScale.pressed = pressed; } GUILayout.Space(4f); float pressedDuration = EditorGUILayout.FloatField("Duration", mScale.pressedDuration); if (mScale.pressedDuration != pressedDuration) { mScale.pressedDuration = pressedDuration; } GUILayout.Space(4f); GUILayout.EndVertical(); NGUIEditorTools.EndContents(); } } }
private void DrawDiverge() { UIButtonScale mScale = target as UIButtonScale; bool showDiverge = EditorGUILayout.Toggle("Show Diverge", mScale.showDiverge); if (mScale.showDiverge != showDiverge) { mScale.showDiverge = showDiverge; } if (mScale.showDiverge) { if (NGUIEditorTools.DrawHeader("Diverge")) { NGUIEditorTools.BeginContents(); GUILayout.BeginVertical(); GUILayout.Space(4f); Vector3 diverge = EditorGUILayout.Vector3Field("Scale", mScale.diverge); if (mScale.diverge != diverge) { mScale.diverge = diverge; } GUILayout.Space(4f); float divergeDuration = EditorGUILayout.FloatField("Duration", mScale.divergeDuration); if (mScale.divergeDuration != divergeDuration) { mScale.divergeDuration = divergeDuration; } GUILayout.Space(4f); GUILayout.EndVertical(); NGUIEditorTools.EndContents(); } } }
public override void StartBinding(GameObject gObj, string args, string layerName) { try { //需求添加,用于导出Lua识别类型 UIButton btn = LayerWordBinder.swapComponent <UIButton>(gObj); btn.enabled = false; UIButtonScale button = LayerWordBinder.swapComponent <UIButtonScale>(gObj); LayerWordBinder.swapComponent <UIEventListener>(gObj); button.pressed = Vector3.one * 0.8f; // UIButton button = LayerWordBinder.swapComponent<UIButton>(gObj); // button.pressed = Color.white; // button.hover = Color.white; UISprite imgBtn = gObj.GetComponent <UISprite>(); if (imgBtn == null) { imgBtn = LayerWordBinder.findChildComponent <UISprite>(gObj, "background", "bg"); } if (imgBtn != null) { //button.tweenTarget = imgBtn.gameObject; Vector3 originPos = imgBtn.transform.localPosition; NHelper.TransformOffset(gObj.transform, imgBtn.transform.localPosition, true); gObj.transform.localPosition = originPos; } NGUITools.AddWidgetCollider(gObj); } catch (Exception) { Debug.LogError(string.Format("[异常Button:{0}] 请检查是否存在(被隐藏)background组! ", layerName)); } }
void Awake() { buttonScale = GetComponent<UIButtonScale>(); myBorder = transform.FindChild("Border").GetComponent<UISprite>(); myCheck = transform.FindChild("Check").GetComponent<UISprite>(); }
void Start() { _sprite = GetComponent<UISprite>(); _toggle = GetComponent<UIToggle>(); _buttonScale = GetComponent<UIButtonScale>(); _boxCollider = GetComponent<BoxCollider>(); }
void Start() { if (correctPair == null) correctPair = new List<IconShadow>(); _sprite = GetComponent<UISprite>(); _toggle = GetComponent<UIToggle>(); _buttonScale = GetComponent<UIButtonScale>(); _boxCollider = GetComponent<BoxCollider>(); }
// Use this for initialization void Start() { _checkBox=gameObject.GetComponentInChildren<UICheckbox>(); _buttonScle=gameObject.GetComponentInChildren<UIButtonScale>(); _buttonSound=gameObject.GetComponentInChildren<UIButtonSound>(); }
void Start() { if (target == null) target = GetComponentInChildren<UISprite>(); _buttonScle=gameObject.GetComponentInChildren<UIButtonScale>(); _buttonSound=gameObject.GetComponentInChildren<UIButtonSound>(); }
// Use this for initialization void Start() { _buttonScale=gameObject.GetComponentInChildren<UIButtonScale>(); _buttonSound=gameObject.GetComponentInChildren<UIButtonSound>(); _sprite=gameObject.GetComponentInChildren<UISprite>(); }
void Start() { scaler = GetComponent<UIButtonScale>(); }
// Use this for initialization void Start() { //initiate all the display OnResource(); OnLife(); OnNewWave(0); OnTowerSelect(); //if a continuous mode is used, show spawn timer _SpawnMode mode=SpawnManager.GetSpawnMode(); if(mode==_SpawnMode.Continuous || mode==_SpawnMode.SkippableContinuous){ StartCoroutine(SpawnTimerRoutine()); } else{ if(labelTimer!=null) labelTimer.text=""; } //disable all the menu if(menu && menu.active) menu.SetActiveRecursively(false); if(menuGeneral && menuGeneral.active) menuGeneral.SetActiveRecursively(false); if(menuOption && menuOption.active) menuOption.SetActiveRecursively(false); //cache the UIButtonScale component on spawnButton, so we can disable it if we want to override it buttonSpawnScale=buttonSpawn.GetComponent<UIButtonScale>(); //disable tower tooltip OnTowerClearTooltip(); //generate build button is needed if(autoGenerateBuildButton) InitBuildButton(); //get the position offset of the tooltip from the first button, so this offset can be cached and applied when other button are mouse overed if(buildButtons[0]!=null) posOffsetFromButton=tooltipTower.transform.position-buildButtons[0].transform.position; //initiate sample menu, so player can preview the tower in pointNBuild buildphase if(buildMode==_BuildMode.PointNBuild && showBuildSample) BuildManager.InitiateSampleTower(); }
private void Awake () { spriteRender = GetComponent<UISprite>(); button = GetComponent<UIButtonScale>(); }