Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

LEAN ⚡️ Touch / GUI / Texture / Localization / Transition / Pool

Discussion in 'Assets and Asset Store' started by Darkcoder, Aug 1, 2019.

  1. Abhishek_Joshi

    Abhishek_Joshi

    Joined:
    Dec 15, 2019
    Posts:
    2
    Yes I updated between two very different versions of lean touch but first I deleted the old folder of lean touch.
     
  2. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,433
    Where is this error coming from? If it's from your code then you will have to update it to match the new event names. It's now called OnAnySelected.
     
  3. Lavendn

    Lavendn

    Joined:
    Jul 5, 2015
    Posts:
    560
    Any update coming to "Lean GUI Shapes" ? I'm waiting for "Gradient" feature :)
     
    dvr7 and Nikita500 like this.
  4. Braza

    Braza

    Joined:
    Oct 11, 2013
    Posts:
    140
    Hi Carlos,
    I'm using LeanTouch but to drag a clickable sprite around (LeanFingerTap + LeanDragTranslate + LeanSelectableByFinger). It works well in Editor but on Mobile it usually does not work, but starts working at some point.
    It seems to be something with the selectables. Are there differences in mobile and PC implementations? Could the timeScale affect thigs somehow as I'm messing with it in the game?
    upload_2022-8-16_14-40-40.png upload_2022-8-16_14-43-1.png

    *Update* What I noticed recently in Editor:
    - LeanSelectByFinger properly shows that my item is selected when I hold down the LMB.
    - LeanSelectableByFinger though shows as selected only if I start dragging the LMB a bit.

    Why is that?

    *UPDATE 2*
    NVM, I removed RequiresSelecatble check from FingerTap and things started working somehow.
     
    Last edited: Aug 21, 2022
  5. lanihou

    lanihou

    Joined:
    Jul 9, 2015
    Posts:
    5
    Hi, does leantouch+ support the new input system of unity ? i am getting compilation error in a new project with just LeanTouch+.
    Thank
    2022-08-23 22 14 37.png

    2022-08-23 22 33 27.png
     
    Last edited: Aug 23, 2022
  6. Volkerku

    Volkerku

    Joined:
    Nov 23, 2016
    Posts:
    115
    Installing Lean Touch + (v3.0), Unity 2020.3.31, Input System 1.3 - I'm getting the error message:

    Assets\Lean\Common\Scripts\LeanInput.cs(3,30): error CS0234: The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

    After changing Lean common Plus (pic below) , I get a lot of error messages along the lines of:
    Assets\Plugins\CW\LeanCommon+\Examples\Scripts\LeanSelectedString.cs(59,24): error CS0246: The type or namespace name 'LeanSelectable' could not be found (are you missing a using directive or an assembly reference?)



    lean.JPG
     

    Attached Files:

    • lean.jpg
      lean.jpg
      File size:
      54.9 KB
      Views:
      147
    Last edited: Aug 26, 2022
  7. AR_Tehcnoplus

    AR_Tehcnoplus

    Joined:
    Jan 17, 2022
    Posts:
    15
    When I build for Android, the buttons do not work. I am building for Quest 2. Any idea ? I am using the latest LeanGUI. Does it use the old input system ?
     
    Last edited: Aug 26, 2022
  8. Volkerku

    Volkerku

    Joined:
    Nov 23, 2016
    Posts:
    115
    Prblem with multiple objects being manipulated at once.
    I'm instatiating multiple prefabs in an AR scene, each with a few Lean components (drag, rotate and scale), see pic.
    There is also the LeanTouch component in my scene.
    However, all my prefabs are manipulated together. How can I fix this?

    lean1.JPG

    lean2.JPG
     
  9. halinc

    halinc

    Joined:
    Feb 24, 2019
    Posts:
    32
    I was struggling with this as well, here's what is working for me if u are using simple Unity 3D Objects:

    on LeanTouch, add LeanFingerDown and LeanSelectByFinger:



    make sure to fill the OnFinger Event on LeanFingerDown as in the screenshot.

    on your leanContainer, add LeanSelectableByFinger and then fill it to the RequiredSelectable field in your drag, rotate and scale components:



    This should work for cubes, spheres etc. What doesn't work for me yet is if I use imported 3D Models. The LeanSelectableByFinger never gets selected (it works fine if I check "SelfSelected", but then it is always selected and not only if the finger is on the object). Anyone knows how to fix this?

    EDIT: my bad, just had to add a MeshCollider to the 3D object, working now.
     
    Last edited: Sep 2, 2022
    MuhammadAhmadYousaf likes this.
  10. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    I'm having trouble with LeanTooltip leaving "orphaned" tooltips behind when the gameobject it's hovering over suddenly becomes disabled or destroyed. What's the recommended action for this situation?
     
  11. elfasito

    elfasito

    Joined:
    Jul 4, 2017
    Posts:
    57
    Hi Carlos.
    Im using the localization asset, Im reading translation from a txt file with ("Lean Language CSV" script).
    Its possible assign a translation with multiple lines of text (w break lines) to one key/phrase?
    my problem:
    all the lines from the txt file are readed, but if one key have a translation with multiple lines only the first line of the key/phrase is stored (the line before the break line)
     
  12. unity_1F549590108F926CE71E

    unity_1F549590108F926CE71E

    Joined:
    Aug 2, 2022
    Posts:
    1
    Hello @Darkcoder !

    I'd like to have an ability to choose which certain mouse buttons trigger touches (to limit the others from doing so, like, not allow right button click for instance).
    In
    LeanTouch
    I've found that it just tests all the button indices
    Code (CSharp):
    1. for (var i = 0; i < 5; i++)
    2. {
    3.     mouseSet |= CwInput.GetMouseIsHeld(i);
    4.     mouseUp  |= CwInput.GetMouseWentUp(i);
    5. }
    So the question is: can I make sort of pull request to implement that feature? It requires just few lines of code to add the indices array to the editor script and handle them like this instead:
    Code (CSharp):
    1. foreach (var i in MouseButtons)
    2. {
    3.     mouseSet |= CwInput.GetMouseIsHeld(i);
    4.     mouseUp  |= CwInput.GetMouseWentUp(i);
    5. }
     
    tolosaoldfan likes this.
  13. ProtagonistKun

    ProtagonistKun

    Joined:
    Nov 26, 2015
    Posts:
    352
    Has anyone ever tested this LeanTouch with ARCore / ARKit? I can't seem to get it working and I'm not sure why. The game builds but crashes on startup past the splash screen. I'm pretty sure LeanTouch might be the culprit (or the way I'm using it)

    Anyone encountered issues with it before or has tested and got this working?
     
  14. frogwise

    frogwise

    Joined:
    Nov 27, 2009
    Posts:
    103
    Hi all - with the lack of Playmaker actions, I am finding it difficult to understand how to send information from Lean Touch Events to a Playmaker FSM. For example - how would I got about sending the On World (Vector 3) value from a Lean Finger Down to a Playmaker FSM? I can only seem to "Broadcast Events" to FSM's.

    The reason I ask is because I'd like to detect whether a player touches the left or right side of the screen, and then power my character accordingly in that direction with my FSM logic.

    Thanks in advance.
     
    Last edited: Oct 12, 2022
  15. elKarkayu

    elKarkayu

    Joined:
    Mar 23, 2017
    Posts:
    18
    Hi there we are new using your fabolous plugin (leantouch) but we have a doubt.

    He have dragable items with components Lean Drag Translate and Lean Selectable by finger to move them.
    We have a door over the items with Lean Finger Tap to open them that with a script opens it.

    The problem is that if you try to drag an item behind the door it moves! how we can avoid this behaiviour?
     
  16. ARVRdavide

    ARVRdavide

    Joined:
    Nov 2, 2021
    Posts:
    1
    hi everybody, what kind of licence does lean localization has? am i free to use it for a game that i will publish? best regards
    Davide
     
  17. mohsenz

    mohsenz

    Joined:
    Aug 10, 2016
    Posts:
    29
    Hey, I'm using Leantouch for an AR project, for dragging an object. it works good, but you can't drag [keep the object] and physically move! I mean I'm looking for a way to somehow equip it once I drag, now it seems everything is based on the screen raycasting, and once I drag and move physically, it stays!
    any Idea?
    thanks
     
  18. RobbertGroenendijk

    RobbertGroenendijk

    Joined:
    Sep 12, 2018
    Posts:
    10
    Hi there, I am using Lean Touch for a project running on Android using the new UIToolkit package to build a UI. Since this UI is not attached to a game-object it is not on a specific layer and cannot be excluded by LeanTouch. Is there a way to tell LeanTouch to not activate certain Events when an event occurs over this UI? Thanks in advance!
     
  19. Lavendn

    Lavendn

    Joined:
    Jul 5, 2015
    Posts:
    560
    Hi,
    Is there a way to get a smooth carve without using Blur?
    In my scene, I'm using "Lean Box" to make a mask for my image.
    - Canves.
    -- LeanBox + Mask.
    --- Image.
    The problem is I can't get a smooth curves without using Blur. When I do use Blur I get pixels!!
     
  20. pako

    pako

    Joined:
    Nov 21, 2012
    Posts:
    112
    Hi,

    I had LeanTouch+ in my project and everything was working fine. I imported LeanPool and got errors in the form:

    error CS0012: The type 'CwEditor' is defined in an assembly that is not referenced. You must add a reference to assembly 'CW.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

    in LeanSelectableByFinger.cs and LeanSelectByFinger.cs

    So, the project doesn't build now. I added a reference to CwEditor by using the suggestion in VS2022, but no change.

    How can I fix this?
     
  21. ShayKrainer

    ShayKrainer

    Joined:
    Feb 19, 2019
    Posts:
    17
    Hi, I need some help.
    I don't understand from the examples how to implement the following. I have 2D sprites on the screen and I want to drag a sprite when I drag it with a finger/mouse (and also a different behavior for swiping).
    But I can't make them move.
    I have the Lean Touch object in the hierarchy, the gameobjects with the sprites have LeanDragTranslate with the correct camera and LeanSelectableByFinger but they won't budge. Not even if I replace LeanSelectableByFinger with Lean SelectByFinger. What am I missing?
     
  22. kevin_unity458

    kevin_unity458

    Joined:
    Feb 22, 2021
    Posts:
    3
    Hi there. I bought Lean Touch + and I am trying to use Lean Selectable Dial. I'd like the user to rotate the object from side-on. So they can rotate a cylinder from the side of the cylinder. On any object I use, including the dials in the examples, the raycasting seems to go through the object and rotates the object sometimes the right way, sometimes the wrong way. It works fine when the camera is pointing end on, but along the edge it doesn't work so well. Is there a way to fix this? Thanks Carlos.
     
  23. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    377
    For Lean Pool.. could you add a method like
    public static void DespawnAll(T) so we can just use the same prefab we used in Spawn(T) to also Despawn all of that type... currently using DespawnAll() ...but it wipes all spawn clone instances
     
  24. StefanoCecere

    StefanoCecere

    Joined:
    Jun 10, 2011
    Posts:
    211
    it's very strange that LeanTouch v2.3 works perfectly (in scene view, SImulator and Device), but when upgrading to 3.0.1 the scene view works, but NOT the Simulator, and even worse neither on device.
    i have an old component still using OnMouseDown() / OnMouseDrag()

    maybe i should update these methods?
    but i get no warnings at all....
    now gone back to LeanTouch 2.3.5 just to keep the game working...
     
    DavidJares likes this.
  25. Veteran66

    Veteran66

    Joined:
    Jul 12, 2015
    Posts:
    50
    Hi Lean Team

    for the "Lean GUI Shapes"

    "LeanLine" between two Objects, it is possible to connect several objects as a chain, not only two objects?
     
  26. Veteran66

    Veteran66

    Joined:
    Jul 12, 2015
    Posts:
    50

    it work :)
     
  27. StefanoCecere

    StefanoCecere

    Joined:
    Jun 10, 2011
    Posts:
    211
    i just wanted to LIMIT the Swipe area detection to a portion of the screen (say to avoid the top bar in the app).

    but i can't find an easy way to tell the Swipe component to not send events if Y > (ScreenHeight - 200), or to contrain it to a defined area.

    is it me or is it LeanTouch too difficult to configure?

    thank you
    stefano
     
  28. stever13888

    stever13888

    Joined:
    Oct 31, 2021
    Posts:
    10
    Does LeanTouch work with the new input system (Input System UI Input Module)? I'm doing some basic things with LeanTouch (`LeanTouch.Fingers.Count` for example) and using `LeanGesture.GetPinchScale()` to do some pinch on images, but it doesn't seem to work with the new input system. My code works with the old input system. Not sure if I set something up wrong with the new input system - I enabled EnhancedTouch via `UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.Enable();` for example.

    Edit: So the issue seems to be a combination of hardware and the new input system. We were getting double clicks when using touch, which I fixed by changing the "Pointer Behavior" from "Single Mouse or Pen" to "All Pointers As Is". I don't really know why this is needed. The 2nd issue seems to be some of our computers don't have multi-touch drivers, so the 2nd finger wasn't registering with the computer and so obviously Unity/LeanTouch wasn't picking it up.
     
    Last edited: Jan 20, 2023
  29. Charlottte

    Charlottte

    Joined:
    Jan 25, 2023
    Posts:
    2
    Hello!when using Lean Localization i meet a question. How can i use the

    Lean.Localization.LeanLocalization.SetCurrentLanguageAll("English");

    in my script ?i found it cant be used directly,there are some errs like“NameSpace”...
    can you help me?
     
  30. Lavendn

    Lavendn

    Joined:
    Jul 5, 2015
    Posts:
    560
    Try "using Lean." and see what showing up.
     
  31. rafaelcraftero_unity

    rafaelcraftero_unity

    Joined:
    Jun 30, 2020
    Posts:
    8
    Hello, Im using LeanGUI and i need to add a variable to the LeanToggle class but it doesnt show up in the inspector, anyone knows why and how to solve it?
     
  32. rafaelcraftero_unity

    rafaelcraftero_unity

    Joined:
    Jun 30, 2020
    Posts:
    8
    I just deleted the Editor part and works just fine.
     
  33. Charlottte

    Charlottte

    Joined:
    Jan 25, 2023
    Posts:
    2
    Hello,
    there is a way to auto translate all languages in a Phrase by onekey.
    I added some scrips in “LeanPhrase_Editor” .In fact these codes are original.
    I am a code beginner, and I know there may be some immaturity in this.For all that I hope I can provide you with ideas or helps.Thank you for the free plugins!

    var title1 = new GUIContent("AutoTranslateOthers");

    menu.AddItem(title1, false, () =>
    {
    foreach (var otherEntry in tgt.Entries)
    {
    //if (entry != otherEntry && string.IsNullOrEmpty(otherEntry.Text) == false)
    if (entry != otherEntry)
    {
    var textInput = entry.Text;
    var languageInput = default(LeanLanguage);
    var languageOutput = default(LeanLanguage);

    if (LeanLocalization.CurrentLanguages.TryGetValue(entry.Language, out languageInput) == true && LeanLocalization.CurrentLanguages.TryGetValue(otherEntry.Language, out languageOutput) == true)
    {
    var languageCodeInput = languageInput.TranslationCode;
    var languageCodeOutput = languageOutput.TranslationCode;

    var textOutput = default(string);

    if (TryAutoTranslate(languageCodeInput, languageCodeOutput, textInput, ref textOutput) == true)
    {
    Undo.RecordObject(tgt, "Auto Translate");

    otherEntry.Text = textOutput;

    EditorUtility.SetDirty(tgt);
    }
    else
    {
    Debug.LogError("Failed to auto translate text for some reason.");
    }
    }
    else
    {
    menu.AddDisabledItem(title1, false);
    }
    }
    else
    {
    menu.AddDisabledItem(title1, false);
    }
    }
    });
     
  34. AlexWalton

    AlexWalton

    Joined:
    Jul 7, 2019
    Posts:
    3
    Is there a way to subscribe to LeanMultiPull events?

    I have several Lean Touch components used in my scene. Instead of assigning their references in the inspector, I'm trying to subscribe to them and set their selectables through a script.

    More specifically, I'm trying to get the delta and drag distance of the first finger with a selectable required, and the delta and drag distance of a second finger. This seemed like the best way to do that.

    I tried subscribing to the public event in the script, but I must be misunderstanding how to subscribe as this asks for an object reference:

    Lean.Touch.LeanTouch.OnFingerTap += HandleFingerTap;
    Lean.Touch.LeanMultiPull.OnVector += HandleVector2;

    Is there a way to subscribe to events on the components, or would there be a better way to achieve this?
     
  35. DYV

    DYV

    Joined:
    Aug 10, 2015
    Posts:
    59
    Hi all!
    Can you help me? I need to get an object from the pool and dynamically change its variable. I can't figure out how to do it. Any help will be appreciated:)
     
  36. DavidJares

    DavidJares

    Joined:
    Dec 18, 2016
    Posts:
    50
    Hi Carlos. Its sad you are not responding anymore. I bought multiple assets of yours. Now Leantouch(+) is not working at all when I build on Mobile Android ( Unity 2022.2.10). That's really sad, as the customer support seems to have ended. Now I have to remove it. I spent 2 days finding out that the problem is with lean touch ( 3.0.1), which I absolutely did not assume at all, as it worked in past projects. Sad. Hope you are fine.
     
    tolosaoldfan and Lavendn like this.
  37. pascal_m

    pascal_m

    Joined:
    Jan 27, 2023
    Posts:
    1
    Hi LeanTouchers

    I would like to pan & zoom an image using LeanTouch+.
    The image has a maximum rect bounds and also max/min scale.

    Currently I have a ScrollRect that handles paning which also makes sure that the content stays inside the bounds.

    So far, I was unsuccessful in attaching a LeanPinch that nicely works to scale the image. It captures the touch everywhere but the image. Furthermore, the scale has no sensible boundries.

    What would be a good way to solve this?
    I really like the smooth scaling of LeanPinch and the fact that you can directly tell it to scale relatively to the pinch point.
     
  38. dvr7

    dvr7

    Joined:
    Apr 24, 2016
    Posts:
    34
    On LeanTransition, Animation Repeater, any idea why the clock keep ticking (Remaining Time), even though the Count has reached 0?

    upload_2023-5-2_12-23-35.png
     
  39. V5Studio

    V5Studio

    Joined:
    Mar 13, 2022
    Posts:
    13
    Need a help! Does LeanTransition allow to tween in numbers? Like counting up scores gradually
     
  40. gegory

    gegory

    Joined:
    Jul 22, 2014
    Posts:
    2
    Hi Carlos!
    First of all, I want to thank you for creating lean touch because it's really good.
    I am a beginner in mobile development. I using LeanTouch. My problem is that I have a cube that I want to control with one finger so that I can move it anywhere on the screen. This also works according to the "12 Transform" example. I took out the script (rotate, scale) that is not necessary for movement.
    The problem is that if I touch it with a second finger, the movement is also distorted. How can I limit control to one finger??
     
    Last edited: May 31, 2023
  41. NatCou

    NatCou

    Joined:
    Jan 29, 2017
    Posts:
    26
    Firstly thanks for making this really amazing asset!
    For my use case I wonder what I need to do to drag UI items onto a 3d object
    I couldn't find any example like that - and would love to have help to achieve it!

    Canvas
    • InventoryPanel (panel with canvas group)
      UIitem1"Key" (UIButton)

    ARCamera (represents the players view)
    3D GameObject with Tag and 3d collider loaded into AR game world
    To work in mobile and computer
     
  42. levoxtrip

    levoxtrip

    Joined:
    May 4, 2020
    Posts:
    48
    HI, thanks for this amazing asset but I get a weard error in my game.

    transform.position assign attempt for 'Background (1)' is not valid. Input position is { NaN, NaN, -100.000000 }

    I tried the examples in another project where they work, but if I try to implement the script into my project it gives me this error
     
  43. ObsidianSpire

    ObsidianSpire

    Joined:
    Sep 13, 2013
    Posts:
    56
    Hi, I've bought a few of your paid plugins and enjoyed them in other projects. Now I'm attempting to use Lean Transition and I was wondering what the best way to make a group of objects follow behind a moving target would be? Think Yoshi's Island where the eggs/objects follow Yoshi in their path until each egg reaches a spot close enough to stop. I have a custom class to move them along the jump arc which works decently well but is not 100% perfect, and I wanted to try this plugin plus others before committing to my method and polishing it further. I have stored the position of the target/player along their jump arc, but I'm not sure of the best practices for this plugin in particular.

    https://forum.unity.com/threads/dotween-hotween-v2-a-unity-tween-engine.260692/page-62#post-4492342

    That post from a couple years ago in another thread mentions this is possible, but I didn't see it mentioned in the examples. Also, I'd like to do this all from code most likely, unless it isn't possible.

    Edit: nvm, I just realized it was mentioning a different asset. I confused them with yours due to the Lean name.
     
    Last edited: Jun 24, 2023
  44. wanzikhn

    wanzikhn

    Joined:
    Apr 4, 2022
    Posts:
    2
    Hi everyone! I have a problem. In some cases localization doesn`t work correctly. I use LeanLocalized TextMeshProUGUI on TextMestProText component and in case of current language are ukrainian it work normaly but if current language set to english - I get fallback text in text component, I have the same localization key in each CSV localization files. How I can solve it?
     
    Last edited: Jul 26, 2023
  45. Tural-Muslim

    Tural-Muslim

    Joined:
    Oct 24, 2019
    Posts:
    31
    Lean Localization: What code can I use to see which language is selected?
     
  46. wanzikhn

    wanzikhn

    Joined:
    Apr 4, 2022
    Posts:
    2
    Use static method LeanLocalization.GetFirstCurrentLanguage(). You will get your current language name in string format
     
  47. Nikita500

    Nikita500

    Joined:
    Aug 18, 2015
    Posts:
    72
    LeanPool - it says it can pool class with LeanClassPool . is it depricated? cant find anything in documentation or add in components
     

    Attached Files:

  48. RiseBasti

    RiseBasti

    Joined:
    Nov 4, 2018
    Posts:
    33
    Is there already an update for the UI Toolkit to use "StartedOverGUI" and "IsOnGUI"?
     
  49. RiseBasti

    RiseBasti

    Joined:
    Nov 4, 2018
    Posts:
    33
    I found a solution that works for me. I think this is just a piece of the whole pie but it works for my current situation.

    1. Create a manipulator and add it to the root element.
    2. Create a mask and place it as needed.
    3. Set the value "StartedOverUI" for the finger with a function when OnPointerDownOverUI gets fired.


    Manipulator:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UIElements;
    3. using System;
    4.  
    5. public class StartedOverUIDetector : PointerManipulator
    6. {
    7.     #region Variables
    8.     private VisualElement maskElement;
    9.     private float alphaThreshold = 0.5f;
    10.     private Action<int> onPointerDownOverUI;
    11.     /// <summary>
    12.     /// OnPointerDown gets called if the pointer is pressed down.
    13.     /// Parameter: PointerID
    14.     /// </summary>
    15.     public event Action<int> OnPointerDownOverUI { add => onPointerDownOverUI += value; remove => onPointerDownOverUI -= value; }
    16.     #endregion
    17.  
    18.     #region Unity Functions
    19.     /// <summary>
    20.     /// Register target callbacks
    21.     /// </summary>
    22.     protected override void RegisterCallbacksOnTarget()
    23.     {
    24.         target.RegisterCallback<PointerDownEvent>(HandleOnPointerDown);
    25.     }
    26.     /// <summary>
    27.     /// Unregister target callbacks
    28.     /// </summary>
    29.     protected override void UnregisterCallbacksFromTarget()
    30.     {
    31.         target.UnregisterCallback<PointerDownEvent>(HandleOnPointerDown);
    32.     }
    33.     #endregion
    34.  
    35.     #region General Functions
    36.     // Constructor
    37.     public StartedOverUIDetector(VisualElement maskElement, Action<int> onPointerDownOverUI, float alphaThreshold = 0.5f)
    38.     {
    39.         // Set values
    40.         this.maskElement = maskElement;
    41.         this.onPointerDownOverUI = onPointerDownOverUI;
    42.         this.alphaThreshold = alphaThreshold;
    43.     }
    44.        
    45.     /// <summary>
    46.     /// On pointer down
    47.     /// </summary>
    48.     protected void HandleOnPointerDown(PointerDownEvent e)
    49.     {
    50.         // Get the clicked position and translate in local position
    51.         Vector2 localClickPosition = maskElement.WorldToLocal(e.position);
    52.  
    53.         // Check if VisualElement contains clicked position
    54.         if (maskElement.ContainsPoint(localClickPosition))
    55.         {
    56.             // Check transparency of the mask texture
    57.             if (!IsPixelTransparent(localClickPosition, maskElement))
    58.             {
    59.                 onPointerDownOverUI?.Invoke(e.pointerId);
    60.             }
    61.         }
    62.     }
    63.  
    64.     /// <summary>
    65.     /// Check pixel for transparency
    66.     /// </summary>
    67.     private bool IsPixelTransparent(Vector2 localClickPosition, VisualElement element)
    68.     {
    69.         // Check if background is set
    70.         if (element.resolvedStyle.backgroundImage.texture != null)
    71.         {
    72.             // Calculate the factor of the clickPosition in relation to the target size
    73.             Vector2 clickPositionFactor = new Vector2(
    74.                 localClickPosition.x / element.resolvedStyle.width,
    75.                 localClickPosition.y / element.resolvedStyle.height
    76.             );
    77.  
    78.             // Get  backgroundImage
    79.             Texture2D backgroundImage = element.resolvedStyle.backgroundImage.texture;
    80.  
    81.             // Scale the clickPositionFactor to the texture position in relation to the texture size
    82.             Vector2 texturePosition = new Vector2(
    83.                 Mathf.Floor(clickPositionFactor.x * backgroundImage.width),
    84.                 Mathf.Floor((1 - clickPositionFactor.y) * backgroundImage.height)
    85.             );
    86.  
    87.             // Get pixelColor at position
    88.             Color pixelColor = backgroundImage.GetPixel((int)texturePosition.x, (int)texturePosition.y);
    89.  
    90.             // Compare alpha value with alpahThreshold
    91.             return pixelColor.a < alphaThreshold;
    92.         }
    93.  
    94.         // If no background is set the background is probably transparent
    95.         return true;
    96.     }
    97.     #endregion
    98. }
    new Manipulator with function called OnPointerDownOverUI:
    Code (CSharp):
    1.             StartedOverUIDetector isOverUIDetector = new StartedOverUIDetector(uiMaskElement, (pointerId) =>
    2.             {
    3.                 int fingerId = pointerId - 1;
    4.                 for (int i = 0; i < LeanTouch.Fingers.Count; i++)
    5.                 {
    6.                     LeanFinger finger = LeanTouch.Fingers[i];
    7.                     if (fingerId >= 0 && finger.Index == fingerId)
    8.                     {
    9.                         finger.StartedOverGui = true;
    10.                     }
    11.                 }
    12.             });
     
    ObsidianSpire likes this.
  50. xahdpe

    xahdpe

    Joined:
    Mar 26, 2017
    Posts:
    6
    hi,
    i have a problem with the following setup :
    lean_rotate_01.PNG

    i want to make a rotation with 90 degree step. Normally it works ok, but if i swipe my screen until the previous rotation is done, my object rotates to the unexpected angle:
    lean_rotate_02.PNG

    can you please help me to get rid of this problem? maybe I can block execution of second swipe until first is done or something?

    thanks for your help!