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
    In that cast it must be a hardware quirk. I don't imagine the Android developer tools themselves would have such a serious bug :D
     
    jimmying likes this.
  2. karonte

    karonte

    Joined:
    Jun 2, 2013
    Posts:
    48
    Hi all. Just a simple question. I would like to create a class that hook quickly some "touch feature".
    Is there a method to quick return the "picked" gameobject in LeanTouch+? some "finger.selected" or something similar?
    I find solution in Raycasting from finger.ScreenPosition but i have problems when UI is over the 3d object.
     
  3. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    You can use your existing raycast code, but also include a call to Lean.Touch.LeanTouch.PointOverGui(finger.ScreenPosition) to see if you should ignore it or not.
     
  4. karonte

    karonte

    Joined:
    Jun 2, 2013
    Posts:
    48
    thanks. i used a check in the "UI" layer but i think your solution is smarter. I think also it could be great to implement the "current touched" object in the next release. i'm creating a configurator and i need to know what i'm touching. Good job with your assets!
    Regards.
     
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    LeanTouch comes with a selection system ("Lean/Touch/Examples/16 Tap To Select" demo scene) that can be used to do this. LeanTouch+ also comes with a picking system ("Lean/Touch+/Examples/Selection/09 Pickable" demo scene) that can be used for more complex scenarios where you need multiple types of selection at the same time.
     
  6. Tubestorm

    Tubestorm

    Joined:
    May 8, 2020
    Posts:
    6
    Hey,
    When instantiating with lean pool, how do you control the capacity for multiple game objects at Run time? I'm spawning a crowd of different game objects and I need to control the capacity for each character spawned. I have 1-100 different characters for reference. (Sorry if this question has already been answered, couldn't find much.)
     
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    See the "Lean/Pool/Examples/05 Capacity" demo scene. This can be configured the same way from code if you need to adjust the capacity at runtime.
     
  8. lbooster

    lbooster

    Joined:
    Jul 15, 2021
    Posts:
    1
    @Darkcoder Hi Carlos, first, I would like to thank you for creating Lean Localization, an excellent plugin! I am making my first game, and it has helped me a lot with localization. I am new to C# and game development, so the next question may seem silly though I have spent a lot of time trying to find an answer and have searched all the forums. I am trying to get a translation from the C# code using:

    Code (CSharp):
    1.  
    2. Lean.Localization.LeanLocalization.GetTranslationText("YourPhraseNameHere");
    3.  
    The code I have come up with looks like this:

    Code (CSharp):
    1.  
    2.     public void SetText(string txt, bool showButton)
    3.         {
    4.             if(txt == "TutorialLvl1Win0"){
    5.             textGUI.text = Lean.Localization.LeanLocalization.GetTranslationText("TutorialLvl1Win0");
    6.             button.SetActive(showButton);
    7.             } else {}
    8.         }
    9.  
    But, I get an error in the console:

    error CS0103: The name 'Lean' does not exist in the current context

    I have tried several things but to no avail. To be honest, I don't have a clue about what I am doing wrong but I am pretty sure is something simple I am missing. I really would appreciate your help!

    Thanks
     
  9. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    All of the Lean Localization code is inside the LeanLocalization.asmdef (assembly). Your code must be in an assembly that either compiles after this, or it must reference this manually. See HERE for more information.
     
  10. xahdpe

    xahdpe

    Joined:
    Mar 26, 2017
    Posts:
    6
    hello,

    I'm struggling to create an infinite (circular, which starts from the very beginning when all the values have been scrolled) scrollable list of 3d objects based on LeanTouch component.

    in the end, I came to the following setup:
    - parent element with "Lean Threshold Delta" and Finger Multi Update / Finger Swipe components to handle the swipe gesture.
    - list of children elements, each has Lean Manual translate component attached (each listens to the
    OnDeltaX event on the parent element and moves, when the event is raised).

    On start event, I placed first N objects of the *elements* array in one line (all the rest are disabled, they also should be disabled if moved outside the screen).
    then, I was trying to listen to "onDelta" event on the parent top object and move the visible objects by swipe, disabling the Nth element and spawning the new element (initially set as disabled) into the beginning of the line.

    my main problem is the fact that I cannot control the movement of the elements properly, when a swipe is relatively slow, it is ok - everything works, but when user swipes fast, everything turns into a mess :) objects overlap each other and some of them move faster then others.

    guys, can you please suggest if my approach is valid or you can propose some other architecture?

    thanks in advance!
     
    Last edited: Nov 30, 2021
  11. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    I would make a custom component that handles your element positioning and re-ordering based on a single float 'position' value. Then all you have to worry about is linking up LeanTouch events to modify this one value. I would then start by using LeanMultiUpdate, and then LeanFingerSwipe. Swipe might require you to add an additional velocity value though.
     
  12. karonte

    karonte

    Joined:
    Jun 2, 2013
    Posts:
    48
    Hi guys. I have to develop a Webgl project with Leantouch+. Unfortunately, I read that it doesn't support touch on mobile with WebGL. I found only that it will work with the new input system. Do you know a step-by-step procedure or a tutorial to create this setup? i see that only import the package doesn't work. Please help.
    Regards.
     
  13. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Just open the Package Manager window to the Unity Registry category and install the Input System package. Once installed it should ask you if you want to enable it and then restart the editor, and click yes. You should then see it set here:

    upload_2021-12-1_21-39-52.png
     
    karonte likes this.
  14. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    @Darkcoder is there any update? Really, it's so annoying - very hard to work within the scene like that.
     
  15. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Yes, I updated all Lean assets last week to fix this :)
     
    novaVision likes this.
  16. wurmmehl

    wurmmehl

    Joined:
    Aug 31, 2021
    Posts:
    11
    Hey,
    I have a problem with this part: Why do all my objects move at the same time?
    I have 2 objects and each has Drag Translate/Twist/Pinch Scale and Select by Finger. I have added the Selectable by Finger to the respective object (see image 1) and an object with the necessary settings (see image 2/3). Unfortunately now no movement works at all. They do not move together as before, but also not individually.
    Have I overlooked something?
    Thanks in advance.
     

    Attached Files:

    • 1.png
      1.png
      File size:
      74.3 KB
      Views:
      264
    • 2.png
      2.png
      File size:
      27.7 KB
      Views:
      271
    • 3.png
      3.png
      File size:
      79 KB
      Views:
      268
  17. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    LeanSelectByFinger uses raycasts, so your selectable GameObject needs a collider.
     
  18. wurmmehl

    wurmmehl

    Joined:
    Aug 31, 2021
    Posts:
    11
    Thank you. I had not thought that far ahead. I will try it out tomorrow.
     
    Darkcoder likes this.
  19. xahdpe

    xahdpe

    Joined:
    Mar 26, 2017
    Posts:
    6
    hi @Darkcoder!

    thanks for all your support and answers, I have some more of them :)

    I have the object with MultiUpdate and ManualTranslate components attached.
    on swipe, the object is slowly moving along the X axis.
    I also have a button that should pause the movement and continue it on the second click.

    so, can you please help me to understand how to properly calculate the remaining delta, which I can apply to the object on button's second click?

    thanks.
     
  20. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    In this scenario you should:

    1 - Create a custom script/component.
    2 - Add a public method to this component that accepts a Vector2 or Vector3, depending on which movement you use.
    3 - Connect MultiUpdate to this custom component's method via inspector event.
    4 - Connect your button to your component, and handle the pause/resume logic inside it.
    5 - Output the remaining delta to ManualTranslate based on your button logic.
     
  21. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Hi, a quick question regarding Lean Texture normal map preset:

    - What settings and texture inputs does it expect?

    - When I put a texture that's imported as Normal map into it, and use this texture's import settings as the source, the output is a darker blue texture (not valid tangent normal anymore).

    - Package demo doesn't include an example using normal map preset, so I am wondering if there is a bug in it. It definitely shouldn't be the default behavior.

    (PS: I usually pack texture with Substance Designer, so this is an attempt to make packing faster, but I do wonder if I should use this tool for the job...)

    (PPS: what's more confusing is using Color Only preset get me the correct normal output, but as documented, it is for SRGB/Gamma texture, which Normal map isn't; both Linear Color and Normal map mode gave incorrect output)
     
    Last edited: Dec 6, 2021
  22. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Actually, under Unity 2021.2 at least, even when packing Linear texture such as Metallic and AO, Color mode is still the correct option, Linear Color mode always output incorrect result, whichever settings I pick for the input textures.

    Perhaps the tool's preset mode is misleading in some ways, also since all of the demos use Color Only preset, it's hard to know if the other mode actually works as intended.
     
  23. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Even more problems:

    - Alpha in Unity should always be stored in Linear, but somehow the Color mode and Linear color mode output Alpha differently.

    - And I compared the source texture (which is just gloss map from Quixel Megascan) vs the saved result in Substance Designer, when I use Color mode to match their color space, the result texture is still wrong in a way: the Luminance histogram is no longer continuous, but show up as discrete bars, as if they have been quantized.

    So yeah, I will go back to using SD for now.
     
  24. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    When using the NormalMap preset, the input texture should be imported into Unity as a normal map, and LeanTexture should also export it as such. There should be no darkening occurring, but it's possible I made a mistake with the color space handling.

    I'll test these out later today when I'm free.
     
  25. wurmmehl

    wurmmehl

    Joined:
    Aug 31, 2021
    Posts:
    11
    Hey,
    sorry, it took a while.
    I have now given the two objects a box collider, but it still doesn't work. Do I have to link it to something else for it to work? Sorry, I don't have that much experience with Unity yet.
     
  26. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    As seen in your screenshot 3, you use LeanSelectByFinger with Search = GetComponentInParent. As long as the raycast is hitting a collider that's on your 'head' GameObject, or one of its children, it should work.

    Your LeanFingerTap is set to IgnoreStartedOverGui, so it's possible your screen has a full screen UI control blocking it.

    There are many potential issues that I can only guess about.

    Try copy + pasting your object into one of the example scenes that has selection that is known to work, and see what the difference is.
     
  27. wurmmehl

    wurmmehl

    Joined:
    Aug 31, 2021
    Posts:
    11
    Thanks for the answer.
    I'll keep trying around and see if I can get it to work, thanks for the help though.
     
    Darkcoder likes this.
  28. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    I tried using LeanDrag on a ScrollRect element but unsurprisingly it didn't work. Is there another component I can use with it or should I roll my own? I found some code on stackoverflow that might do it.
     
  29. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    You should put the LeanDrag component on a parent UI element that is larger than your ScrollRect, then you can drag it from outside. The ScrollRect will capture all drags performed within, and while there might be a way to override this, it would probably break the way it works unless you have some very specific usage in mind in which case you should roll your own.
     
  30. NotEvenTrying

    NotEvenTrying

    Joined:
    May 17, 2017
    Posts:
    43
    Hi, I've been converting a lot of my UI images to LeanGUI components, and was wondering if you could add an option to blur the radial edges of LeanCircles that are partially filled? At the moment the blur is not applied to the two edges that join the center to the circumference of a partially filled circle, leaving them jagged and aliased, especially as Unity's UI does not have aliasing. Thank you :)
     
  31. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    This is actually very difficult to calculate, which is why I didn't apply blur there :D

    I could make a simple version that works good enough for most scenarios though. I'm not sure how much free time I will have these next few weeks though, we'll see.
     
    NotEvenTrying likes this.
  32. yiki94

    yiki94

    Joined:
    Jan 17, 2017
    Posts:
    2
    Hello,

    I'm using Lean Touch to rotate an object in AR. How do you set it to 1 finger to rotate the object? I have already set the required finger count to 1 and nothing happened.
     
  33. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    If you're using the LeanTwistRotate component then it cannot function with 1 finger, because the twist gesture requires at least 2 fingers. To do one finger rotation you can use the LeanMultiTwist component that comes with LeanTouch+, which is shown in the "Lean/Touch+/Examples/06 One Finger" demo scene.
     
  34. NotEvenTrying

    NotEvenTrying

    Joined:
    May 17, 2017
    Posts:
    43
    Ah I see, I've currently been using another LeanBox and rotating it to line up with the edge of the fill as a workaround for now, doing that automatically internally should be fine too; doesn't have to be super "correct" so to speak, as the performance impact should be minimal anyways and it achieves the same end result, especially if its an optional checkbox :)
     
  35. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    305
    Hello
    Where can I find more documentation about LeanLocalization
    I would like to know what are the differences between the different CSV chaches, Load Immediately, Lazy Load, etc

    Is it possible to add translations dynamically as I use them, for example when starting a cinematic cut, can I load the CSV that will be used in the cut dynamically or I have to load a single CSV with absolutely every single translation from the beginning.

    I would like to keep CSV separate as per cut scenes rather than having a huge CSV file.

    Lastly, if I have to have a huge CSV file, how many keys LeanLocalization supports to load in memory? Is there any impact to performance?

    Thank you.
     
  36. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Just leave Cache at the default setting (Load Immediately), or read the code to understand it better.

    You can enable/disable CSV components or add and remove them from your scene at any time to save memory.
     
    Hazneliel likes this.
  37. yiki94

    yiki94

    Joined:
    Jan 17, 2017
    Posts:
    2
    I see, alright thank you for your reply!
     
  38. shacharoz

    shacharoz

    Joined:
    Jul 11, 2013
    Posts:
    98
    hi @Darkcoder

    opened my project in a new pc , and redownloaded LeanTouch package. now i have version 2.3.5, and not sure what i had before.

    i get these errors:
    'LeanSelectable' does not contain a definition for 'Select'
    'LeanFingerFilter' does not contain a definition for 'GetFingers'
    'LeanTouch' does not contain a definition for 'GetDampenFactor'
    'LeanTouch' does not contain a definition for 'GetCamera'

    any ideas if i need an older version? i do not want to spend time to upgrade to a new version. but this was working before.

    thanks for your work!
     
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    I sent you the earlier version via email!

    Last year I changed the selection system quite a lot. Before, it only worked with touches. However, I realized that in many scenarios you may want to select it without fingers (e.g. GUI). To support this I split LeanSelect into LeanSelect + LeanSelectByFinger, and LeanSelectable into LeanSelectable + LeanSelectableByFinger. The finger specific methods and settings are now in the ByFinger versions of these methods.

    I have some nice plans for the Lean asset series this year, and these changes will help a lot :)
     
    shacharoz likes this.
  40. shacharoz

    shacharoz

    Joined:
    Jul 11, 2013
    Posts:
    98
    ahhh! ok. i guess the quarantine helped :)

    so would you recommend me to try to replace my classes with "byFinger" versions, and it might have the same API?
     
  41. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    I recommend you not update any asset ever in the middle of your project unless it now has a feature you need. Updating assets after such a long time for no reason only leads to pain :D
     
  42. IceTrooper

    IceTrooper

    Joined:
    Jul 19, 2015
    Posts:
    36
    A small bug here (assignment in conditional)
    upload_2022-1-7_15-19-20.png

    LeanToggle.cs
     
  43. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    That will assign value to turnOffSiblings, and then call TurnOffSiblingsNow if it's true, so it should work as intended. This should be the equivalent of: turnOffSiblings = value; if (turnOffSiblings) TurnOffSiblingsNow();
     
  44. RatherGood

    RatherGood

    Joined:
    Oct 12, 2014
    Posts:
    22
    Hello. Is there a way to move GUI elements similar to your Lean touch swap example. Bought the Lean GUI and touch. Thank you?
     
  45. IceTrooper

    IceTrooper

    Joined:
    Jul 19, 2015
    Posts:
    36
    Ahh... omg, you're right that this works as intended. I mean, it's just an unconventional syntax assigning in the conditional, hah. Sorry ;p
     
    Darkcoder likes this.
  46. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    You can use the LeanManualTranslate component from LeanTouch+ to do this. The LeanSwipe component (as seen in the "27 Swipe" demo scene) can be used to detect swipes in a specific direction, and you can then connect the OnSwipe event to LeanManualTranslateA or B.

    upload_2022-1-12_13-1-0.png

    upload_2022-1-12_13-3-22.png

    You can also use LeanTransition to do this with the SwipeTransitions (Right Click -> Create), and set up the transition like this:

    upload_2022-1-12_13-2-57.png
     
  47. ChefoMR

    ChefoMR

    Joined:
    Apr 25, 2019
    Posts:
    7
    Hey there, thank you so much for your amazing work! I'm using Lean Transition and I'd like to transition between colors, but I'm not sure how to use the ease functions. This is my method and I'm getting an error that "Smooth" doesn't exist in the context. I've included the Lean Transition namespace. Thank you very much in advance for the help!
     

    Attached Files:

  48. Malveka

    Malveka

    Joined:
    Nov 6, 2009
    Posts:
    191
    I finally got to the stage in my project where I had to follow-up on the issues I was seeing (documented above) when using Lean Touch/Lean Touch+ on Windows 10 desktop. After a couple of hours of digging I discovered a relatively simple fix for the problem - sort of.

    By setting the "Use Mouse" checkbox OFF in the LeanTouch component in the editor, my strange scaling and rotating issues no longer occur. It seems that on desktop, one of your fingers when touching the screen also end-up counting as a mouse click and drag. So when doing the pinch to zoom and/or twist to rotate gesture with two fingers, Lean Touch is seeing three fingers - two hardware fingers and the mouse finger. Likewise, as soon as you touch with one finger, it sees two fingers that have identical positions, which can have some very strange results (e.g. pinchScale == 0 in LeanPinchScale, which causes the scaled object to disappear). Clearly problems like this are only going to occur when using a touchscreen on a system that also has a mouse.

    I'm happy to find this straightforward work around, but wondering if it would be possible make these touch mechanisms independent. In other words, if there are any real fingers touching the screen, the mouse/simulated fingers are discarded. Or something like that.

    I was hoping to supply my clients with the ability to use either the touchscreen or a mouse and keyboard if they happened to have one attached. As it stands, it seems it's not possible to use touch if you enable the mouse/simulation options.
     
  49. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    The Smooth method is part of the LeanMethod class. Unless you add your method to the LeanMethod class, you can't just call it like that. You must at least call LeanMethod.Smooth assuming you have: using Lean.Transition;


    Interesting. The LeanTouch code only adds mouse data if the input system says there is a mouse present. Perhaps the UnityEngine.Input.simulateMouseWithTouches setting is enabled, which may cause both to be sent. You can also try using the new InputSystem package from the package manager, which may have different behavior or settings. In earlier versions of LeanTouch I ignored mouse data if touch data was available, but I imagined there were edge cases where a user had a touch display and a mouse present and for some reason might expect both to work at the same time so I changed this.
     
  50. Malveka

    Malveka

    Joined:
    Nov 6, 2009
    Posts:
    191
    The UnityEngine.Input.simulateMouseWithTouches setting is indeed important. Seems it defaults to true. When I set it to false, I can enable Use Mouse and Use Simulator and everything works as expected. Woot!

    Perhaps our findings are worth a few lines in the Lean Touch documentation to save future desktop users some time.

    Thanks for your help with this!