Search Unity

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

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

  1. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    1 - If your instances were spawned using LeanPool's API then it should work.

    2 - All LeanGameObjectPool data should correctly de/serialize. You don't have to place the spawned instances as children either, because they're stored in the private spawnedClonesList list.
     
    bitinn likes this.
  2. Fariborzzn

    Fariborzzn

    Joined:
    Apr 17, 2019
    Posts:
    14
    Hey carlos , hope you have great day. I'm using Swipe Screen Scene from LeanGUI and it works perfectly. I'm trying to make the arrows UI To button so player have 2 options to Swipe Screen 1-Dragging on screen 2-Pressing desire button..
    like this picture ..
    99.png

    I Look at the source code but didn't find a right path to to it. Hope You could put me in right direction
    Thanks for your amazing effort in Game Dev Journey
     
  3. RiseBasti

    RiseBasti

    Joined:
    Nov 4, 2018
    Posts:
    33
    Thank you for your Answer. I just tried something (not used to lambda expressions) and just wanted to ask if this is fine because the functions doesn't get listet in the inspector. (but it seems to work)

    Code (CSharp):
    1. leanSelectable.OnSelect.AddListener(_ => item.OnSelect());
    2. leanSelectable.OnDeselect.AddListener(() => item.OnDeselect());
    Is this how it's supposed to be? :confused:
     
  4. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Looks good. Only editor made events show in the inspector so don't worry about it not appearing.
     
    RiseBasti likes this.
  5. Coltenney

    Coltenney

    Joined:
    Mar 10, 2015
    Posts:
    25
    Hi just posting a potential issue/solution here in case others come across it.
    I had trouble using the Selectable Dial script on a UI element (Dial example - 07 UI). I found that the RectTransformUtility.ScreenPointToWorldPointInRectangle(...) call in LeanSelectableDial.GetPoint(...) expects the camera parameter to be null when the canvas is set to Screen Space - Overlay.

    From the Unity Doc... https://docs.unity3d.com/ScriptRefe...ility.ScreenPointToWorldPointInRectangle.html

    "The cam parameter should be the camera associated with the screen point. For a RectTransform in a Canvas set to Screen Space - Overlay mode, the cam parameter should be null."

    Since I only have 1 UI based Dial, I just force this cam parameter to be null for now.
     
  6. gentlegorilla

    gentlegorilla

    Joined:
    Jun 18, 2019
    Posts:
    19
    Hi,

    proud owner of lt and lt+, I'm currently facing an issue. Using LeanTouchMultiUpdate with LeanTouchSimulation to get the Mouse input, input is working as long as I allow all mouse buttons (RequiredMouseButtons = 0); left and right mouse button get catched.

    I want to restrict the multi update to only left mouse button. But setting a RequiredMouseButtons to anything except 0, mouse stops working, no buttons are catched.

    Not sure what caused the issue, as I had the impression it was working on that machine before. The machine has also a touchscreen, but disabling it does not help.

    Any hints where to dig into to get more information / a solution?

    Best
     
  7. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    I ran into a limitation of Lean Pool: it cannot manage multiple pools of the same prefab?

    I am using Lean Pool in some creative ways and I wonder this means I *have to* have many identical prefabs, or perhaps prefab variants?
     
  8. NoPants_

    NoPants_

    Joined:
    Apr 23, 2014
    Posts:
    59
    Hey, just so you are aware, I think there's a bug in the latest LeanGui, running an android build. Lean Buttons don't seem to be working. I had to downgrade to previous version to fix it. Sorry I don't have much else, there wasn't any errors of any kind in logcat, and regular buttons were still working fine.
     
  9. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Thanks for pointing this out! This will be fixed in the next release coming out next week.


    I don't see any issue. If I modify the "Drag/01 Drag" demo scene so RequiredMouseButtons = 1, then I must left click to see the mouse information. Right click, middle click, etc, no longer do anything as expected.



    To make multiple pools manage the same prefab you must manually create the LeanGameObjectPool component, and manually spawn and despawn from them using a direct reference. The LeanPool static class abstracts all of this so each prefab only maps to one pool, after all how else could it work?


    I'll check it out. I made a card for this issue HERE.
     
  10. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961

    I was doing that and it still complain about it.

    (Does LeanGameObjectPool.TrySpawn counts?)

    Basically 2 LeanGameObjectPool use the same prefab, and I manually spawn and despawn using TrySpawn/DespawnAll. The warning is logged where I call DespawnAll then TrySpawn.
     
  11. yepfuk

    yepfuk

    Joined:
    Sep 23, 2015
    Posts:
    67
    Hi, I want to add Lean Touch to the project via unity package manager api.
    But I get 'com.cwilkes.lean' cannot be found error. What is the lean touch's package name?
    Thanks.
     
  12. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    You'll have to provide an example that I can replicate because I don't see any issue. If I modify one of the example scenes to have 2 pools managing the same prefab then I can spawn clones, DespawnAll, and then spawn more without any errors. The only thing I see is a warning about multiple pools managing the same prefab.

    Unity assets aren't packages, so I don't think you can add them like official packages. Although I've added a package manifest to my assets, I don't think it does anything except provide convenience for advanced users that want to import it like a package to multiple projects. I've never used the API for this so I don't know though.
     
  13. gentlegorilla

    gentlegorilla

    Joined:
    Jun 18, 2019
    Posts:
    19
    Digged into it a bit more. With your 01 Drag scene, I added a script as target for OnFingers event.

    Code (CSharp):
    1.  
    2.     public void OnFingers(List<LeanFinger> fingers)
    3.     {
    4.         LeanFinger finger = fingers[0];
    5.  
    6.         ConsoleProDebug.Watch("Game::UserInteraction", $"Index: {finger.Index}, Age: {finger.Age}, Set: {finger.Set}, Tap: {finger.Tap}, Old: {finger.Old}, WPos: {finger.GetStartWorldPosition(20f)}");
    7.  
    8.         if(finger.Tap)
    9.         {
    10.             Debug.Log("TAP");
    11.         }
    12.     }
    13.  
    If I keep 0 set for "Required Mouse Buttons", TAP will be printed to console. If I set to 1 or 2, no TAP is recognized anymore. For my use case, I wanted to use Lean Touch incl. Simulator to support Touch and Mouse input, triggering the event only, if there is a touch tap or a click with left mouse button. But not the right mouse button.
    Also fingers.Set is always true, when "Required Mouse Button" is set to non-zero.

    Best
    Thorsten
     
  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Try the attached package, this should fix the issue.



    Aha. The RequiredMouseButtons setting was only checking to see if the specified fingers were down, but since a tap requires the mouse to release, there are no longer any fingers down. The attached "LeanFingerFilter_Fix" package should fix this.
     

    Attached Files:

  15. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    yes, that's exactly what I was asking about: is the warning a problem or just a general warning? for example, does DespawnAll() cause all instances (instances in both pool), to disappear?
     
  16. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Oh I see, well you can ignore that warning. There’s currently no way to disable it due to a bug that I will fix though.

    If you call DespawnAll on the pool itself then it will only despawn instances spawned from that pool. LeanPool.DespawnAll will despawn everything in your scene.
     
    bitinn likes this.
  17. Coltenney

    Coltenney

    Joined:
    Mar 10, 2015
    Posts:
    25
    I think I have found another bug... I am unable to get the UI Buttons working when in 'Simulator' when testing in editor. Buttons still work when in 'Game' mode and in Build.

    GetMousePosition() in LeanInput has the following line. UnityEngine.InputSystem.Mouse.current.position.ReadValue(). Which seems to return Infinity for the screen coordinates when viewing the 'Simulator'. I tested with Input System set to BOTH and NEW in project settings.

    Code (CSharp):
    1. public static UnityEngine.Vector2 GetMousePosition()
    2.         {
    3. #if ENABLE_INPUT_SYSTEM
    4.             return UnityEngine.InputSystem.Mouse.current != null ? UnityEngine.InputSystem.Mouse.current.position.ReadValue() : default(UnityEngine.Vector2);
    5. #else
    6.             return UnityEngine.Input.mousePosition;
    7. #endif
    8.         }
     
  18. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Hmm, sounds like a bug with the simulator. If it's not providing any mouse data then it shouldn't say the mouse exists. I guess I could write some special code to ignore it if it's infinity, I'll think about it.
     
  19. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Question about lean transitions. Is there an ability to pause a transition, reset it to start, and replay it?
     
  20. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    For one specific transition, you can kind of do this. After you begin a transition you can access its state from the LeanTransition.PreviousState property. This has the .Stop() method, and you can call the .Update(0.0f) method to set it back to the start. You can't pause and resume it though, you would have to begin a new transition with the same settings to do this.

    For a sequence of transitions you can use the LeanManualAnimation component, which has the BeginTransitions(), SkipTransitions(), and StopTransitions() methods. There's no way to revert the transitions though.

    Also keep in mind not all transitions store their initial state (e.g. Transform translate transition), so it's not always possible to revert them.
     
  21. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Thank You for the answer.
     
  22. Coltenney

    Coltenney

    Joined:
    Mar 10, 2015
    Posts:
    25
    I am using the joystick for aiming and currently getting the correct Vector2 from OnSet(). I want to fire when finger is lifted, but the OnUp() call is invoked after the scaled value is reset to 0,0 with the center on release enabled. What should I do?
     
  23. Coltenney

    Coltenney

    Joined:
    Mar 10, 2015
    Posts:
    25
    A seperate question, I am tying to set up a 'cancel' button that appears next to a joystick that can be released on to cancel the action. I am not sure how to set up a button that will get fired by dragging onto (from a seperate control) and releasing. I am using touch devices. This may be a good candidate for an example.
     
  24. ricke44654

    ricke44654

    Joined:
    May 8, 2016
    Posts:
    8
    I've used Lean Pool in few projects and it's a great, simple pooling system. However, I'm a little fuzzy on how to setup and use the LeanClassPool for plain C# classes. A few questions:
    * Is there a good example out there that I'm missing? I checked out the Examples folder and available scenes but didn't see anything. The code documentation for the class didn't show too much in the way of usage.
    * How can I pre-populate the pool with class instances?

    Any thoughts would be appreciated. Thanks for your help and for the great asset. :)
     
  25. wagenheimer

    wagenheimer

    Joined:
    Jun 1, 2018
    Posts:
    323
    I'm using LeanTouch and I'm adding support to GamePads to my games. I do use UIPointer to control the Mouse Cursor using the GamePad (simple move the cursor and press a button is relative to a click).

    Is there any support for Rewired on LeanTouch? I could not found anything
     
  26. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    107
    Hey Carlos, is there a way to simulate fingers in LeanTouch (Plus)? Simply, I'd like to create my own LeanFinger instances and add them as fingers and then manually manage them myself like adjusting screen position, touch Up/Down, etc.

    Reason is sometimes I'd be working on a touch related feature, and it would be nice to create a replicable touch gesture for ease of testing. I know there's the Snapshot feature but as I understand it, it's just to record and playback screen position only?
     
  27. BillDNA

    BillDNA

    Joined:
    Jun 3, 2014
    Posts:
    7


    Ok So what Am I doing wrong with the Join Transitions? the 2nd AnchorMax.x doesn't ever seem to go to 2
     
  28. D_Gaters

    D_Gaters

    Joined:
    Feb 14, 2018
    Posts:
    7
    Hello,
    I have an issue with LeanTouch, the FingerTap event fires twice in simulator mode, and once in game mode as it should. Is there any way to not have it fire twice? Or I should not use simulator mode?
     
  29. Volkerku

    Volkerku

    Joined:
    Nov 23, 2016
    Posts:
    114
    I'm getting this error in unity 2020.2.13 after activating Both or active input handling in the player settings. I need to be able to use the new inpoytr system witrh the old one. Is there a fix?

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

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

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

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Lean Touch has a touch simulator built in so you shouldn't need to use unity's one.

    What I think is happening is Unity is simulating touch from your mouse, but also still sending mouse info, and Lean Touch is detecting both of these and thus giving you two taps. If this is the case you can disable the UseMouse setting in the LeanTouch component inspector. Not sure if there's an easy to fix this, hmm.


    I can't replicate this issue. If I make a new project in 2020.3.0f1 with Lean Touch+ 2.3.4 and install the Input System then switch Active Input Handling to Both, then it works as expected. Moreover, I can't think of a reason why switching it to Both would ever cause this issue. Try selecting the Lean/Common/LeanCommon asset, and seeing if the Unity.InputSystem assembly is listed there like this:

    upload_2021-10-28_23-17-50.png
     
  31. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
  32. Ryan-Hayle

    Ryan-Hayle

    Joined:
    Feb 16, 2014
    Posts:
    142
    Lean Touch+ How do you translate, rotate and scale an object (Not camera), without them interfering with each other? I have tried out many of your demo examples and have manged to get them working on PC, but never on my Android phone.
     
    Last edited: Nov 4, 2021
  33. Ryan-Hayle

    Ryan-Hayle

    Joined:
    Feb 16, 2014
    Posts:
    142
    How do you achieve a different action when dragging 1 finger or 2 or multiple? They all seem to interfere with each other when testing on mobile.
     
    Last edited: Nov 12, 2021
  34. Ryan-Hayle

    Ryan-Hayle

    Joined:
    Feb 16, 2014
    Posts:
    142
    Do you have a discord?
     
  35. anatolyniky

    anatolyniky

    Joined:
    Oct 2, 2018
    Posts:
    1
    I have same question
     
  36. lacas8282

    lacas8282

    Joined:
    Apr 25, 2015
    Posts:
    138
    I got a lot of:

    This pool contained a null despawned clone, did you accidentally destroy it?

    You're attempting to despawn a gameObject that wasn't spawned from this pool

    on LeanPool in the Console

    Is it normal? Error or just warning?
     
  37. Aracon

    Aracon

    Joined:
    Aug 16, 2018
    Posts:
    16
    Hello! Thanks for clean pooling solution.
    Is there any method to check if the prefab is pooled? To choose the right call (Instantiate/Spawn)
     
  38. Ryan-Hayle

    Ryan-Hayle

    Joined:
    Feb 16, 2014
    Posts:
    142
    Why does Lean Touch property Gui Layers being set to UI break tapping with UI layers within a canvas object?

    If I try to work around this and set Gui Layers to none, it then throws error:

    NullReferenceException: Object reference not set to an instance of an object
    UnityEditor.PropertyEditor.DrawEditors (UnityEditor.Editor[] editors) (at <2cd7ebc9c2ef4276a8edbc7de85c89ce>:0)
    UnityEditor.PropertyEditor.RebuildContentsContainers () (at <2cd7ebc9c2ef4276a8edbc7de85c89ce>:0)
    UnityEditor.InspectorWindow.RedrawFromNative () (at <2cd7ebc9c2ef4276a8edbc7de85c89ce>:0)

    I'm trying to tap a UI button to select it and double tap to trigger a function call, but if I have 2 buttons both are called on a double tap, what's happening?

    Can we have some support please, I posted a week ago?
     
    Last edited: Nov 12, 2021
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Sorry for the late replies everyone.

    The Graphic.color Transition (LeanGraphicColor) can be used to do this.




    You can use the RequiredFingerCount setting to do this:

    upload_2021-11-13_10-43-18.png

    You can also use the LeanGestureToggle component (Lean/Touch+/Exampels/TransformToggle demo scene) to isolate the gestures to one at a time.


    No.


    It's a warning. You can ignore this, but if this happens for every object in your scene then it means you're not using pooling properly and won't get any performance benefit. You can add the LeanPoolDebugger component to your prefab to see when things are going wrong.


    You can check the LeanPool.Links dictionary to see if it contains an entry for your GameObject.


    Most games have the UI on top of the gameplay, and you usually only need to use LeanTouch for the game part behind the UI. The GuiLayers setting is therefore used to 'ignore' touch controls if they begin on top of the UI. You can control this with the IgnoreStartedOverGui setting on most components:


    upload_2021-11-13_10-49-9.png
     
  40. AlexWalton

    AlexWalton

    Joined:
    Jul 7, 2019
    Posts:
    3
    What is the best way to access data inside each component? I'm trying to pull the onVector data from a LeanMultiPull instance.

    Edit: Carlos replied to my email:

    "The LeanMultiPull component has the OnVector event (among others), which you can use to send data to your custom component. As long as your component has a public method with the Vector2 argument, you will be able to connect it using the inspector. This is how the "Lean/Touch+/Examples/Drag/16 Turn 2D" demo scene works."
     
    Darkcoder likes this.
  41. RosMedia

    RosMedia

    Joined:
    Oct 23, 2020
    Posts:
    2
    Hi, I'm a happy owner of LeanTouch and LeanTouch+. It works great, but I have one case where I'm unable to figure out.

    I have something that looks similar to a sphere (it's a mesh). I have an object on it, which can be dragged on it. But, dragging goes on a flat plane, yet this mesh isn't flat and there are places where object goes inside a mesh and becomes partially or fully invisible.

    It looks like this:

    upload_2021-11-15_14-58-53.png

    The small item uses following scripts:

    Box Collider
    Lean Selectable by Finger
    Lean Selectable Renderer Color
    Lean Drag Translate

    I've only found an example "13 DragUnderAlongPlane" - but this uses plain - I need an object to "stick" to mesh and then make it draggable.

    Is this possible with LT?
     
  42. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    You can use the LeanDragTranslateAlong component seen in that demo scene, but you must change its ScreenDepth setting to PhysicsRaycast:

    upload_2021-11-16_22-59-51.png

    Make sure you set the Layers setting correctly, and that your object has a (probably Mesh)collider.
     
  43. Tubestorm

    Tubestorm

    Joined:
    May 8, 2020
    Posts:
    6
    Hello,
    I recently found your asset LeanPool and it is a godsend, it works so well and I'm so grateful for how easy it's made pooling in Unity. I have some questions and wanted to know how to create a Dictionary of LeanPools and if it is possible to control the capacity of each pool (in the dictionary) in code.

    I have multiple prefabs so I need different pools, but they all use the same code that's why I was hoping to just create a dictionary holding all the different pools. Thanks again.

    Regards.
     
  44. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    I have a need for both scaledTime and unscaledTime with LeanTransitions (i.e. pausing timers but keeping UI effects).

    Is it possible to add a Time property to the transition methods?
     
  45. RosMedia

    RosMedia

    Joined:
    Oct 23, 2020
    Posts:
    2
    Thanks, it works indeed!
     
    Darkcoder likes this.
  46. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    There is a big issue using LeanTouch/(+) in Unity 2021.2.2f1 - if LeanSelectableByFinger (or any other Lean Touch component) is attached to the object and Gizmos are enabled in Scene window, transform handles will not appear. Have no idea why after checking the source code.

    @Darkcoder please have a look
     
  47. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    LeanPool itself stores a dictionary of pools and creates new ones if you try to spawn a new prefab, so it already implements this? These pools are created with default settings though, so you should manually add pre-configured pools to your scene if you need different settings.



    See the "Lean/Transition/Examples/08 Time" demo scene ;)

    You can also add the LeanTransition component to your scene and change the DefaultTiming.



    Interesting, it looks like Unity 2021 somehow changed the gizmo system to no longer work with Lean components. Perhaps it's the custom inspector or something, I'll have to dig into the code a bit. Yay fun times!
     
    JohnnyFactor likes this.
  48. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    107
    Hey Carlos, this is unlikely an issue with the asset, but have you come across what's going on below?



    - So two fingers are on the screen
    - The left finger, I'm holding perfectly still
    - The right finger, I'm moving, yet it affects the left touch input

    Is this just a hardware thing? I've tested this on a few different phones, both Android and iOS. Some show the issue more than others.
     
  49. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Where are you getting the data for those finger visualizations? If it's only changing this little then it must be a hardware issue/quirk, or your finger (or at least the contact patch) is actually moving a tiny bit. If the finger data was being swapped or something I would expect to see much large movement on the left. In practice you shouldn't rely on any analog input being that precise though, you should add some kind of tolerance.
     
  50. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    107
    That's the touch input display that's part of the Developer options on Android.

    I thought this too, but it's pretty consistent. Also I'm very careful. While there still might be a chance it's me, I still don't think so at this point.

    I also thought this, and did print out the finger index but they remained the same.

    Yeah I might try this. On the device the video was recorded on though (a Pixel 2) the touch movement that it equates to isn't that small, and if I added tolerance it might reduce the sensitivity too much.

    Thanks for the response though. I wasn't expecting anything to be done and just wanted to know if you or anyone had encountered it.