스크립트(ngui -> UI 폴더)
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class UIRepeatButton : MonoBehaviour
- {
- public float interval = 0.0001525F;
- bool mIsPressed = false;
- float mNextClick = 0f;
- void OnPress (bool isPressed) { mIsPressed = isPressed; mNextClick = Time.realtimeSinceStartup + interval; }
- void Update ()
- {
- if (mIsPressed && Time.realtimeSinceStartup > mNextClick)
- {
- mNextClick = Time.realtimeSinceStartup + interval;
- // Do what you need to do, or simply:
- //SendMessage("OnClick", SendMessageOptions.DontRequireReceiver);
- //cleaner:
- EventDelegate.Execute(onPressListeners);
- }
- }
- }
에디터 스크립트(ngui -> editer폴더)
- using UnityEngine;
- using UnityEditor;
- [CanEditMultipleObjects]
- public class UIRepeatButtonEditor : UIWidgetContainerEditor
- {
- public override void OnInspectorGUI ()
- {
- serializedObject.Update();
- UIRepeatButton button = target as UIRepeatButton;
- //this allows to more conveniently set the event handler:
- NGUIEditorTools.DrawEvents("On Repeated Press", button, button.onPressListeners);
- }
- enum Highlight
- {
- DoNothing,
- Press,
- }
- }
'TA > Unity' 카테고리의 다른 글
쉐이더 LOD(Shader Level of Detail) (0) | 2017.03.14 |
---|---|
쉐이더 포지 TRANSFORM_TEX() (0) | 2017.02.23 |
Unity 해상도 설정 (0) | 2016.12.29 |
Unity Editer 단축키 (0) | 2016.03.22 |
XML의 문법 (0) | 2016.03.22 |