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,412
    Ah I see now. I sent you an updated build via email :)
     
  2. Miguelfanclub

    Miguelfanclub

    Joined:
    Jun 14, 2015
    Posts:
    64
    It works! Many thanks.
     
    Darkcoder likes this.
  3. unity_rsenoron

    unity_rsenoron

    Joined:
    Oct 24, 2019
    Posts:
    6
     
  4. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Thanks for pointing this out! I've submitted a fix, and sent you an early copy of it via private message :)
     
  5. netlander

    netlander

    Joined:
    Nov 22, 2011
    Posts:
    28
    Is there a way to receive swipe events and events with swipe directions with this plugin?
     
  6. unity_rsenoron

    unity_rsenoron

    Joined:
    Oct 24, 2019
    Posts:
    6
    Nice. Thanks it works.

    Anyway is there an 'on drag' event in lean selectable?

    I have a UI element( a card). On select it will translate and on deselect it will revert. I want that when you start to drag the 'card', it will revert and then use the 'lean drag translate'.
     
  7. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    Hello,
    I'm using Lean GUI, which is quite nice and simple to use.
    I have a minor problem, when in the editor I have this warning message:
    The line which ultimately cause the problem is:
    Code (CSharp):
    1. Target.sizeDelta = targetSize;
    The warning seems quite harmless, but it's cluttering the console.
    Is there a way to get rid of that (I am using Unity 2019.1.12 if it can help)?
     
  8. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Yep, check out the SwipeDirection4 and SwipeDirection8 demo scenes that come with Lean Touch :)



    Yes, you can add the LeanMultiSet component to your card. As long as the Use.RequiredSelectable setting it set (it should auto set), then the events from this component (e.g. OnDelta) should fire only when selected.


    Indeed, these events are annoying since you can't switch them off. In this scenario you can probably wrap that line in a statement like: if (Target.sizeDelta != targetSize)
     
  9. doarp

    doarp

    Joined:
    Sep 24, 2019
    Posts:
    147
    I have several overlapping LeanSelectable objects and I want to only select the one where the selecting finger is closest to the object center. The objects are flat on a flat plane (in 3D space).
    They have no “order” between them on the plane.
    what’s the best way to do this?
     
  10. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    Thanks!
    I'm feeling a bit dumb not having thought about that in the first place.
     
    Darkcoder likes this.
  11. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Good idea. I sent you a private message with an updated script that allows you to do this, let me know if this works as you expect :)
     
  12. khanhabib

    khanhabib

    Joined:
    Oct 11, 2018
    Posts:
    29
    Thank you so much
     
    Darkcoder likes this.
  13. unadamlar

    unadamlar

    Joined:
    Jul 7, 2015
    Posts:
    10
    I'm using Lean Localization. I have a an inbox menu where I list all the friend request that the user gets. It lists the requests as

    -{Sender_Name} Wants to be your friend!
    -{Sender_Name} Wants to be your friend!
    etc.

    If I use Sender_Name as a token and do LeanLocalization.SetToken("Sender_Name", request.senderName);
    All the request objects will switch to the the last setting of the token. Every text will display the same senderName. This is the expected behaviour from what I can see.

    I thought of registering a token for each request object I instantiate, but I don't think that approach is workable as I wouldn't be able to dynamically add new phrases for each new request object to the CSV file I store.

    Is there any way LeanLocalization allows me to localize a list like this dynamically?

    EDIT:
    I eventually figured I was using the wrong approach after all. I removed the LeanLocalizedTextMeshProUGUI components from the request objects and instead set the text by setting the token first and calling LeanLocalization.GetTranslationText("FriendRequestMessage"); everytime a new request was instantiated.
     
    Last edited: Dec 12, 2019
  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    In this scenario I recommend you manually replace the tokens with your own (e.g. using string.Replace(...)). You would also want to hook into LeanLocalization.OnLocalizationChanged and manually replace them again if the user changes languages. Perhaps I could add some kind of 'local token' system to handle this scenario, but my task list is currently very long so this may take a while to get around to.
     
  15. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Hey everyone,

    Later today many of my assets will be given away in the 2019 Christmas Giveaway hosted by Devdog.

    You can sign up for free HERE to be in for a chance to win!

    Good luck!
     
  16. damiann5f

    damiann5f

    Joined:
    Apr 10, 2017
    Posts:
    2
    Hi,

    I would like to use Lean Touch+ for top-down camera movement with zoom option. Basically, I want to combine functionalities of OrbitMoveTopDown and OrbitZoom demo scense. I stumbled onto an issue with two-fingers gestures. LeanPinchCamera is detected when doing LeanDragCamera with is resulting in slightly zooming in and out while moving it with two fingers drag.

    My question:
    Is there a possibility to disable LeanPinchCamera when LeanDragCamera is performend or lower down LeanPinchCamera sensitivity for gestures so it would not be fired each time when doing two finger drag.

    Beside that awesome package. Thanks for the amazing work.

    Regards
     
    doarp likes this.
  17. Dolomitenfex

    Dolomitenfex

    Joined:
    Dec 2, 2019
    Posts:
    7
    Hi Carlos,
    thanks for lean touch first of all!
    I just wondered if I can use it for AR applications as well - how will the scenes be implemented? Any coding necessary?

    Best wishes
    Eva
     
    khanhabib likes this.
  18. Dolomitenfex

    Dolomitenfex

    Joined:
    Dec 2, 2019
    Posts:
    7
    I have found some tutorials. Now I would like to implement the SideScroll3dZoomRotate. As I found it in the tutorials, I should drag - among other things - the script for this example on to a new game object. I cannot find the script for that example…
     
  19. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    I answered you via email!

    I'm not sure I understand your question. The Sidescroll3DZoomRotate demo scene works in a 3D sidescolling game scenario. I'm not sure how this would work in AR, since in AR the camera is controlled by the device orientation. If you just want to move objects on top of an AR plane then I posted a demo scene of this a few weeks ago with Vuforia.
     
  20. Dolomitenfex

    Dolomitenfex

    Joined:
    Dec 2, 2019
    Posts:
    7
    Hey, thanks for your answer. Where did you post that scene?
     
  21. Aetrix

    Aetrix

    Joined:
    Nov 23, 2013
    Posts:
    12
    Hello to all, i have one question, when we download latest version fron asset store there are few scenes with missing prefabs (SinpleSwipe) and events with no funcion calls. Can anyone explain what happened and how can we fix those missing things? Thank you!
     
  22. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You can get it HERE.


    Can you tell me which demo scenes have missing prefabs?

    Regarding the functions, it's probably THIS bug. Unless I actually forgot to connect some?
     
    Aetrix likes this.
  23. Dolomitenfex

    Dolomitenfex

    Joined:
    Dec 2, 2019
    Posts:
    7
    Thank you, I am sure it's gonna help me with my project!
     
    Darkcoder likes this.
  24. Aetrix

    Aetrix

    Joined:
    Nov 23, 2013
    Posts:
    12
  25. nekolyst

    nekolyst

    Joined:
    Mar 12, 2018
    Posts:
    23
    Hi, I use LeanLocalization.SetToken() method in script to change value in runtime.
    In inspector, Lean Token value was changed, but the TMP UGUI text which use this token was not updated.
    I need to right on LeanLocalizedTextMeshProUGUI script and select "Update Localization"
    manually.

    How to fix that or I need to call what method after LeanLocalization.SetToken() in script?

    Thank you!!

    ===============
    Oh! I found it. Just call "LeanLocalization.UpdateTranslations()" after SetToken() and it works.
     
    Last edited: Dec 16, 2019
  26. Denchi_

    Denchi_

    Joined:
    Dec 17, 2018
    Posts:
    23
    Hi Carlos!

    First of all, love your assets. =) I use them a lot. Really clean, easy to use and well-documented.

    I was wondering if you'd consider eventually adding an open source license to some of your free assets. I'd love to use them in my own open source projects that I publish on GitHub, but unfortunately the standard Unity asset license that applies to all free assets in the store that don't have their own explicit license doesn't allow that.

    I fully understand if you can't/don't want to, but I thought it wouldn't hurt to ask.

    Thanks! :)
     
  27. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Yep, you need to update to a version of Unity that fixes this bug. If you can't update then you must modify each event field definition so the access modifier is public instead of private.

    For example:

    Code (CSharp):
    1. public Vector3Event OnWorldDelta { get { if (onWorldDelta == null) onWorldDelta = new Vector3Event(); return onWorldDelta; } } [SerializeField] private Vector3Event onWorldDelta;
    Would change into this:

    Code (CSharp):
    1. public Vector3Event OnWorldDelta { get { if (onWorldDelta == null) onWorldDelta = new Vector3Event(); return onWorldDelta; } } [SerializeField] public Vector3Event onWorldDelta;


    I just tested this and it works for me, and the code looks like it should work. modifying the LeanToken value should uatomatically update all components that use that token. I did notice that manually modifying the LeanToken from the inspector doesn't trigger the update though, which I will fix.

    Perhaps I'm missing a step?


    Thanks for actually caring about licenses! However, publishing my assets twice sounds like a pain in the ass. While I could change the license of my free assets on the store, I don't want to confuse or scare away users, as I kind of like how almost everything on the store uses a uniform and fairly permissive license.
     
  28. Denchi_

    Denchi_

    Joined:
    Dec 17, 2018
    Posts:
    23
    Fair enough. The only thing I dislike about the Unity asset store license is that it makes it impossible to directly use code from free assets in open source projects. I see many people doing it anyway, but technically it's not allowed.
    So the way it is currently, I have to tell people in my README to "download free asset X from the asset store after opening the project", which isn't a big issue but still a bit odd.

    Anyway, this probably isn't the right place to discuss licensing issues. Thanks for at least considering and providing such high-quality assets for free.
     
    Darkcoder likes this.
  29. nankink

    nankink

    Joined:
    May 6, 2017
    Posts:
    15
    Hi, I'm using Lean Touch in my prototype since it has angle detection of the swipe! I'd like to make the player face de direction of the swipe and make it move towards it, like a having a dash following the swipe.
    The player faces the angle of the swipe beautifully! The problem is that I want the distance of the swipe impacts on the distance that the player moves towards the direction of the swipe. Using Rigidbody.MovePosition makes him teleport, I believe that's because the function is not running on FixedUpdate. Do you have any idea how can I make a smooth movement?
     
  30. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    It depends how you want it to work. Since your player is using a Rigidbody, do you have some kind of character controller? If not, you would need to write one. Movement could be as simple as setting the velocity to 'forward' for 'n' seconds. This gets complicated if you want your character to be able to react to colliders in the way though.
     
  31. nankink

    nankink

    Joined:
    May 6, 2017
    Posts:
    15
    I assumed that the MovePosition would be enough to move the player using the swipe, since I read somewhere that using velocity for movement is kinda messy. Haven't tried using Character Controller tho, or do you mean by writing a script from zero?
     
  32. narotuali

    narotuali

    Joined:
    Oct 23, 2018
    Posts:
    6
    man i have lean touch +
    but i didn't know how to use mobile joystick your documentation not clear and i didn't get an example of how to use joystick
     
  33. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Back from my holiday guys, as soon as I work through this backlog I'll be working on new updates to the Lean assets :)

    Movement using velocity is indeed messy, but it also allows for more realism. MovePosition is the same as changing the transform.position directly, so it will sort of bypass any collision and physics interactions on the way. This is great if you want to move your character a specific distance, or instantly, but it can look bad if you want to react to hitting objects on the way there. A character controller could be the basic one that comes with Unity, or a custom one written from scratch in C#, it really depends on what you need.

    Also, the SwipeUnderTranslateRigidbody demo scene shows you how to move the swiped object to the swipe end point smoothly using Rigidbody.velocity changes. This works using a remaining velocity system, so it still allows the object to hit things on the way.


    If you mean on-screen joystick controls, then these have been moved to the Lean GUI asset (free). The "14 Joystick" demo scene shows you how to build various types of joystick. You can then read the current joystick position/state using the ScaledValue property, or from the OnSet event, which gives you a Vector2.
     
  34. genstant

    genstant

    Joined:
    Sep 30, 2017
    Posts:
    1
    I'm trying to use LeanTouch to detect taps on sprites in a game where the camera settings are perspective. For that, I set the sprite etc. by imitating the Select2D scene. However, tapping on the sprite does not seem to be recognized unless the camera setting is orthographic.
    I think that it is necessary to change the Screen Depth inspector setting, but I did not know how to set it so that sprite taps could be detected.
    (Sorry in poor english)
     
  35. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    Hi @Darkcoder

    First of all, thanks for this great and easy to use library.

    I noticed that the first time a GameObject is spawned, its position is not correct in OnEnable.

    After getting a few more grey hairs, I was able to fix this, by changing the CreateClone method as follows:

    Code (CSharp):
    1. private GameObject CreateClone(Vector3 position, Quaternion rotation, Transform parent, bool worldPositionStays)
    2.         {
    3.             if (worldPositionStays == false && parent != null)
    4.                 position = parent.position + position;
    5.  
    6.             // var clone = Instantiate(prefab);
    7.             // with the above solution OnEnable is called before the position/rotation is set, resulting in wrong transform info for the first spawn
    8.             // we also need to use GameObject.Instantiate - using just Instantiate(prefab, position, rotation, parent) still gives the wrong position
    9.             var clone = GameObject.Instantiate(prefab, position, rotation, parent);
    10.  
    11.             if (Stamp == true)
    12.             {
    13.                 clone.name = prefab.name + " " + Total;
    14.             }
    15.             else
    16.             {
    17.                 clone.name = prefab.name;
    18.             }
    19.  
    20.             // Update transform
    21.             /*
    22.             var cloneTransform = clone.transform;
    23.  
    24.             cloneTransform.SetParent(parent, worldPositionStays);
    25.            
    26.             if (worldPositionStays == true)
    27.             {
    28.                 cloneTransform.position = position;
    29.                 cloneTransform.rotation = rotation;
    30.             }
    31.             else
    32.             {
    33.                 cloneTransform.localPosition = position;
    34.                 cloneTransform.localRotation = rotation;
    35.             }
    36.             */
    37.  
    38.             return clone;
    39.         }

    I would recommend that you update the code.
     
  36. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    @Darkcoder ok, I seem to be getting the same issue again when I use it in my actual project on a second scene. So the code above seems to work better for some cases, but it's not the solution for all cases. I guess using "void Start()" for the first time is the best solution.
     
  37. elfasito

    elfasito

    Joined:
    Jul 4, 2017
    Posts:
    51
    Hello, I practicing with the scene "switch" from lean gui module.
    I changed the size of the "switch" to adapt/scale to diferents screen resolution.
    but the script "Lean rect transform anchored position X" Uses a static float value for "position", and when I change the screen resolution, the switcher dont move to the correct position.

    Any guidance in the right direction to solve this?
    PD: Is what I try to explain understandable?.

     
    Last edited: Jan 11, 2020
  38. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    Pretty often I need to recognise Swipe gesture over particular UI element, like panel. I had to write my own script for that. Is there a way LeanTouch can provide it? I didn't find suitable solution using it.
     
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Good find, try THIS file. This should fix 2D selection when using a perspective camera :)


    Last time I modified this code I did quite a bit of testing with Instantiate and SetParent to try and get consistent behaviour, and I wasn't successful in all scenarios. It seems like these both behave differently, especially if the target Transform has scale, or is previously parented to something else. The code I use now is what I found to give almost identical results in 9/10 scenarios, but as you notice I modify the Transform values after instantiation, so you can't rely on the values in Awake or OnEnable.

    I'll take another look at the code and try to calculate these values ahead of time to fix this!


    This demo scene stores the anchoredPosition.x values in the "[Right Transitions]" GameObject. In your scenario you can change them to match your width. An easy way to do this is to manually adjust the value until it looks right, then click the "auto fill" button inside the LeanRectTransformAnchoredPositionX component. If your UI layout uses anchored positions rather than absolute, then you can instead transition the anchorMin and anchorMax values. It looks like there's no component for just the anchorMin.x and anchorMax.x values though, I should add them!


    If you need Lean Touch functionality, then Lean Touch+ comes with the LeanFingerDownCanvas and LeanManualSwipe components (CanvasSwipeMove demo scene), which can detect this. If you only care about detecting when you swipe over a UI element then you can get Lean GUI, which has the LeanSwipe component (Swipe demo scene), which can detect this.
     
  40. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    Yeah, i though i had it figured out, but results are just not consistent. I'm now simply using Start() if the GameObject is newly created and afterwards OnEnable(). Works fine.
     
    Darkcoder likes this.
  41. florianveltman

    florianveltman

    Joined:
    Sep 7, 2012
    Posts:
    27
    Hi Darkcoder,

    First off, thank you so much for the amazing assets you're providing, I'm so glad to have discovered your work.
    I'm looking to get touch interactions to work with a Canvas component set to
    Screen Space - Camera
    . The reason the Canvas is set to this, is because I require post-processing to affect the Canvas.
    I'm realising that with my setup, the
    StartedOverGui
    flag doesn't detect my UI, so I'm wondering if there's either something I can change in the Lean Touch code for this, or if there's an example I can look at for this specific case, or something else?
    Apparently the PostProcessing Stack can affect UI, so I might look into that, though I'd like to avoid implementing something as big as that as this point in this project!

    Thanks in advance for your help!

    Edit:
    I figured out what was going on: my Canvas didn't have a
    Graphic Raycaster
    component, which was obviously causing some trouble, haha!
    I'm leaving the post anyhow but now it's just to thank you for your amazing contribution to the Unity game developers.
     
    Last edited: Jan 17, 2020
    Darkcoder likes this.
  42. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Thanks, glad you found a solution :D
     
  43. splitter77

    splitter77

    Joined:
    Feb 25, 2018
    Posts:
    14
    Hello Darkcoder, I have a problem with time.timscale impossible to pause on the transitions, I tried all the possible settings but nothing.

    I do not see where the problem is :(

    however, I put the leantransition component and the leantime component.

    thx
     
  44. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Thanks for pointing this out, I've found the issue and improved all the code related to transition timing. I'll send you a private message with an updated build :)
     
  45. splitter77

    splitter77

    Joined:
    Feb 25, 2018
    Posts:
    14
    thank you thank you thank you for the update , it works like a charm!
     
    Darkcoder likes this.
  46. tatecreative

    tatecreative

    Joined:
    Apr 24, 2017
    Posts:
    21
    Hey there, just discovered this tool and it looks great. Please take a look at the linked video below. I'm looking for a solution that offers the same functionality—two finger rotate, 1 finger rotate on all axis, pan, pinch to zoom. I installed the LeanTouch version in a demo project and I don't see a demo with all those features. Do you have docs on implementing something like this?

    https://www.dropbox.com/s/detduipmw0hj6fn/RPReplay_Final1579902886.mov?dl=0

    Thanks!
     
  47. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    The pan controls can be done using the Sidescroll3D demo scene setup, and the camera relative twist + scale can be done using the Transform3DRelative setup.

    The object-relative rotation controls can be done using LeanTouch+ with the DragTurn2D demo scene setup (perhaps you would also need to change the LeanManualRotate.Space setting to Self).

    You can make these controls work using 1 or 2 fingers based on the Use > Required Finger Count setting on most components.
     
  48. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    Hi @Darkcoder

    I see you released 1.2.3 and according to the release notes it sounds like you were able to fix the issue.
    That's great, many thanks!
     
  49. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Indeed, I did some testing and the current code matches Instantiate for all the important scenarios. Thanks for pointing it out. Let me know if you encounter any other issues :)
     
    iddqd likes this.
  50. tatecreative

    tatecreative

    Joined:
    Apr 24, 2017
    Posts:
    21
    Thanks for the reply @Darkcoder. I downloaded a copy of + and am looking at the dragturn2d, which is cool, but that only satisfies rotation on two axis. What about rotating on all 3? Please take a look at the linked videos:
    Example:
    https://www.dropbox.com/s/phcfbvy2i1ddyxg/RPReplay_Final1580267467.MP4?dl=0
    - I can rotate the object on any of the 3 axis, no pinch twist required.
    - Rotate on X to Y, Y to Z, etc, etc

    https://www.dropbox.com/s/5wsc592gnzi207q/test1.mov?dl=0
    - I've set my object to use the same Lean+ elements as the drag2d example
    - https://www.dropbox.com/s/kwa8zzedfskf9gz/Screenshot 2020-01-28 22.17.43.png?dl=0
    - I can only rotate on 2 of the 3 axis
    - There seems to be some weird drifting happening, where is that coming from? (this is a separate issue)

    - I also applied the Lean Pinch Camera and Twist Camera to my main camera, which allowed me to rotate and zoom, however, the relative rotation of the object is not recognized and the same 2D drag behavior described above occurs.
    - https://www.dropbox.com/s/ntbllw852d61au9/test3.mov?dl=0

    I'd also like to take advantage of the 2 finger twist rotate and two finger zoom on top of the 3D drag rotate

    How would I accomplish the above?

    Thanks!
     
    Last edited: Jan 29, 2020