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
    You can use the LeanConstrainToCollider or LeanConstrainToColliders components for this, they're shown in the ConstrainToCollider and ConstrainToColliders demo scenes :)
     
    BEST-Thanawat likes this.
  2. Djaydino

    Djaydino

    Joined:
    Aug 19, 2012
    Posts:
    48
    Hi.
    i recently updated Leanpool in our project and all the LeanGameObjectPool.cs that are on a Prefab Variant got disconnected.
    i lost connection a few times before when using github and on other end they forgot to close unity (probably GUID got changed/lost) and when they re import all it got back connected.

    But this time it happend on my end and re import does not help this time.
    also after update several prefabs where spawning on wrong position due to worldPositionStays default was set to 'true' when i checked your script i noticed that some where set as true and some as false.

    I am using unity 2018.4.13f1 btw
     
  3. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    The prefab is stored using:

    Code (CSharp):
    1. [SerializeField] [UnityEngine.Serialization.FormerlySerializedAs("Prefab")] private GameObject prefab;
    So any loss of data is unlikely to be an issue with my code.

    You're right about the inconsistency with the worldPositionStays value though, not sure how I missed that! I'll add it to my to-do list and make sure it stays as consistent with Instantiate as possible.
     
  4. RhinoFreak

    RhinoFreak

    Joined:
    Dec 11, 2017
    Posts:
    6
    Hi! First of all a huge thanks for creating this awesome library, it makes life much much easier.
    I am facing an issue with Lean Select functionality where my prefab instantiated will sometimes not be selected at all. I can click, touch, swipe and whatever but it doesn't get selected (I checked in inspector, object was not responding). It is completely random and I wanted to seek your guidance on what could be the issue.
    Oddly enough, if I instantiate another copy of this same Prefab at the same place, it would sometimes fix the non-selectable prefab as well and I can drag and move both one by one.

    Information on the objects at play:
    I have a Prefab that has the scripts LeanSelectable and LeanDragTranslate, you can check the scripts in inspector here:

    The OnSelect and OnDeselect methods aren't doing anything but setting a value of bool.
    Code (CSharp):
    1.  
    2.     public void OnSelect()
    3.     {
    4.         isBeingHeld = true;
    5.     }
    6.  
    7.     public void OnDeselect()
    8.     {
    9.         isBeingHeld = false;
    10.         StartCoroutine(ResetPosition());
    11.     }
    12.  
    13.     private IEnumerator ResetPosition()
    14.     {
    15.         yield return new WaitForSeconds(0.075f);
    16.         if (!isInteracting)
    17.         {
    18.             transform.position = initialBurgerPosition;
    19.         }
    20.     }
    I have the Down To Select (2D) and LeanTouch object in my scene and normal touch on other objects work fine. Here is a screenshot of Down To Select (2D) from inspector.


    Some more info on the prefab being instantiated:
    Here is the code that instantiates it:
    Code (CSharp):
    1. instantiatedBurger = Instantiate(burger, transform.position, transform.rotation);
    2. instantiatedBurger.GetComponent<Burger>().InitialiseBurger(FoodMenu.Instance.burgerItems[menuId], isBurgerValid, isOrdered);
    3.  
    Here is the Initialization method:
    Code (CSharp):
    1. public void InitialiseBurger(BurgerItems burgerData, bool validity, bool ordered)
    2. {
    3.         ingredients = burgerData.ingredients;
    4.         burgerPrice = burgerData.burgerPrice;
    5.         isBurgerValid = validity;
    6.         isBurgerOrdered = ordered;
    7.         initialBurgerPosition = transform.position;
    8.  }

    Any insights or help at all would be greatly greatly appreciated because I cannot seem to find the cause of this bug.
     
  5. Breathing

    Breathing

    Joined:
    Apr 16, 2016
    Posts:
    7
    Hey Carlos!
    Lean GUI Shapes are really cool. Before I used Procedural UI, but your asset has more features and can blur! YAY!
    But there's a feature that I haven't found anywhere — cool UI outline.
    Standard Outline in Unity has no blur settings, and it doesn't adjust well.

    Now I have to use procedural UI or lean shapes with positive thickness for an outline, but it has some problems - each UI element has to be duplicated to add a outline. With these things, you can only make an inner outline (otherwise you have to make a filling anchor preset and set indents to -1).
    Do you plan to make an Outline component?
    This will help us a lot.
    Thank you!

     
  6. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    This sounds like it might be an issue with the selection of your object, rather than your script on the object. Can you try adding a really basic selectable object to your scene and seeing if it has these issues? If so, maybe you have UI elements on your screen that are unexpectedly blocking your selection attempts? You can try disabling your UI to test this.


    Good ideas! I agree, outlines are super useful. However, implementing them inside the shape components would make them very complex. What if you want two outlines? What if you want to animate it? etc

    I think a simpler better solution is to have some kind of setting to offset the outer edge of the shape, that way you wouldn't have to fiddle with the transform values so much, and it would make animation quite easy. What do you think?
     
    Breathing likes this.
  7. Breathing

    Breathing

    Joined:
    Apr 16, 2016
    Posts:
    7
    I don't think you have to put it right into shape.
    Before making the interface layout in Unity, I design it in Figma.

    It has a handy concept — you can add multiple fill and strokes at one layer w/ different parameters.

    Setting to offset the outer edge is a cool idea, but the edge will need a different rounding radius.

    Anyway, I will be very glad to be able to add the outlines to the figures, there are hundreds of pixel-perfect elements in our project, it will save me dozens of hours of work :)
     
  8. NFMynster

    NFMynster

    Joined:
    Jul 1, 2013
    Posts:
    71
    Hello!
    I'm writing regard a slight inconvenience on the LeanPool asset.
    We are using the preload method quite a bit, that you added as a menu item to the script, lovely.

    There are two slight inconveniences with this though.
    1. When you preload through that, it doesn't retain the link to the actual prefab it preloads. So if you make changes, you'll have to "de-preload" (not using despawn for term clarity here haha)
    2. When you want to "de-preload" all, ie remove all the preloaded prefabs, you have to remove them all manually. However, this makes the "despawned" list have xxx references to now deleted prefabs. You therefor gotta go into the debug inspector and set the despawned list count to 0.
    Edit:
    A potential fix to the second point, is simply to have a menu item that destroys/removes all the preloaded copies.
    What are your thoughts on this @Darkcoder ?
    Thank you.
     
  9. gferrari

    gferrari

    Joined:
    Jan 14, 2015
    Posts:
    135
    Hi! I want to know how I can limit my touch to one finger. For example if the user is pressing down I don't want other finger in the screen. Thanks!

    upload_2020-5-2_13-53-46.png
     
  10. Lindbrum

    Lindbrum

    Joined:
    Sep 28, 2019
    Posts:
    5
    Hello there! I've been using LeanLocalization as soon i started worrying about localizing my project and it's been a pretty smooth experience so far. Today, i have experienced a bug where trying to set one or more tokens using LeanLocalization.SetToken(name,value,allowCreation) is generating new tokens instead of setting the already existing ones. I'm currently using version 1.3.4 but i'll update as soon as i have done the project backup. As you can see from the image, the "LVL1" and "LVL4" tokens (used to show the first and fourth team members' levels, starting from the top) have been successfully set, while the rest have been ignored and now have duplicates. I'm not sure why this is happening however i might add that i'm setting them all in a "for" cycle that iterate on the string array {"LVL1","LVL2","LVL3","LVL4","LVL5"} for the names. I'll try diving into your code and see if i find what's going on in the meantime!

    Thanks in advance for your help!

    EDIT: Forgot to mention i'm working on unity 2020.1b
     

    Attached Files:

    • lean.jpg
      lean.jpg
      File size:
      206.4 KB
      Views:
      340
  11. FabianMartin

    FabianMartin

    Joined:
    Nov 5, 2016
    Posts:
    4
    Hello,
    I have the same problem. After analyzing the code a bit, I found the possible cause in the file LeanTranslation.cs.

    In line 145 it checks if the translation matches the current value. Only if this is not true, the event handlers for the tokens are registered. If no current value is passed, the translation is used for comparison.

    If I remove the check, the tokens work as expected.

    Code (CSharp):
    1.                 if (Match(currentText, current) == false)
    2.                 {
     
  12. RhinoFreak

    RhinoFreak

    Joined:
    Dec 11, 2017
    Posts:
    6
    Hey man, thanks a lot for reply! So I added in a basic selectable and well, it works. The item that I instantiate also works like 80% of the time.
    Some more context behind it is that I always spawn it at the exact same Vector3 position and there is no UI element anywhere close to that part of the screen. I don't know how to debug it either since when the bug actually happens, inside the inspector I am able to check that it is indeed NOT being selected despite me tapping/clicking on it.

    Do you have any ideas what else I can test and check?
    Perhaps some place inside the LeanSelect script I can put a Debug.Log() to see what method is not being called and perhaps why?

    Thank you so much for your time and help.

    PS: I was just playtesting trying to make it happen and it happened again, I know this screenshot isn't going to help but just attaching it still
    https://i.imgur.com/Dd5jUX2.png

    The "Regular Burger" in the hierarchy is the one that is not being selected as you can see in the Inspector window. The "GameObject" in hierarchy (small burger) is a test selectable object with a sprite render that was able to be selected even when the original one was not.
     
  13. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Hello,

    Quick question about the lean pool asset. Any idea it if it will work with pooling particle systems?

    Regards.
     
  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    I sent you a private message with an updated LeanBox component. This now includes the Inflate setting, which allows you to much more easily layer boxes to create more complex outlines.


    Good idea, the attached package should update LeanGameObjectPool to include the Clean() method, which will destroy all despawned clones. I didn't actually consider the scenario of changing the prefab in edit mode. In this scenario it may also be a nice idea to make the editor spawned clones retain their prefab link, and to also detect if the link is broken and warn you.

    LeanFingerDown is designed only for handling inputs on a per-finger basis. If you want controls that depend on others then you should hook into OnGesture, or in Update you can call LeanTouch.GetFingers or LeanSelectable.GetFingers and manually filter them yourself based on count, etc. You could call LeanTouch.GetFingers within that method to check the finger count though.

    Where in the program life cycle are you adding these tokens?

    If you add them before the existing tokens are registered to LeanLocalization, then this could happen.

    The tokens are initially registered from LeanLocalization.OnEnable, which calls UpdateTranslations, which is where all tokens will be registered.

    If your code runs in OnEnable or Awake then you can try increasing your script execution order (or decreasing LeanLocalization+LeanToken).

    Thanks, I'll check it out.

    In this case something about your object is causing it to not select properly. I recommend you make a new scene with just the bare minimum to debug this issue, and you adjust settings until you figure out what that is, as it's probably quite simple. To test the code you could debug your project in VS, add a breakpoint inside LeanSelect, and see what the UI raycast results give, etc.

    No idea, last time I tried I think they automatically stop/start with the GameObject activation, so no extra script was necessary to support them.
     

    Attached Files:

  15. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Thank You.
     
    Darkcoder likes this.
  16. NFMynster

    NFMynster

    Joined:
    Jul 1, 2013
    Posts:
    71
    Right, yeah, we are using the preloaded gameobject pools inside the scene, and they don't retain the prefab link. That's a bit impractical since we might forget to "refresh" the pools, however, that's now a bit easier with the clean context menu.
    Thanks for the updated package, will wait patiently for the prefab-link feature as that'll make it all tie together nicely.
     
  17. alinehuf

    alinehuf

    Joined:
    Nov 16, 2019
    Posts:
    2
    Hi !
    Thank you very much for your great LeanLocalization library. I was looking of a internationalization tool and yours is really great, really easy to use and it works well.
    I've just a small difficulty when I want to load a text with Lean.Localization.LeanLocalization.GetTranslationText() in the Start() method of a MonoBehavior object. The text is correctly loaded if I use exactly the same instruction inside the Update() method for exemple, but in the Start() method, I systematicaly get the fallback text. Did I miss something ? How can I load a text into the Text component of an object at start from C# ?
     
  18. Lindbrum

    Lindbrum

    Joined:
    Sep 28, 2019
    Posts:
    5
    Thanks a lot,
    I feel stupid i didn't think about script execution order. Having LeanToken + LeanLocalization run before default time fixed it.
     
  19. yohanscritch

    yohanscritch

    Joined:
    Apr 30, 2020
    Posts:
    28

    Hi there,

    I run into the same problem. I have Lean Localization as a game object, and in one of my Monobehavior object, I call in the Awake function():

    Code (CSharp):
    1.  private void Awake()
    2.     {
    3.      
    4.         Text Pitch = GameObject.Find("Pitch/Text").GetComponent<Text>();
    5.  
    6.         Pitch.text = Lean.Localization.LeanLocalization.GetTranslationText("Mytranslation");
    7.     }
    But my text doesn't update, just like Lean hadn't time to initialize and my translations are not ready yet.

    What should I do ?

    Thanks,
     
  20. yohanscritch

    yohanscritch

    Joined:
    Apr 30, 2020
    Posts:
    28
    Anyone from support here?
     
  21. Lindbrum

    Lindbrum

    Joined:
    Sep 28, 2019
    Posts:
    5
    Hi, that's likely caused by the script execution order. Just as i was suggested (scroll up a bit), try making "Lean.Localization.LeanLocalization" run before the default time in "Project Settings -> Script Execution Order" (for good measure in case you will be using tokens, also make "Lean.Localization.LeanToken" run before LeanLocalization).
     
    alinehuf likes this.
  22. alinehuf

    alinehuf

    Joined:
    Nov 16, 2019
    Posts:
    2
    Thank you very much for that answer, I hadn't seen the previous answer of Darkcoder. I was able to get the desired result by changing the scripts execution order as you advise, by placing my script at the end then adding Lean.Localization.Localization and Lean.Localization.LeanLanguageCSV well before (my translations are loaded from a CSV file).
    Thanks again!
     
    Lindbrum likes this.
  23. xahdpe

    xahdpe

    Joined:
    Mar 26, 2017
    Posts:
    6
    Hello guys,

    Trying to make a carousel with multiple items.
    to simplify things, i positioned all my carousel items in line under the fake parent and on swipe event (left or right, configured via Lean Finger Swipe components), i execute the following code:
    Code (CSharp):
    1.     public void ToPrevious()
    2.     {
    3.         var moveToPosition = MoveToPosition(fakeParent, new Vector3(
    4.             fakeParent.position.x - lengthBetween,
    5.             fakeParent.position.y,
    6.             fakeParent.position.z
    7.         ), 0.5f);
    8.         StartCoroutine(moveToPosition);
    9.     }
    where lengthBetween is a fixed value.

    it would be great if somebody can help me find out how to deal with inertia here, (basing on the length and speed of swipe).

    thanks!
     
    Last edited: May 22, 2020
  24. tonygiang

    tonygiang

    Joined:
    Jun 13, 2017
    Posts:
    71
    Hi. Will there be Lean Transition support for Light components? (Light 2D included)
     
  25. TheFlyHawk

    TheFlyHawk

    Joined:
    Mar 23, 2016
    Posts:
    58
    Hopefully the Lean Box can add texture slots, like this

    20200526191953.png
     
  26. xahdpe

    xahdpe

    Joined:
    Mar 26, 2017
    Posts:
    6
    hello guys,

    I want to know, what is the best / right way to implement Z-axis translation on swipe in/out. right now, i'm trying to achieve it via (MultiPinch + Manual Translate RB) for Z-axis and (Translate) for X,Y-axis.
    But unity acts wierd here.

    update: set "required finger count" on drag translate rigid body solved the issue.

    thanks!
     
    Last edited: May 29, 2020
  27. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    107
    Hey Carlos, is it possible to rotate the dial so it rotates along a different axis? For all the examples, the dial is horizontal (as if on the floor), but instead I'd like to rotate it whichever way and still be able to work. So, for example, if I rotated it so like it's on a wall (vertical).

    To replicate, in the DialLever example, if you rotate the "Selectable Dials" object so the x rotation is -90, I'd like the lever to still work.

    Thanks!

    edit: I tried to setting up a scene, where I created a similar lever but along the axis I wanted, where I ended up with my Dial script with an axis of z = 1, but when it rotates, it goes in the opposite direction in which I'm gesturing.
     
    Last edited: May 30, 2020
  28. Bentoon

    Bentoon

    Joined:
    Apr 26, 2013
    Posts:
    98
    @Darkcoder
    Hello Carlos,
    Thanks for the +
    I love the OrbitDolly Example but I need a Tracking(w 3 fingers) /
    1 finger rotates
    2 TwistPinch and Zoom
    3 Would Track

    I almost have it with a "Lean Drag Camera" but am at a loss
    Please help
    Thank you So much
    ~be
     
  29. yohanscritch

    yohanscritch

    Joined:
    Apr 30, 2020
    Posts:
    28
    Hi @Lindbrum, @Darkcoder

    Thanks for that explanation. I'm afraid I just did it but it does not change the problem, my strings are still empty. Here is my newly updated script order:

    Capture d’écran 2020-05-31 à 02.08.39.png

    Any other idea for my trouble?
    FYI, I'm loading just 2 variables (not even huge volume or CSV)

    EDIT:

    I tried to reproduce the problem on the examples of the plugin. In order to recreate it, just follow these really quick steps:

    1- Open Examples/02 - Phrase
    2- Add the following script on "LeanLocalization" object:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class test : MonoBehaviour
    7. {
    8.     void Awake()
    9.     {
    10.         Debug.Log(Lean.Localization.LeanLocalization.GetTranslationText("Hello"));
    11.     }
    12. }
    13.  
    3- Run and see the console: it should display "Hello" but you'll get a "null".
     
    Last edited: May 31, 2020
  30. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    107
    Don't worry about my question. I think I've figured something out, so I'll keep having a play. Thanks for a great asset :)

    edit: I'll note what I'm doing just in case someone else is trying to do the same thing: I'm using the LookAt example as a base, and then adjusting ScreenDepth of MultiSet script to Depth intercept, and then RotateTo of RotateToPosition to Side2D.
     
  31. Develax

    Develax

    Joined:
    Nov 14, 2017
    Posts:
    67
    Actually it is not initialized even in
    Start
    or
    OnEnable
    , I checked it. The
    CurrentTranslations
    list is initialized only when
    LeanLocalization.Update()
    is called. So, the only solution to have it initialized in
    Start
    could be making
    Start
    a coroutine and waiting for the 1-st frame with
    yield return null
    .

    Or, as it was suggested by Darkcoder, you could use
    LeanLocalization.OnLocalizationChanged
    event.
     
    Last edited: May 31, 2020
  32. yohanscritch

    yohanscritch

    Joined:
    Apr 30, 2020
    Posts:
    28
    Thanks Develax, any chance to direct me to a example or give me a snippet code, as I've never used events handling so far?
     
  33. Bentoon

    Bentoon

    Joined:
    Apr 26, 2013
    Posts:
    98
    Hello, I figured some of it
    I need to orbit the camera around a stable point because I am Baking scenes so they must be static
    I use the OrbitDolly example for this and add a "The Lean Drag Camera" with a "Lean Multi Set" for a 3 finger drag...
    to the "move to selection function"

    Thanks for the awesome work Carlos @Darkcoder

     
  34. Develax

    Develax

    Joined:
    Nov 14, 2017
    Posts:
    67
    From my point of view it is even easier not to use the event:

    Code (CSharp):
    1.  
    2. private IEnumerator Start()
    3. {
    4.     // Do everything you need here except for localization.
    5.     yield return null;
    6.     // Localization is ready.
    7. }
    But if you'd like to...

    Code (CSharp):
    1. private void Awake()
    2. {
    3.     LeanLocalization.OnLocalizationChanged += OnLocalizationChanged;
    4. }
    5.  
    6. private void OnDestroy()
    7. {
    8.     LeanLocalization.OnLocalizationChanged -= OnLocalizationChanged;
    9. }
    10.  
    11. private void OnLocalizationChanged()
    12. {
    13.     // Localization is ready.
    14. }
    Or you can combine them both:

    Code (CSharp):
    1.  
    2. private static bool _isLocalizationReady;
    3.  
    4. private void Awake()
    5. {
    6.     LeanLocalization.OnLocalizationChanged += OnLocalizationChanged;
    7. }
    8.  
    9. private void OnDestroy()
    10. {
    11.     LeanLocalization.OnLocalizationChanged -= OnLocalizationChanged;
    12. }
    13.  
    14. private void OnLocalizationChanged()
    15. {
    16.     _isLocalizationReady = true;
    17. }
    18.  
    19. private IEnumerator Start()
    20. {
    21.     // Do everything you need here except for localization.
    22.     yield return new WaitUntil(() => _isLocalizationReady);
    23.     // Localization is ready.
    24. }
    25.  
    But again, the 2nd & 3rd examples are just unnecessary complications of the 1st one. And you should be careful with the
    Start
    method which normally is called before any
    Update
    calls, but in this case, its part after the
    yield
    statement will be called after the first
    Update
    . Another caution is that
    LeanLocalization.OnLocalizationChanged
    is called even in editor mode.
     
    Last edited: Jun 1, 2020
  35. yohanscritch

    yohanscritch

    Joined:
    Apr 30, 2020
    Posts:
    28
    Thanks, I just used your first method and it works correctly. Maybe this example should be one of the few that are shipped with the package, as I assume some others may encounter this problem of using Lean combined with Start/Awake methods.

    Thanks a mil',
     
  36. Develax

    Develax

    Joined:
    Nov 14, 2017
    Posts:
    67
    You're welcome.
    That's why I switched to the public thread. I believe, however, the best solution would be if the author moved Lean initialization time to the
    Awake
    (or at least to the
    Start
    ) method.
     
  37. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Sorry for the late replies everyone!

    Just submitted a new version that has this feature.


    Try package adds a Light.color transition: https://www.dropbox.com/s/uo78rlmedc7fv75/LightColor.unitypackage?dl=1

    I'm developing Lean Transition with 2018.4.0f1 which doesn't have 2D lights though, so that will have to wait a bit.


    You can do this using a UI Mask with your image as a child. Combining it with the LeanBox itself to make the edges smooth is trickier though, but I plan to add this eventually.


    Nice, you solved it all then?

    The reason why I initialize everything in OnEnable is because when hot/assembly reloading, only OnDisable and OnEnable get called. If you move initialization to Awake/Start then in this scenario the translations will break. It would be possible to perform it in both though, I'll add it to the to-do list.
     
    NFMynster likes this.
  38. tonygiang

    tonygiang

    Joined:
    Jun 13, 2017
    Posts:
    71
    Thanks, this package worked correctly. Please support other properties of Light too, especially intensity and range. They are gonna be so nice when combined with Lean Pulse.
     
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Try this :D
     

    Attached Files:

    tonygiang likes this.
  40. tonygiang

    tonygiang

    Joined:
    Jun 13, 2017
    Posts:
    71
    It works! Now I have a simple warning light just by a Lean Pulse + Light.intensity transition combination!
     
  41. paulindrome

    paulindrome

    Joined:
    Mar 10, 2018
    Posts:
    36
    Hello there!

    I am currently trying to replicate Google Maps touch controls for a client and with your LeanTouch components I am making good progress. :)
    Thank you so much for an easy-to-use asset with so many possibilities!

    Using LeanPinchScale on my CameraTarget object to which the main camera is parented to zoom in and out of the scene works nicely, though the wrong way around (pinch in should zoom out, not in).
    Is there a way to revert the direction of LeanPinchScale?

    Edit:
    I frankenstein'd it by adding a bool to your LeanPinchScale script and using GetPinchRatio instead of GetPinchScale if it's true. It's a testament to your VERY nice code, however it feels hacky to me.
     
    Last edited: Jun 4, 2020
  42. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    This is because LeanPinchScale is designed to scale an object in the camera view, not the camera itself. You could add this component to a map object in view and have it work the right way around, though your change is fine too. In LeanTouch+ there is the "Sidescroll2DZoomRotateMap" demo scene, which implements camera controls similar to Google Maps though :)
     
  43. adelinegames

    adelinegames

    Joined:
    Oct 3, 2019
    Posts:
    2
    Hi,

    First of all, I would like to thank you for this wonderful work you have done. The best input control asset I have found in the asset store. I recommend it to anyone interested in mobile game development.

    On the other hand, I have identified some points we can improve.

    1. GameObject Reference: Some components can take target gameObject as reference for organization (like LeanManualRotate). however, many components do not. (Like LeanDragTranslateRigidbody). this is incompatible with organizational discipline.

    2. Step Value Error: It seems there is an error in the LeanStepValue2D component. When the control is resumed without waiting for dumping to end, final transform of the object becomes different than expected.

    3. Rigidbody Performance Issue: There are some performance problems with LeanDragTranslateAlong and similar physics components. I think it would be useful to review it.

    Thank you again. I wish you good work.
    Samet
     
  44. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Thanks for the feedback!

    1 - I agree, there's some inconsistency here. I'll see if I can improve this in the next or next-next update.

    2 - I've already rewritten this component into the new LeanThresholdPosition and LeanThresholdDelta components, which should fix any issues and add new options. These will appear in the next version.

    3 - Is this component causing actual lag, or just the appearance of lag? LeanDragTranslateAlong performs the translation in Update, which may be out of sync with physics (FixedUpdate), thus making it look like your object is stuttering. This could be fixed by moving the code to FixedUpdate, or making a physics-specific version like LeanDragTranslateRigidbody.
     
  45. shin-sim

    shin-sim

    Joined:
    Dec 16, 2015
    Posts:
    4
    I'm using Lean GUI,
    how can I make Image/RawTexture to have drag & resize together?
    I'm trying to make some picture gallery.
     
  46. Darkcoder

    Darkcoder

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

    Version 2.1.1 of Lean Touch & Lean Touch+ is now out!

    This includes lots of small tweaks to the components and demo scenes, but most importantly I restructured all the example scenes to be easier to follow. They're now grouped into folders, and sorted in order of the features they introduce. This should make it easier to find what you want, be easier to learn, and allow me to add new features quicker.

    Enjoy :)


    As long as your LeanResize drag handle is a child of your image (like in the Resize example), then you can add the LeanDrag component to the main image (e.g. Left/Right Box GameObject in the Resize example), and they should work together.
     
    Last edited: Jun 17, 2020
  47. haywirephoenix

    haywirephoenix

    Joined:
    May 17, 2017
    Posts:
    109
    Hi, I just purchased Lean shapes and it's great. Is it possible for Lean to automatically update the material instance to match the color (without changing the material directly, similar to how we have meshrenderer.sharedmaterial)

    For example in LeanBox.cs OnPopulateMesh I would have something like:

    Code (CSharp):
    1. vert.color = color;
    2.  
    3. if(m_Material != null)
    4.                 canvasRenderer.GetMaterial(0).SetColor("_Color",color);

    Note: I am only using a material because I need to have a shader that inverts the colours on light backgrounds to make it visible all the time. If Leanshapes can already do this it would be awesome.
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Unless each of your UI elements has a unique material, this wouldn't work. The UI automatically batches elements with the same material together, and this kind of code would just override all color changes until the last one gets used. You may be able to use material property blocks to automatically do this and break batching, but it would break batching for everything so it makes no sense to add. You should just make a second material with your inverted shader, and set it on your UI graphics you want t have inverted.
     
  49. Bentoon

    Bentoon

    Joined:
    Apr 26, 2013
    Posts:
    98
    @Darkcoder
    Not really. But I'm getting close and closer...
    Camera Orbits around the static model (1finger) & I Zoom in well (2 finger), but when I try and use 3 fingers to track in the above way it kind of works but throw off the Pivot. so I tried applying it to the Camera instead but to no avail

    Then I used the Lean Manual Translate with a "Lean Multi Set" for a 3 finger drag on the Pivot and it works well but the TranslateAB is global and when I orbit the X axis becomes the Y and it zooms

    Any ideas?
    I think the 1(rotate)/2(zoom)/3(track) around a static object could be a great Lean+ example
    Thank so much for your help
    ~be

     
  50. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    In the latest version (came out last week), I improved the organization of the demo scenes so you can find what you want more easily. Inside the the "Touch+/Examples/Camera" folder, you can see the "Orbit / Move" or "Orbit / Move / Top Down" demo scenes depending on your requirements, and you can modify the LeanMultiSet (for LeanPitchYaw), and LeanDragCamera to have a RequiredFingerCount of 1 and 3, and on the main camera you can add the LeanPinchCamera component with a RequiredFingerCount of 2. This should work as you describe, let me know if you encounter any issues.

    I plan to make a set of more 'game ready' scene setups that combine most of these into one, rather than making a massive tree of all the possible combinations.