From 85b64acac70799f973512e5e1f19f23a72db7c0a Mon Sep 17 00:00:00 2001 From: WreckCenter Date: Tue, 15 May 2012 08:42:44 -0600 Subject: [PATCH 1/3] added text instance lists to buttons and Containers added hiding/showing to children added infinite loop for animations added constructor to bgcontainer to take a size made background sprite public for adding children added constructors to horiz/vert layouts to take toolkit argument removed onTouchEnded from onTouchMoved of scrollable containers (prevents touch from passing through and causing bugs) fixed constructor errors (can't set default values...although i think was fixed in lastest drop too) commented hd setting for editor and added UNITY_ANDROID to allow compilation on unity --- .../BaseElements/UIAbstractContainer.cs | 12 ++++++++++ .../UIAbstractTouchableContainer.cs | 21 +++++++++++++++- .../UIToolkit/BaseElements/UIObject.cs | 2 +- .../UIToolkit/BaseElements/UISprite.cs | 24 ++++++++++++++++--- .../BaseElements/UISpriteAnimation.cs | 7 ++++-- .../UIToolkit/BaseElements/UISpriteManager.cs | 2 +- .../Containers/UIBackgroundLayout.cs | 13 +++++++++- .../UIScrollableHorizontalLayout.cs | 6 ++++- .../Containers/UIScrollableVerticalLayout.cs | 6 ++++- Assets/Plugins/UIToolkit/UI.cs | 23 +++++++++--------- 10 files changed, 94 insertions(+), 22 deletions(-) diff --git a/Assets/Plugins/UIToolkit/BaseElements/UIAbstractContainer.cs b/Assets/Plugins/UIToolkit/BaseElements/UIAbstractContainer.cs index 6abb981..91b80c0 100644 --- a/Assets/Plugins/UIToolkit/BaseElements/UIAbstractContainer.cs +++ b/Assets/Plugins/UIToolkit/BaseElements/UIAbstractContainer.cs @@ -26,6 +26,7 @@ public enum UILayoutType { Horizontal, Vertical, BackgroundLayout, AbsoluteLayou protected float _scrollPosition; // scroll position calculated from the top (vertical) or left (horizontal) protected List _children = new List(); + protected List _textChildren = new List(); protected bool _suspendUpdates; // when true, layoutChildren will do nothing @@ -49,6 +50,8 @@ public virtual bool hidden // apply state to the children foreach( var child in _children ) child.hidden = value; + foreach( var child in _textChildren ) + child.hidden = value; } } @@ -86,7 +89,16 @@ public virtual void addChild( params UISprite[] children ) layoutChildren(); } + public virtual void addText( params UITextInstance[] children ) + { + foreach( var child in children ) + { + //child.parentUIObject = this; + _textChildren.Add( child ); + } + //layoutChildren(); + } /// /// Removes a child from the container and optionally from it's manager. If it is removed from diff --git a/Assets/Plugins/UIToolkit/BaseElements/UIAbstractTouchableContainer.cs b/Assets/Plugins/UIToolkit/BaseElements/UIAbstractTouchableContainer.cs index 2d0670f..4fc245a 100644 --- a/Assets/Plugins/UIToolkit/BaseElements/UIAbstractTouchableContainer.cs +++ b/Assets/Plugins/UIToolkit/BaseElements/UIAbstractTouchableContainer.cs @@ -33,6 +33,17 @@ public abstract class UIAbstractTouchableContainer : UIAbstractContainer, ITouch public bool pagingEnabled; // enables paging support which will snap scrolling. page size is the container width + //private bool __hidden = false; + public virtual bool _hidden + { + get { return base.hidden; } + set + { + base.hidden=value; + _velocities.Clear(); + } + } + public override float width { get { return _touchFrame.width; } @@ -407,7 +418,12 @@ public virtual void onTouchBegan( Touch touch, Vector2 touchPos ) public virtual void onTouchMoved( Touch touch, Vector2 touchPos ) { - + if( _activeTouchable != null ) + { + // we dont pass onTouchEnded here because technically we are still over the ITouchable + _activeTouchable.highlighted = false; + _activeTouchable = null; + } } @@ -488,7 +504,10 @@ public override void addChild( params UISprite[] children ) foreach( var child in children ) { if( child is ITouchable ) + { _manager.removeFromTouchables( child as ITouchable ); + //child.manager.removeFromTouchables(child as ITouchable ); + } } } diff --git a/Assets/Plugins/UIToolkit/BaseElements/UIObject.cs b/Assets/Plugins/UIToolkit/BaseElements/UIObject.cs index 7b3989c..b3b1ba6 100644 --- a/Assets/Plugins/UIToolkit/BaseElements/UIObject.cs +++ b/Assets/Plugins/UIToolkit/BaseElements/UIObject.cs @@ -16,7 +16,7 @@ public GameObject client private UIObject _parentUIObject; public virtual Color color { get; set; } // hack that is overridden in UISprite just for animation support protected UIAnchorInfo _anchorInfo; - public bool autoRefreshPositionOnScaling = true; + public bool autoRefreshPositionOnScaling = false; //true; protected float _width, _height; /// diff --git a/Assets/Plugins/UIToolkit/BaseElements/UISprite.cs b/Assets/Plugins/UIToolkit/BaseElements/UISprite.cs index 217f1ee..e5014a0 100644 --- a/Assets/Plugins/UIToolkit/BaseElements/UISprite.cs +++ b/Assets/Plugins/UIToolkit/BaseElements/UISprite.cs @@ -36,11 +36,11 @@ public class UISprite : UIObject, IPositionable protected Vector3[] meshVerts; // Pointer to the array of vertices in the mesh protected Vector2[] uvs; // Pointer to the array of UVs in the mesh protected Dictionary spriteAnimations; - + + protected List _children = new List(); public UISprite(){} - - + public UISprite( Rect frame, int depth, UIUVRect uvFrame ) : this( frame, depth, uvFrame, false ) {} @@ -131,6 +131,10 @@ public virtual bool hidden manager.hideSprite( this ); else manager.showSprite( this ); + + // apply state to the children + foreach( var child in _children ) + child.hidden = value; } } @@ -388,9 +392,23 @@ public override Color color // Removes the sprite from the mesh and destroys it's client GO public virtual void destroy() { + foreach( var child in _children ) + { + child.destroy(); + } manager.removeElement( this ); } + public virtual void addText( params UITextInstance[] children ) + { + foreach( var child in children ) + { + //child.parentUIObject = this; + _children.Add( child ); + } + + //layoutChildren(); + } #region Sprite Animation methods diff --git a/Assets/Plugins/UIToolkit/BaseElements/UISpriteAnimation.cs b/Assets/Plugins/UIToolkit/BaseElements/UISpriteAnimation.cs index b35edd4..1a007bd 100644 --- a/Assets/Plugins/UIToolkit/BaseElements/UISpriteAnimation.cs +++ b/Assets/Plugins/UIToolkit/BaseElements/UISpriteAnimation.cs @@ -33,7 +33,7 @@ public IEnumerator play( UISprite sprite, int loopCount ) _isPlaying = true; // loop while we are playing and we havent finished looping - while( _isPlaying && loopCount >= 0 ) + while( _isPlaying && (loopCount > 0 || loopCount==-1)) { // what frame are we on? if( loopingForward ) @@ -45,7 +45,10 @@ public IEnumerator play( UISprite sprite, int loopCount ) if( currentFrame < 0 || currentFrame == totalFrames ) { // finished a loop, increment loop counter, reverse loop direction if necessary and reset currentFrame - --loopCount; + if (loopCount>0) + { + --loopCount; + } if( loopReverse ) loopingForward = !loopingForward; diff --git a/Assets/Plugins/UIToolkit/BaseElements/UISpriteManager.cs b/Assets/Plugins/UIToolkit/BaseElements/UISpriteManager.cs index 8db5f94..c98d967 100644 --- a/Assets/Plugins/UIToolkit/BaseElements/UISpriteManager.cs +++ b/Assets/Plugins/UIToolkit/BaseElements/UISpriteManager.cs @@ -362,7 +362,7 @@ public UISprite addSprite(string name, int xPos, int yPos, int depth, bool gameO /// /// Shortcut for adding a new sprite using the raw materials /// - private UISprite addSprite(Rect frame, UIUVRect uvFrame, int depth, bool gameObjectOriginInCenter) + public UISprite addSprite(Rect frame, UIUVRect uvFrame, int depth, bool gameObjectOriginInCenter) { // Create and initialize the new sprite UISprite newSprite = new UISprite(frame, depth, uvFrame, gameObjectOriginInCenter); diff --git a/Assets/Plugins/UIToolkit/Containers/UIBackgroundLayout.cs b/Assets/Plugins/UIToolkit/Containers/UIBackgroundLayout.cs index 5cf1f6b..a2fbe71 100755 --- a/Assets/Plugins/UIToolkit/Containers/UIBackgroundLayout.cs +++ b/Assets/Plugins/UIToolkit/Containers/UIBackgroundLayout.cs @@ -5,16 +5,27 @@ public class UIBackgroundLayout : UIAbstractContainer { + public UISprite background; public UIBackgroundLayout( string filename ) : this( UI.firstToolkit, filename ) {} public UIBackgroundLayout( UIToolkit manager, string filename ) : base( UILayoutType.BackgroundLayout ) { - var background = manager.addSprite( filename, 0, 0, 2 ); + background = manager.addSprite( filename, 0, 0, 2 ); addChild( background ); //set dimensions of container based on background texture dimensions _width = background.width; _height = background.height; } + + public UIBackgroundLayout(UIToolkit manager, string filename, Rect frame) : base(UILayoutType.BackgroundLayout) + { + background = manager.addSprite(frame,UIUVRect.zero,2,false); + background.setSpriteImage(filename); + addChild(background); + + _width = background.width; + _height = background.height; + } } diff --git a/Assets/Plugins/UIToolkit/Containers/UIScrollableHorizontalLayout.cs b/Assets/Plugins/UIToolkit/Containers/UIScrollableHorizontalLayout.cs index 8dd00f8..d97d926 100644 --- a/Assets/Plugins/UIToolkit/Containers/UIScrollableHorizontalLayout.cs +++ b/Assets/Plugins/UIToolkit/Containers/UIScrollableHorizontalLayout.cs @@ -8,6 +8,8 @@ public class UIScrollableHorizontalLayout : UIAbstractTouchableContainer { public UIScrollableHorizontalLayout( int spacing ) : base( UILayoutType.Horizontal, spacing ) {} + public UIScrollableHorizontalLayout( UIToolkit manager, int spacing ) : base(manager, UILayoutType.Horizontal, spacing ) + {} protected override void clipChild( UISprite child ) @@ -70,7 +72,9 @@ public override void onTouchMoved( Touch touch, Vector2 touchPos ) // once we move too far unhighlight and stop tracking the touchable if( _activeTouchable != null && Mathf.Abs( _deltaTouch ) > TOUCH_MAX_DELTA_FOR_ACTIVATION ) { - _activeTouchable.onTouchEnded( touch, touchPos, true ); + //this is broken and passes a touch through to the scrollable item even if scrolling + //_activeTouchable.onTouchEnded( touch, touchPos, true ); + _activeTouchable.highlighted = false; _activeTouchable = null; } diff --git a/Assets/Plugins/UIToolkit/Containers/UIScrollableVerticalLayout.cs b/Assets/Plugins/UIToolkit/Containers/UIScrollableVerticalLayout.cs index 9344718..7b1aac2 100644 --- a/Assets/Plugins/UIToolkit/Containers/UIScrollableVerticalLayout.cs +++ b/Assets/Plugins/UIToolkit/Containers/UIScrollableVerticalLayout.cs @@ -9,6 +9,9 @@ public class UIScrollableVerticalLayout : UIAbstractTouchableContainer public UIScrollableVerticalLayout( int spacing ) : base( UILayoutType.Vertical, spacing ) {} + //add constructor so we can specify manager + public UIScrollableVerticalLayout( UIToolkit manager, int spacing ) : base( manager, UILayoutType.Vertical, spacing ) + {} protected override void clipChild( UISprite child ) { @@ -71,7 +74,8 @@ public override void onTouchMoved( Touch touch, Vector2 touchPos ) // once we move too far unhighlight and stop tracking the touchable if( _activeTouchable != null && Mathf.Abs( _deltaTouch ) > TOUCH_MAX_DELTA_FOR_ACTIVATION ) { - _activeTouchable.onTouchEnded( touch, touchPos, true ); + //_activeTouchable.onTouchEnded( touch, touchPos, true ); + _activeTouchable.highlighted = false; _activeTouchable = null; } diff --git a/Assets/Plugins/UIToolkit/UI.cs b/Assets/Plugins/UIToolkit/UI.cs index 01a8d9b..a92a65d 100644 --- a/Assets/Plugins/UIToolkit/UI.cs +++ b/Assets/Plugins/UIToolkit/UI.cs @@ -75,23 +75,24 @@ private void Awake() // setup the HD flag // handle texture loading if required -#if UNITY_EDITOR || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_WEBPLAYER + #if UNITY_EDITOR || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_WEBPLAYER || UNITY_ANDROID var deviceAllowsHD = true; -#else + #else var deviceAllowsHD = ( allowPod4GenHD && iPhone.generation == iPhoneGeneration.iPodTouch4Gen ) || iPhone.generation != iPhoneGeneration.iPodTouch4Gen; -#endif + #endif if( autoTextureSelectionForHD && deviceAllowsHD ) { // are we laoding up a 2x texture? -#if UNITY_EDITOR - if( Screen.width >= 500 || Screen.height >= 500 ) // for easier testing in the editor -#else + //plw comment out the editor test...wondered why it wasnt working + //#if UNITY_EDITOR + // if( Screen.width >= 500 || Screen.height >= 500 ) // for easier testing in the editor + //#else if( Screen.width >= maxWidthOrHeightForSD || Screen.height >= maxWidthOrHeightForSD ) -#endif + //#endif { -#if UNITY_EDITOR + #if UNITY_EDITOR Debug.Log( "switching to 2x GUI texture" ); -#endif + #endif isHD = true; scaleFactor = 2; } @@ -100,10 +101,10 @@ private void Awake() // grab all our child UIToolkits _toolkitInstances = GetComponentsInChildren(); firstToolkit = _toolkitInstances[0]; -#if UNITY_EDITOR + #if UNITY_EDITOR if( _toolkitInstances.Length == 0 ) throw new System.Exception( "Could not find any UIToolkit instances in children of UI" ); -#endif + #endif // kick off the loading of texture for any UIToolkits we have foreach( var toolkit in _toolkitInstances ) From f1d003318cc41bfea901290c6bc35fc8b6ea5a45 Mon Sep 17 00:00:00 2001 From: WreckCenter Date: Wed, 16 May 2012 14:33:14 -0600 Subject: [PATCH 2/3] removed default values for variables in constructors (not supported) --- .../UIToolkit/Support/UIObjectAnimationExtensions.cs | 6 +++--- Assets/Plugins/UIToolkit/UIAnimation/UIAnimation.cs | 6 +++--- Assets/Plugins/UIToolkit/UIElements/UISlider.cs | 4 ++-- Assets/Plugins/UIToolkit/UIElements/UIZoomButton.cs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Assets/Plugins/UIToolkit/Support/UIObjectAnimationExtensions.cs b/Assets/Plugins/UIToolkit/Support/UIObjectAnimationExtensions.cs index 4b440f0..6a1a593 100644 --- a/Assets/Plugins/UIToolkit/Support/UIObjectAnimationExtensions.cs +++ b/Assets/Plugins/UIToolkit/Support/UIObjectAnimationExtensions.cs @@ -197,7 +197,7 @@ private static UIAnimation animate( UIObject sprite, bool animateTo, float durat // Sets up and starts a new animation in a Coroutine - float version private static UIAnimation animate( UIObject sprite, float duration, UIAnimationProperty aniProperty, float start, float target, UIEaseType ease ) { - UIAnimation ani = new UIAnimation( sprite, duration, aniProperty, start, target, ease ); + UIAnimation ani = new UIAnimation( sprite, duration, aniProperty, start, target, ease, true ); UI.instance.StartCoroutine( ani.animate() ); return ani; @@ -222,7 +222,7 @@ private static UIAnimation animate( UIObject sprite, bool animateTo, float durat // Sets up and starts a new animation in a Coroutine - Color version private static UIAnimation animate( UIObject sprite, float duration, UIAnimationProperty aniProperty, Color start, Color target, UIEaseType ease ) { - UIAnimation ani = new UIAnimation( sprite, duration, aniProperty, start, target, ease ); + UIAnimation ani = new UIAnimation( sprite, duration, aniProperty, start, target, ease, true ); UI.instance.StartCoroutine( ani.animate() ); return ani; @@ -261,7 +261,7 @@ private static UIAnimation animate( UIObject sprite, bool animateTo, float durat // Sets up and starts a new animation in a Coroutine - Vector3 version private static UIAnimation animate( UIObject sprite, float duration, UIAnimationProperty aniProperty, Vector3 start, Vector3 target, UIEaseType ease ) { - var ani = new UIAnimation( sprite, duration, aniProperty, start, target, ease ); + var ani = new UIAnimation( sprite, duration, aniProperty, start, target, ease, true ); UI.instance.StartCoroutine( ani.animate() ); return ani; diff --git a/Assets/Plugins/UIToolkit/UIAnimation/UIAnimation.cs b/Assets/Plugins/UIToolkit/UIAnimation/UIAnimation.cs index 2ebc46c..29d7181 100644 --- a/Assets/Plugins/UIToolkit/UIAnimation/UIAnimation.cs +++ b/Assets/Plugins/UIToolkit/UIAnimation/UIAnimation.cs @@ -36,7 +36,7 @@ public class UIAnimation private Color targetColor; - public UIAnimation(UIObject sprite, float duration, UIAnimationProperty aniProperty, Vector3 start, Vector3 target, System.Func ease, bool affectedByTimeScale = true) + public UIAnimation(UIObject sprite, float duration, UIAnimationProperty aniProperty, Vector3 start, Vector3 target, System.Func ease, bool affectedByTimeScale) { this.sprite = sprite; this.duration = duration; @@ -51,7 +51,7 @@ public UIAnimation(UIObject sprite, float duration, UIAnimationProperty aniPrope } - public UIAnimation(UIObject sprite, float duration, UIAnimationProperty aniProperty, float startFloat, float targetFloat, System.Func ease, bool affectedByTimeScale = true) + public UIAnimation(UIObject sprite, float duration, UIAnimationProperty aniProperty, float startFloat, float targetFloat, System.Func ease, bool affectedByTimeScale) { this.sprite = sprite; this.duration = duration; @@ -66,7 +66,7 @@ public UIAnimation(UIObject sprite, float duration, UIAnimationProperty aniPrope } - public UIAnimation(UIObject sprite, float duration, UIAnimationProperty aniProperty, Color startColor, Color targetColor, System.Func ease, bool affectedByTimeScale = true) + public UIAnimation(UIObject sprite, float duration, UIAnimationProperty aniProperty, Color startColor, Color targetColor, System.Func ease, bool affectedByTimeScale) { this.sprite = sprite; this.duration = duration; diff --git a/Assets/Plugins/UIToolkit/UIElements/UISlider.cs b/Assets/Plugins/UIToolkit/UIElements/UISlider.cs index ad54c5e..e629be4 100644 --- a/Assets/Plugins/UIToolkit/UIElements/UISlider.cs +++ b/Assets/Plugins/UIToolkit/UIElements/UISlider.cs @@ -19,13 +19,13 @@ public class UISlider : UITouchableSprite // The knobs x/y coordinates should be relative to the tracks and it is measured from the center of the knob - public static UISlider create( string knobFilename, string trackFilename, int trackxPos, int trackyPos, UISliderLayout layout, int depth = 2, bool knobInFront = true ) + public static UISlider create( string knobFilename, string trackFilename, int trackxPos, int trackyPos, UISliderLayout layout, int depth, bool knobInFront ) { return create( UI.firstToolkit, knobFilename, trackFilename, trackxPos, trackyPos, layout, depth, knobInFront ); } - public static UISlider create( UIToolkit manager, string knobFilename, string trackFilename, int trackxPos, int trackyPos, UISliderLayout layout, int depth = 2, bool knobInFront = true ) + public static UISlider create( UIToolkit manager, string knobFilename, string trackFilename, int trackxPos, int trackyPos, UISliderLayout layout, int depth, bool knobInFront ) { // create the track first so we can use its dimensions to position the knob var trackTI = manager.textureInfoForFilename( trackFilename ); diff --git a/Assets/Plugins/UIToolkit/UIElements/UIZoomButton.cs b/Assets/Plugins/UIToolkit/UIElements/UIZoomButton.cs index 95e6a5a..bd8e72b 100644 --- a/Assets/Plugins/UIToolkit/UIElements/UIZoomButton.cs +++ b/Assets/Plugins/UIToolkit/UIElements/UIZoomButton.cs @@ -60,8 +60,8 @@ public UIZoomButton( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, { centerize(); autoRefreshPositionOnScaling = false; - _zoomInAnimation = new UIAnimation( this, 0.3f, UIAnimationProperty.Scale, new Vector3( 1, 1, 1 ), new Vector3( 1.3f, 1.3f, 1.3f ), Easing.Quartic.easeInOut ); - _zoomOutAnimation = new UIAnimation( this, 0.3f, UIAnimationProperty.Scale, new Vector3( 1.3f, 1.3f, 1.3f ), new Vector3( 1, 1, 1 ), Easing.Quartic.easeInOut ); + _zoomInAnimation = new UIAnimation( this, 0.3f, UIAnimationProperty.Scale, new Vector3( 1, 1, 1 ), new Vector3( 1.3f, 1.3f, 1.3f ), Easing.Quartic.easeInOut, true ); + _zoomOutAnimation = new UIAnimation( this, 0.3f, UIAnimationProperty.Scale, new Vector3( 1.3f, 1.3f, 1.3f ), new Vector3( 1, 1, 1 ), Easing.Quartic.easeInOut, true ); } #endregion; From 6809d3374174ba6a1545dc91c3287758baa896ee Mon Sep 17 00:00:00 2001 From: WreckCenter Date: Fri, 18 May 2012 10:47:51 -0600 Subject: [PATCH 3/3] added inFocus variables for uibuttons, itouchables and uiabstractcontainers this allows a "popup" to be ontop of another menu, but turn off the other menu's input (it's out of focus) --- .../UIToolkit/BaseElements/ITouchable.cs | 1 + .../BaseElements/UIAbstractContainer.cs | 24 +++++++++++++++++++ .../UIAbstractTouchableContainer.cs | 5 ++++ .../UIToolkit/BaseElements/UIObject.cs | 3 +-- .../UIToolkit/BaseElements/UISprite.cs | 13 ++++++++++ Assets/Plugins/UIToolkit/UIToolkit.cs | 2 +- 6 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Assets/Plugins/UIToolkit/BaseElements/ITouchable.cs b/Assets/Plugins/UIToolkit/BaseElements/ITouchable.cs index 2bed264..bd90184 100644 --- a/Assets/Plugins/UIToolkit/BaseElements/ITouchable.cs +++ b/Assets/Plugins/UIToolkit/BaseElements/ITouchable.cs @@ -9,6 +9,7 @@ public interface ITouchable #endif bool highlighted { get; set; } bool hidden { get; set; } + bool inFocus { get; set; } Rect touchFrame { get; } Vector3 position { get; set; } diff --git a/Assets/Plugins/UIToolkit/BaseElements/UIAbstractContainer.cs b/Assets/Plugins/UIToolkit/BaseElements/UIAbstractContainer.cs index 91b80c0..0398040 100644 --- a/Assets/Plugins/UIToolkit/BaseElements/UIAbstractContainer.cs +++ b/Assets/Plugins/UIToolkit/BaseElements/UIAbstractContainer.cs @@ -55,6 +55,30 @@ public virtual bool hidden } } + /// + /// leaves the container and all its children visible + /// but removes focus (so a popup can be on top and take input) + /// + private bool _inFocus=true; + public bool inFocus + { + get + { + return(_inFocus); + } + set + { + if (value==_inFocus) + { + return; + } + _inFocus=value; + foreach (var child in _children) + { + child.inFocus=value; + } + } + } /// diff --git a/Assets/Plugins/UIToolkit/BaseElements/UIAbstractTouchableContainer.cs b/Assets/Plugins/UIToolkit/BaseElements/UIAbstractTouchableContainer.cs index 4fc245a..8aa5cd3 100644 --- a/Assets/Plugins/UIToolkit/BaseElements/UIAbstractTouchableContainer.cs +++ b/Assets/Plugins/UIToolkit/BaseElements/UIAbstractTouchableContainer.cs @@ -411,6 +411,11 @@ public virtual void onTouchBegan( Touch touch, Vector2 touchPos ) _isDragging = true; _velocities.Clear(); + if (!inFocus) + { + return; + } + // kick off a new check _manager.StartCoroutine( checkDelayedContentTouch() ); } diff --git a/Assets/Plugins/UIToolkit/BaseElements/UIObject.cs b/Assets/Plugins/UIToolkit/BaseElements/UIObject.cs index b3b1ba6..18aff8b 100644 --- a/Assets/Plugins/UIToolkit/BaseElements/UIObject.cs +++ b/Assets/Plugins/UIToolkit/BaseElements/UIObject.cs @@ -27,8 +27,7 @@ public GameObject client /// evaluated by event handlers. /// public object userData; - - + /// /// Sets up the client GameObject along with it's layer and caches the transform /// diff --git a/Assets/Plugins/UIToolkit/BaseElements/UISprite.cs b/Assets/Plugins/UIToolkit/BaseElements/UISprite.cs index e5014a0..e51ee4b 100644 --- a/Assets/Plugins/UIToolkit/BaseElements/UISprite.cs +++ b/Assets/Plugins/UIToolkit/BaseElements/UISprite.cs @@ -6,6 +6,7 @@ public class UISprite : UIObject, IPositionable { public UIToolkit manager = null; // Reference to the sprite manager in which this sprite resides public bool ___hidden = false; // Indicates whether this sprite is currently hidden (DO NOT ACCESS DIRECTLY) + private bool __inFocus = true; public static readonly Rect _rectZero = new Rect( 0, 0, 0, 0 ); // used for disabled touch frames private bool _suspendUpdates; // when true, updateTransform and updateVertPositions will do nothing until endUpdates is called @@ -137,6 +138,18 @@ public virtual bool hidden child.hidden = value; } } + + public virtual bool inFocus + { + get + { + return(__inFocus); + } + set + { + __inFocus=value; + } + } public bool clipped diff --git a/Assets/Plugins/UIToolkit/UIToolkit.cs b/Assets/Plugins/UIToolkit/UIToolkit.cs index 4de3409..e4cd2cf 100644 --- a/Assets/Plugins/UIToolkit/UIToolkit.cs +++ b/Assets/Plugins/UIToolkit/UIToolkit.cs @@ -289,7 +289,7 @@ private ITouchable getButtonForScreenPosition( Vector2 touchPosition ) // Run through our touchables in order. They are sorted by z-index already. for( int i = 0, totalTouchables = _touchableSprites.Count; i < totalTouchables; i++ ) { - if( !_touchableSprites[i].hidden && _touchableSprites[i].hitTest( touchPosition ) ) + if( !_touchableSprites[i].hidden && _touchableSprites[i].inFocus && _touchableSprites[i].hitTest( touchPosition ) ) return _touchableSprites[i]; }