Esempio n. 1
0
        public Stage()
            : base()
        {
            _inst       = this;
            soundVolume = 1;

            _updateContext     = new UpdateContext();
            stageWidth         = Screen.width;
            stageHeight        = Screen.height;
            _frameGotHitTarget = -1;

            touchScreen = Input.touchSupported;

            _touches = new TouchInfo[5];
            for (int i = 0; i < _touches.Length; i++)
            {
                _touches[i] = new TouchInfo();
            }

            if (!touchScreen)
            {
                _touches[0].touchId = 0;
            }

            _rollOutChain  = new List <DisplayObject>();
            _rollOverChain = new List <DisplayObject>();

            onStageResized = new EventListener(this, "onStageResized");
            onTouchMove    = new EventListener(this, "onTouchMove");

            StageEngine engine = GameObject.FindObjectOfType <StageEngine>();

            if (engine != null)
            {
                this.gameObject = engine.gameObject;
            }
            else
            {
                int layer = LayerMask.NameToLayer(StageCamera.LayerName);

                this.gameObject           = new GameObject("Stage");
                this.gameObject.hideFlags = HideFlags.None;
                this.gameObject.layer     = layer;
                this.gameObject.AddComponent <StageEngine>();
                this.gameObject.AddComponent <UIContentScaler>();
            }
            this.cachedTransform            = gameObject.transform;
            this.cachedTransform.localScale = new Vector3(StageCamera.UnitsPerPixel, StageCamera.UnitsPerPixel, StageCamera.UnitsPerPixel);
            this.gameObject.SetActive(true);
            UnityEngine.Object.DontDestroyOnLoad(this.gameObject);

            EnableSound();

            inputCaret  = new InputCaret();
            highlighter = new Highlighter();
        }
		void __focusOut(EventContext contxt)
		{
			if (_mobileInputAdapter != null)
			{
				_mobileInputAdapter.CloseKeyboard();
			}

			if (_caret != null)
			{
				_caret.SetParent(null);
				_caret = null;
				_highlighter.SetParent(null);
				_highlighter = null;
			}
		}
		void __focusIn(EventContext context)
		{
			if (_mobileInputAdapter != null)
			{
				OpenKeyboard();
			}
			else
			{
				_caret = Stage.inst.inputCaret;
				_caret.grahpics.sortingOrder = this.renderingOrder + 1;
				_caret.SetParent(cachedTransform);
				_caret.SetSizeAndColor(_textFormat.size, _textFormat.color);

				_highlighter = Stage.inst.highlighter;
				_highlighter.grahpics.sortingOrder = this.renderingOrder + 2;
				_highlighter.SetParent(cachedTransform);

				_caretPosition = _text.Length;
				CharPosition cp = GetCharPosition(_caretPosition);
				AdjustCaret(cp);
				_selectionStart = cp;
			}
		}
Esempio n. 4
0
		void __focusOut(EventContext contxt)
		{
			if (_mobileInputAdapter != null)
			{
				_mobileInputAdapter.CloseKeyboard();
			}

			if (_caret != null)
			{
				_caret.SetParent(null);
				_caret = null;
				_highlighter.SetParent(null);
				_highlighter = null;
				onKeyDown.RemoveCapture(__keydown);
				onTouchBegin.RemoveCapture(__touchBegin);
			}
		}
Esempio n. 5
0
		void __focusIn(EventContext context)
		{
			if (_input)
			{
				if (_mobileInputAdapter != null)
				{
					OpenKeyboard();
				}
				else
				{
					_caret = Stage.inst.inputCaret;
					_caret.grahpics.sortingOrder = this.renderingOrder + 1;
					_caret.SetParent(cachedTransform);
					_caret.SetSizeAndColor(_textFormat.size, _textFormat.color);

					_highlighter = Stage.inst.highlighter;
					_highlighter.grahpics.sortingOrder = this.renderingOrder + 2;
					_highlighter.SetParent(cachedTransform);

					onKeyDown.AddCapture(__keydown);
					onTouchBegin.AddCapture(__touchBegin);
				}
			}
		}
Esempio n. 6
0
        void __focusIn(EventContext context)
        {
            if (_input)
            {
                if (_mobileInputAdapter != null)
                {
                    OpenKeyboard();
                    onMouseDown.AddCapture(__mouseDown2);
                }
                else
                {
                    _caret = Stage.inst.inputCaret;
                    _caret.SetParent(cachedTransform);
                    _caret.SetSizeAndColor(Mathf.FloorToInt(_textFormat.size * _fontScale), _textFormat.color);

                    _highlighter = Stage.inst.highlighter;
                    _highlighter.SetParent(cachedTransform);

                    onKeyDown.AddCapture(__keydown);
                    onMouseDown.AddCapture(__mouseDown);
                }
            }
        }
Esempio n. 7
0
        public Stage(int layer, int cameraDepth)
            : base()
        {
            inst = this;
            defaultLayer = layer;
            soundVolume = 1;

            _updateContext = new UpdateContext();
            stageWidth = Screen.width;
            stageHeight = Screen.height;

            gameObject.name = "Stage";
            gameObject.hideFlags = HideFlags.None;
            gameObject.SetActive(true);
            _engine = gameObject.AddComponent<StageEngine>();
            Object.DontDestroyOnLoad(gameObject);

            _cameraObject = new GameObject("Camera");
            _cameraObject.hideFlags = HideFlags.None;
            _cameraObject.layer = defaultLayer;
            Object.DontDestroyOnLoad(_cameraObject);

            camera = _cameraObject.AddComponent<Camera>();
            camera.nearClipPlane = -8;
            camera.farClipPlane = 1;
            camera.depth = cameraDepth;
            camera.cullingMask = 1 << defaultLayer;
            camera.clearFlags = CameraClearFlags.Depth;
            camera.orthographic = true;
            camera.orthographicSize = 1;
            camera.transform.parent = cachedTransform;

            _halfPixelOffset = (Application.platform == RuntimePlatform.WindowsPlayer ||
                Application.platform == RuntimePlatform.XBOX360 ||
                Application.platform == RuntimePlatform.WindowsWebPlayer ||
                Application.platform == RuntimePlatform.WindowsEditor);

            // Only DirectX 9 needs the half-pixel offset
            if (_halfPixelOffset)
                _halfPixelOffset = (SystemInfo.graphicsShaderLevel < 40);

            if (Application.platform == RuntimePlatform.IPhonePlayer
                || Application.platform == RuntimePlatform.Android
                || Application.platform == RuntimePlatform.WP8Player)
                touchScreen = true;

            AdjustCamera();
            EnableSound();

            inputCaret = new InputCaret();
            highlighter = new Highlighter();

            _touches = new TouchInfo[5];
            for (int i = 0; i < _touches.Length; i++)
                _touches[i] = new TouchInfo();

            if (!touchScreen)
                _touches[0].touchId = 0;

            _rollOutChain = new List<DisplayObject>();
            _rollOverChain = new List<DisplayObject>();

            onStageResized = new EventListener(this, "onStageResized");
            onMouseMove = new EventListener(this, "onMouseMove");
            onPostUpdate = new EventListener(this, "onPostUpdate");
        }
Esempio n. 8
0
        public Stage()
            : base()
        {
            _inst       = this;
            soundVolume = 1;

            _updateContext     = new UpdateContext();
            stageWidth         = Screen.width;
            stageHeight        = Screen.height;
            _frameGotHitTarget = -1;

            touchScreen = Input.touchSupported;

            _touches = new TouchInfo[5];
            for (int i = 0; i < _touches.Length; i++)
            {
                _touches[i] = new TouchInfo();
            }

            if (!touchScreen)
            {
                _touches[0].touchId = 0;
            }

            _rollOutChain  = new List <DisplayObject>();
            _rollOverChain = new List <DisplayObject>();

            onStageResized = new EventListener(this, "onStageResized");
            onTouchMove    = new EventListener(this, "onTouchMove");
            onCopy         = new EventListener(this, "onCopy");
            onPaste        = new EventListener(this, "onPaste");

            StageEngine engine = GameObject.FindObjectOfType <StageEngine>();

            if (engine != null)
            {
                this.gameObject = engine.gameObject;
            }
            else
            {
                int layer = LayerMask.NameToLayer(StageCamera.LayerName);

                this.gameObject           = new GameObject("Stage");
                this.gameObject.hideFlags = HideFlags.None;
                this.gameObject.layer     = layer;
                this.gameObject.AddComponent <StageEngine>();
                this.gameObject.AddComponent <UIContentScaler>();
            }
            this.cachedTransform            = gameObject.transform;
            this.cachedTransform.localScale = new Vector3(StageCamera.UnitsPerPixel, StageCamera.UnitsPerPixel, StageCamera.UnitsPerPixel);
            this.gameObject.SetActive(true);
            UnityEngine.Object.DontDestroyOnLoad(this.gameObject);

            EnableSound();

            inputCaret  = new InputCaret();
            highlighter = new Highlighter();

            Timers.inst.Add(5, 0, RunTextureCollector);

#if UNITY_WEBPLAYER || UNITY_WEBGL || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR
            CopyPastePatch.Apply();
#endif

#if UNITY_5_4_OR_NEWER
            SceneManager.sceneLoaded += SceneManager_sceneLoaded;
#endif
        }
Esempio n. 9
0
        public Stage()
            : base()
        {
            _inst = this;
            soundVolume = 1;

            _updateContext = new UpdateContext();
            stageWidth = Screen.width;
            stageHeight = Screen.height;
            _frameGotHitTarget = -1;

            touchScreen = Input.touchSupported;

            _touches = new TouchInfo[5];
            for (int i = 0; i < _touches.Length; i++)
                _touches[i] = new TouchInfo();

            if (!touchScreen)
                _touches[0].touchId = 0;

            _rollOutChain = new List<DisplayObject>();
            _rollOverChain = new List<DisplayObject>();

            onStageResized = new EventListener(this, "onStageResized");
            onTouchMove = new EventListener(this, "onTouchMove");
            onCopy = new EventListener(this, "onCopy");
            onPaste = new EventListener(this, "onPaste");

            StageEngine engine = GameObject.FindObjectOfType<StageEngine>();
            if (engine != null)
                this.gameObject = engine.gameObject;
            else
            {
                int layer = LayerMask.NameToLayer(StageCamera.LayerName);

                this.gameObject = new GameObject("Stage");
                this.gameObject.hideFlags = HideFlags.None;
                this.gameObject.layer = layer;
                this.gameObject.AddComponent<StageEngine>();
                this.gameObject.AddComponent<UIContentScaler>();
            }
            this.cachedTransform = gameObject.transform;
            this.cachedTransform.localScale = new Vector3(StageCamera.UnitsPerPixel, StageCamera.UnitsPerPixel, StageCamera.UnitsPerPixel);
            this.gameObject.SetActive(true);
            UnityEngine.Object.DontDestroyOnLoad(this.gameObject);

            EnableSound();

            inputCaret = new InputCaret();
            highlighter = new Highlighter();

            Timers.inst.Add(5, 0, RunTextureCollector);

            #if UNITY_WEBPLAYER || UNITY_WEBGL || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR
            CopyPastePatch.Apply();
            #endif
        }
Esempio n. 10
0
        public Stage(int layer, int cameraDepth)
            : base()
        {
            inst         = this;
            defaultLayer = layer;
            soundVolume  = 1;

            _updateContext = new UpdateContext();
            stageWidth     = Screen.width;
            stageHeight    = Screen.height;

            gameObject.name      = "Stage";
            gameObject.hideFlags = HideFlags.None;
            gameObject.SetActive(true);
            _engine = gameObject.AddComponent <StageEngine>();
            Object.DontDestroyOnLoad(gameObject);

            _cameraObject           = new GameObject("Camera");
            _cameraObject.hideFlags = HideFlags.None;
            _cameraObject.layer     = defaultLayer;
            Object.DontDestroyOnLoad(_cameraObject);

            camera = _cameraObject.AddComponent <Camera>();
            camera.nearClipPlane    = -8;
            camera.farClipPlane     = 1;
            camera.depth            = cameraDepth;
            camera.cullingMask      = 1 << defaultLayer;
            camera.clearFlags       = CameraClearFlags.Depth;
            camera.orthographic     = true;
            camera.orthographicSize = 1;
            camera.transform.parent = cachedTransform;

            _halfPixelOffset = (Application.platform == RuntimePlatform.WindowsPlayer ||
                                Application.platform == RuntimePlatform.XBOX360 ||
                                Application.platform == RuntimePlatform.WindowsWebPlayer ||
                                Application.platform == RuntimePlatform.WindowsEditor);

            // Only DirectX 9 needs the half-pixel offset
            if (_halfPixelOffset)
            {
                _halfPixelOffset = (SystemInfo.graphicsShaderLevel < 40);
            }

            if (Application.platform == RuntimePlatform.IPhonePlayer ||
                Application.platform == RuntimePlatform.Android ||
                Application.platform == RuntimePlatform.WP8Player)
            {
                touchScreen = true;
            }

            AdjustCamera();
            EnableSound();

            inputCaret  = new InputCaret();
            highlighter = new Highlighter();

            _touches = new TouchInfo[5];
            for (int i = 0; i < _touches.Length; i++)
            {
                _touches[i] = new TouchInfo();
            }

            if (!touchScreen)
            {
                _touches[0].touchId = 0;
            }

            _rollOutChain  = new List <DisplayObject>();
            _rollOverChain = new List <DisplayObject>();

            onStageResized = new EventListener(this, "onStageResized");
            onMouseMove    = new EventListener(this, "onMouseMove");
            onPostUpdate   = new EventListener(this, "onPostUpdate");
        }