Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

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

  1. IceTrooper

    IceTrooper

    Joined:
    Jul 19, 2015
    Posts:
    35
    1 - ok, now I understand what it does, but the most important question:
    If I want the same behavior (feeling) on every device's screen, should I change depends on screen dpi? Or just set once, for instance: 200 reference dpi and it works the same on every device?

    2 - oh man, you're great. I knew that your asset is prepared for everything! I knew it! : D I got LeanTouch+ and first thought was to write a script myself to accumulate those values, but it looks like we got LeanTresholdDelta component.
    One more question: I see that "Treshold" value is calculated by distance X, Y, Z. Is it possible to calculate it independently? So I'm only interested in every 5 on X-axis.

    Now I'm using OnDelta from LeanFingerUpdate with AddXY (obviously) calling. As you see, unfortunately, I need to call that method instead of AddX. Do you see any way of doing this without a custom script calling AddX on every OnDelta call? It's ok if there is no other way, your LeanTouch+ has already helped me a lot.

    For now I've made this simple sctript:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Events;
    3.  
    4. public class LeanVector2Splitter : MonoBehaviour
    5. {
    6.     [System.Serializable] public class FloatEvent : UnityEvent<float> { }
    7.  
    8.     [SerializeField] private FloatEvent OnX = null;
    9.     [SerializeField] private FloatEvent OnY = null;
    10.  
    11.     public void AddXY(Vector2 xy)
    12.     {
    13.         if(xy.x != 0f)
    14.         {
    15.             OnX.Invoke(xy.x);
    16.         }
    17.  
    18.         if(xy.y != 0f)
    19.         {
    20.             OnY.Invoke(xy.y);
    21.         }
    22.     }
    23. }
     
    Last edited: Sep 26, 2020
  2. dacoursey

    dacoursey

    Joined:
    Dec 17, 2016
    Posts:
    40
    Progress, I think. I deleted all the Lean game objects and started over. I also added in the LeanPool game object and I'm using the LeanGameObjectPool.Spawn method.

    It is now spawning my tree prefab but at 0,0 instead of under the tap. Is it not getting the proper coords from the LeanTouch object?
     
  3. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    1 - The way the scaled coordinates work is they make actions require the same physical distance to work, which for touch devices should mean the exact same finger movement, if this means the same 'feeling' then yes.

    2 - This is how LeanThresholdDelta works, it checks each axis independently. You can also enable the Step setting to make it output values in increments of Threshold. One thing I notice is that if you move only on the X axis, then it will still trigger the OnDeltaY and OnDeltaZ with values of 0. Perhaps I should make it skip these.


    Are you calling the Spawn method/function that takes the dynamic Vector3? If you don't, then it will spawn using its default position which will either match the spawning Transform, or the prefab.
     
  4. dacoursey

    dacoursey

    Joined:
    Dec 17, 2016
    Posts:
    40
    EDIT I fixed it, the coordinates weren't matching up. Updated code below EDIT

    I have a timing problem so things aren't quite firing in the proper order. But you can see the code is logging the total number of spawned trees and it is incrementing 1,3,5,7,9,10 where it starts recycling.


    Code (CSharp):
    1. if (touch.phase == TouchPhase.Ended && tapTimer < 0.3f) //checking for quick tap
    2. {
    3.     Debug.LogError("DETECTED TAP: " + touch.position.ToString());
    4.     Debug.Log(tapTimer.ToString());
    5.     Vector3 dropLocation = Camera.main.ScreenToWorldPoint(new Vector3(target.x, target.y, 10.0f));
    6.     TreePool.Spawn(dropLocation, Quaternion.identity);
    7.     tapTimer = 0.0f;
    8. }
    9. else if (touch.phase == TouchPhase.Moved)
    10. {
    11.     buildRoute();
    12. }
    13. else if (touch.phase == TouchPhase.Ended)
    14. {
    15.     completeRoute();
    16.     tapTimer = 0.0f;
    17. }
     

    Attached Files:

    Last edited: Sep 28, 2020
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    I don't see why you're doing basically the same code manually in your script and then in LeanFingerTap. In any case, you're doing this "TreePool.Spawn(touch.position, Quaternion.identity);", which will spawn the tree in world space using the finger's screen space coordinates, which is wrong. You must convert the screen space coords to world space, which is what the ScreenDepth settings from LeanFingerTap do.
     
  6. noomieware

    noomieware

    Joined:
    Jun 18, 2019
    Posts:
    18
    Using LeanTouch+ for Input in combination with the UI Toolkit Preview. It seems, the IsOnGui and StartedOverGui is not yet reflecting the UI elements generated from the Panel Renderer, though the GameObject hosting that PanelRenderer is on a layer I enabled as GUI Layer.

    In LeanTouch Code I understood, that it is based on a Raycast and LayerCheck. So that probably means, that the UI Elements do not react on Raycasts?

    Just wondering if some1 or the LeanTouch Maintainer ever tried it yet, otherwise I'd love to offer help in testing,
     
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    I haven't tried UI Elements/Toolkit yet. Once it leaves preview stage I will. Adding the new UI specific raycast code to the LeanTouch RaycastGui code should be enough to support almost everything though.
     
  8. livium

    livium

    Joined:
    Aug 3, 2018
    Posts:
    27
    UPDATE: I import again Lean Touch and Lean GUI and now it is ok.


    Hi.
    I update a project to Lean Touch+ at 2.1.7. and I got some errors. Can you please help?

    Assets\Lean\Transition\Scripts\LeanMethod.cs(173,31): error CS0103: The name 'Target' does not exist in the current context
    Assets\Lean\Transition\Scripts\LeanMethod.cs(221,55): error CS0103: The name 'Target' does not exist in the current context
    Assets\Lean\Transition\Scripts\LeanMethod.cs(225,28): error CS0103: The name 'Target' does not exist in the current context
    Assets\Lean\Transition\Scripts\LeanMethod.cs(249,30): error CS0103: The name 'Target' does not exist in the current context
    Assets\Lean\Transition\Scripts\LeanMethod.cs(272,19): error CS0103: The name 'Target' does not exist in the current context
    Assets\Lean\GUI\Scripts\LeanSwitch.cs(114,16): error CS0103: The name 'Target' does not exist in the current context
    Assets\Lean\GUI\Scripts\LeanSwitch.cs(119,58): error CS0103: The name 'Target' does not exist in the current context
     
    Last edited: Sep 28, 2020
    Darkcoder likes this.
  9. IceTrooper

    IceTrooper

    Joined:
    Jul 19, 2015
    Posts:
    35
    2 - Ahh, yeah, I think that was the problem. I moved finger on Y axis and still get values "0" or "2.19" OnDeltaX when Threshold was 8.

    1 - Ok, now it's clear what it means :)
     
  10. DYV

    DYV

    Joined:
    Aug 10, 2015
    Posts:
    58
    Hello. Is it possible to use Lean Pool with unity 2018.1.9f2? For some reason I would not like to switch to another version
    Thank you
     
  11. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    It should still work in older versions. You may need to run a newer version to download it though. 2018.4.13f1 added the ability to specify asmdef references that do not exist in the project, which is important for optionally supporting the InputSystem and possibly other packages in the future.
     
  12. dacoursey

    dacoursey

    Joined:
    Dec 17, 2016
    Posts:
    40
    Without the manual code, it still wouldn't spawn the tree under the finger. It wasn't until I was logging how many were used in the pool that I was even sure things were spawning at all.

    I'll run another test in the morning to see if it works without the LeanFingerTap component.

    Also I was flailing, basically trying one of everything. :)
     
  13. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Oh I see now, you're using the LeanTouch "Finger Tap / Spawn" example, which connects LeanFingerTap to LeanSpawn. These are both LeanTouch components, and the spawning here just uses Instantiate directly without any pooling.

    You can't combine LeanTouch and LeanPool like this, because LeanGameObjectPool has no such method to spawn a prefab using only a Vector3 position. LeanPool is designed to be used entirely from code, and all the spawn methods are designed to match Unity's own Instantiate ones, none of which accept just a Vector3 position.
     
  14. DYV

    DYV

    Joined:
    Aug 10, 2015
    Posts:
    58
    thank you for the answer. Could you tell me how to import it to Unity 2018.4.13f1 then.
    I imported it to Unity 2019 and don't know what to do now. I tried export the asset from U2019 and import it as custom package to 2018.4.13f1 but alas. There is error: "Assembly has reference to non-existent assembly 'Unity.InputSystem' (Assets/Lean/Common/LeanCommon.asmdef)"
     
  15. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    You can just remove that assembly reference, since the InputSystem is optional. Or you can delete the asmdefs used by LeanCommon and LeanTouch.
     
  16. hdxpmc

    hdxpmc

    Joined:
    May 1, 2016
    Posts:
    52
    Is there any example for UV transform (pan/pinch/rotate) ?
     
  17. dhaynes_unity

    dhaynes_unity

    Joined:
    Jun 10, 2019
    Posts:
    2
    Hi Darkcoder - I'm using LeanTouch+ and loving it. I've used it to make a strategy game-style camera (pinch, zoom, and orbit around 3d isometric world) and it works great.

    One question: How could I introduce rubber banding into my camera? Example: I want the camera to allow me to zoom in past the minimum limit, but then snap back when I release my fingers. Same with Constrain To Box - I'd like to be able to stretch outside that box and then have it snap back on touch release. Is this possible with LeanTouch, and if not, any suggestions on how to implement it?

    Thanks!
     
    dhaynes89 likes this.
  18. assertor

    assertor

    Joined:
    Oct 30, 2018
    Posts:
    2
    Hi Darkcoder
    I have some suggestions for the LeanLocalization plugin: is it possible to add a custom Get/Set Value feature? because I want to save the Value the way I want.The examples are as follows.

    Code (CSharp):
    1.  
    2.  
    3.         // Old...
    4.  
    5.         // [ContextMenu("Clear Save")]
    6.         // public void ClearSave() {
    7.         //     PlayerPrefs.DeleteKey("LeanLocalization.CurrentLanguage");
    8.         // }
    9.  
    10.         // private static void SaveNow() {
    11.         //     PlayerPrefs.SetString("LeanLocalization.CurrentLanguage", currentLanguage);
    12.         // }
    13.  
    14.         // private static void LoadNow() {
    15.         //     currentLanguage = PlayerPrefs.GetString("LeanLocalization.CurrentLanguage");
    16.         // }
    17.  
    18.         // New...
    19.  
    20.         public static event System.Action<string> OnDeleteKey;
    21.         public static event System.Action<string, string> OnSetString;
    22.         public static event System.Func<string, string> OnGetString;
    23.  
    24.         [ContextMenu("Clear Save")]
    25.         public void ClearSave() {
    26.             if (OnDeleteKey != null) {
    27.                 OnDeleteKey.Invoke("LeanLocalization.CurrentLanguage");
    28.                 return;
    29.             }
    30.             PlayerPrefs.DeleteKey("LeanLocalization.CurrentLanguage");
    31.         }
    32.  
    33.         private static void SaveNow() {
    34.             if (OnSetString != null) {
    35.                 OnSetString.Invoke("LeanLocalization.CurrentLanguage", currentLanguage);
    36.                 return;
    37.             }
    38.             PlayerPrefs.SetString("LeanLocalization.CurrentLanguage", currentLanguage);
    39.         }
    40.  
    41.         private static void LoadNow() {
    42.             if (OnGetString != null) {
    43.                 currentLanguage = OnGetString.Invoke("LeanLocalization.CurrentLanguage");
    44.                 return;
    45.             }
    46.             currentLanguage = PlayerPrefs.GetString("LeanLocalization.CurrentLanguage");
    47.         }
    48.  
    Thanks!
     
  19. NoPants_

    NoPants_

    Joined:
    Apr 23, 2014
    Posts:
    59
    Hello, I recently updated to the latest leanpool, but now when I try to build I get this error for all my object pools.
    Code (CSharp):
    1. InvalidOperationException: The following game object is invoking the DontDestroyOnLoad method: TowerObjectPools. Notice that DontDestroyOnLoad can only be used in play mode and, as such, cannot be part of an editor script.
    2. Lean.Pool.LeanGameObjectPool.Awake () (at Assets/Lean/Pool/Scripts/LeanGameObjectPool.cs:496)
    3.  
    Not sure if anyone else if having this problem, but I can't seem to figure out what is causing this, that line wasn't changed in the last version..
     
  20. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Assuming you're talking about material UVs, then by default in the standard pipelines these can only be adjusted for scale and offset. Even then, mapping these to match fingers would be difficult except for simple meshes like a plane/quad. Maybe a reference image of what you're trying to do would make this clearer?


    You should be able to do this with ConstrainToBox. To make it snap only when you release, you could make this component enable/disable based on if fingers are touching the screen. To make it smooth you can decouple the movement so instead of moving & snapping the camera, you do this on some kind of dummy object, and then you use LeanChase to make the camera smoothly follow it. This should be possible, let me know if you encounter any issues.


    I'm not sure how useful this would be for most users, so I don't think I'll add it. I designed the code for save/load to be very simple as you can see, so users can customize it to their exact requirements.


    Thanks, this will be fixed in the next version that I just submitted for review. For now you can ignore it as it shouldn't cause any issues.
     
    NoPants_ likes this.
  21. alterra_br

    alterra_br

    Joined:
    Mar 29, 2019
    Posts:
    5
    Hi!
    I try to make couple selectable objects.
    But object deselects only on second tap outside it, not in first.
    All works perfect in demo scene, in empty scene, but not in main scene with same settings.
    Try to disable all UI, change Select and Selectable settings. No luck.
    Is something else that i miss?
     
    Last edited: Oct 20, 2020
  22. dacoursey

    dacoursey

    Joined:
    Dec 17, 2016
    Posts:
    40
    Hi again Darkcoder, I just picked up GUI and GUI Shapes. I am using the "Lean Edge" example to make the slide out drawer but had a question. Is there a way to make it pinned through code? So I can allow the user to check a box and the drawer will stay out.

    Thanks
     
  23. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Can you make a simple scene that demonstrates this issue, and send it to me to test? It sounds like a UI issue, but if you've disabled that them I'm not sure.


    Try the attached package.

    This updates LeanConstrainAnchoredPosition to include the CachedRectTransform, HorizontalRange, and VerticalRange properties. You can snap it to the max position using something like:

    Code (csharp):
    1. lcap.CachedRectTransform.anchoredPosition = new Vector2(lcap.HorizontalRange.y, lcap.CachedRectTransform.anchoredPosition.y);
    Where the __Range property's .x value is the minimum, and .y is the maximum. Keep in mind this will have to be set every frame (e.g. LateUpdate), unless you disable LeanDrag.
     

    Attached Files:

  24. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    Hello, I have a question about LeanPool.

    I would like to know if it's possible to Spawn objects that are not activated. (gameObject.SetActive(false)).

    My use case: I spawn projectiles at various positions and I enable them after a delay.
    But because these projectiles are pooled, when I spawn then deactivate them, they are put back in the pool of course.

    How can I do that operation of spawning various pooled objects and delaying their activation?
     
  25. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    This cannot be done without modifying the code, because the pooling itself de/activates the cloned GameObjects. There are two main ways to do this:

    a) Modify the SetActive(true) calls to match the prefab.

    b) Remove the SetActive calls, and instead move the clones to a deactivated 'container' GameObject.
     
  26. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    Do you mind explaining this one some more? I don't understand what you mean.

    I tried it and it works, however I need to create a parent gameObject for every object I want to delay spawn. I would like to try something less messy.


    What do you think about the following options?
    1) Pass an argument in the spawn method that allows a delay. (Like the despawn method)
    2) Disable the auto go back to pool on a object.
     
  27. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    406
    Lean Touch+

    How do I make a multi finger trail select?

    Example I have 3 squares above each other

    With 1 finger I can select each by dragging over them, but I want to be able to also use 2 fingers and drag over the top and bottom square and have each finger select what it touches. At the moment I can only select using just 1 finger dragging over each square.

    So what I need is multi trail, multi select
     
  28. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    406
    Ok, I got no answer here and also no Email reply.

    Let’s put it into simple terms.

    Have 2 objects on the screen and 2 fingers. It does not matter which finger touches an object it gets selected.

    That’s it

    So How?
     
  29. alterra_br

    alterra_br

    Joined:
    Mar 29, 2019
    Posts:
    5
    Hi! Thanks for your reply!
    Seems it was my bad, some of my GO containing empty UI elements that blocks clicks.
    I future out how to make all work with LeanSelect settings change.
     
  30. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    406
    Anyone have an idea please. Read above for more
    lean touch+

    Have 2 objects on the screen and 2 fingers. It does not matter which finger touches an object it gets selected.
     
  31. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    406
    Ok, the dev replied to my Email and is working on a solution for multi finger selection
    So this could then be possible in a few days or so.
    Thanks Dev.
     
  32. S4UC1SS0N

    S4UC1SS0N

    Joined:
    May 29, 2014
    Posts:
    49
    Is there a way with LeanLocalization to load a CSV with multi-lines translation ?


    my_translation;"Hello,
    How are you ?
    Bye"



    When i try, it stops at the first line.
     
  33. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    I sent you a private message with a test build. This adds the Strategy setting to the LeanGameObjectPool component, which can be set to "Deactivate Via Hierarchy". Let me know if this works as you expect.


    I sent you a test build via email.

    Keep in mind this isn't a live chat room. I try to answer messages every day depending on how busy I am. I answered you via email 27 hrs after your initial forum message, which I think is pretty reasonable.



    Glad you found a solution!


    This can be done based on the "New Line" setting. By default it's "\n" to match most text parsers, so your multi line text would look like this: "Hello,\nHow are you?\nBye."

    Making it actually multi line like your example would require modification to the code, or for you to use one of the alternative new line characters alongside a different one for the actual lines, but this would be difficult to edit.
     
  34. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    Actually I realized that the bug was of my own making, it seems what I needed is supported with the default option already. Sorry for misleading you.
    I thought that when I called GameObject.SetActive(false) the object would go back to the pool.
    But I see now that's not the case.


    My use case was to delay the creation of pooled torrents:
    MKGjcCWrpw.gif

    Code (CSharp):
    1. for (int i = 0; i < 10; i++)
    2. {
    3.                    var obj = LeanPool.Spawn(_torrent, _position, _rotation, _parent);
    4.                     var baseDelay = .5f;
    5.                     var delay = i * .03f + baseDelay;
    6.                  
    7.                     obj.gameObject.SetActive(false);
    8.                     GameObjectManager.SetActive(obj.gameObject, true, delay); // The problem came from this method, I was activating a component instead of the gameobject itself.
    9. }                  
    10.  


    When looking through your scripts I noticed you had static variables.
    Unity has a way of entering playmode without recompiling the scripts, it's called Fast Enter Playmode.
    And it requires that if you have static variables they must be reset in a custom method with a RuntimeInitializeOnLoadMethod attribute.

    I think this could potentially cause bugs during editor time if you don't initialize your static variables in a method like this.

    Code (CSharp):
    1.         private static Dictionary<GameObject, LeanGameObjectPool> prefabMap;
    2.  
    3.         private static List<IPoolable> tempPoolables;
    4.  
    5.         [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
    6.         static void StaticSetup()
    7.         {
    8.             prefabMap  = new Dictionary<GameObject, LeanGameObjectPool>();
    9.             tempPoolables  = new List<IPoolable>();
    10.         }
    upload_2020-10-25_14-24-45.png
     
  35. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    406
    Thanks for the new build. It works exactly as I needed it to.
    I am going to give this asset 5 Stars
     
  36. panpapik

    panpapik

    Joined:
    Nov 3, 2020
    Posts:
    2
    Hello!

    I've recently started to use LeanTouch. It's a great package and makes things a lot easier. Thank you very much for providing such awesome asset!

    I'm using LeanPinchScale and LeanDragTranslate. The pinch scale works awesome, but translation does not work at all. So, I guess I'm missing something small.

    - I am using the latest LeanTouch asset from October 2020
    - I am using it for AR on Android
    - I have Unity 2019.4.4f1, Unity AR Foundation 2.1.10, ARCore XR Plugin 2.1.12
    - I have LeanTouch, LeanSelectable on my scene and LeanPinchScale and LeanDragTranslate scripts on my prefab
    - My prefab is an .fbx file and doesn't have any colliders.
    - I assigned AR Camera and LeanSelectable to LeanPinchScale and LeanDragTranslate scripts.

    Here's the details of my setup:

    upload_2020-11-4_1-7-51.png

    As I said, the scale works perfectly, but I cannot drag/translate the model.

    Thank you very much!
     
  37. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Aha. Indeed, deactivating an object isn't the same as despawning it, since you can always deactivate a normal object without expecting it to be destroyed.

    I'll have to experiment with this Fast Enter Playmode setting. Although LeanTouch uses statics, in theory the contents of these should correctly add/remove based on the scene components enabling/disabling, so there should be no memory leaking. Unless of course this setting completely wipes the statics to null, I'll have to see.


    Your settings look like they should work.

    Do demo scenes such as "Lean/Touch/Examples/12 Transform 3D" or "Select 3D / Transform" work? These use the same components. If so, try setting if there's some obvious difference between the scenes, or copy+paste components over until it works/breaks to see what causes it.
     
  38. panpapik

    panpapik

    Joined:
    Nov 3, 2020
    Posts:
    2
    Hello again and thank you for your quick response!

    I went through the differences, I even replaced the prefabs in the end. So, I used my own prefab in Lean/Touch/Examples/12 Transform 3D and the cubes there in my own scene.

    Everything works fine in the editor, but when I take a build for AR, even the cubes from Lean/Touch/Examples/12 Transform 3D does not drag/translate, but only scale.

    Is it possible there is a different kind of setup for AR Foundation?

    Thank you.
     
  39. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    185
    I'm considering to buy this asset (LeanTouch+). Are there any demo scenes available to work with Playmaker?

    I read here in the forum that you don't consider Playmaker actions because everything is already drag and drop without coding, but what I'm interested in is to see if a setup together with playmaker is easy to do.

    I guess that you have to call certain methods and variables from those scripts in order to really implement this into a real game scenario, right?

    Would be awesome to have sample scenes that shows this together in a playmaker setup if possible/available.
     
  40. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Sorry for the late reply, I'm not sure. I'll see if I can test with AR Foundation.


    It depends what you need to do. Indeed, most features can be set up without any code. Most other remaining features can be triggered by calling a method in one of the components, which can be done from UI buttons, and presumably some built in PlayMaker action. If you let me know what kind of interaction you're trying to implement then I can tell you what kind of i/o would be required from an external source to achieve it.
     
  41. Urjin

    Urjin

    Joined:
    Mar 16, 2020
    Posts:
    5
    Hi all. I don't know this is a bug or a feature, but LeanTouch.RaycastGui - returns not a from vector2, but only from current screen position (LastScreen position).
     
  42. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    I'm not sure I understand the issue. RaycastGui returns a List<RaycastResult>, where element 0 is the first/top element. The input 'Vector2 screenPosition' should work if you pass it pixels e.g. Input.mousePosition?
     
  43. Urjin

    Urjin

    Joined:
    Mar 16, 2020
    Posts:
    5
    As I understood this method, it would give raycast from vector I given to elements, or not?
    Why it needs argument, if it's counts only from ScreenPosition
     
  44. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    The RaycastGUI method allows you to find the GUI elements under a specific Vector2 pixel position on the screen. This is necessary because mobile devices support multiple touches/fingers, so you need to find what is under multiple different positions at the same time. It's also made public so users can find UI elements under a custom position, which can be used for anything. I just tested this and it works as expected (see attached, you can adjust the RaycastTestGUI component's Position setting and it correctly detects the UI element under the current position).
     

    Attached Files:

  45. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    145
    Hi and thanks for this great tool
    One question, can we split (predifine areas) for touches?
    For example create 3 areas for different actions?
    Something like creating buttons but invisible in a rect shape
    Thanks in advance.
     
  46. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    This can be done with LeanTouch+ using the LeanFingerDownCanvas component, and sending the finger via the provided OnFinger event to other components. This strategy works for most components, though it might depend on exactly what you want to have happen in each of these predefined areas. The Pong example shows you one use case for this.
     
    Pourya-MDP likes this.
  47. tushtush91

    tushtush91

    Joined:
    Sep 17, 2019
    Posts:
    14
    Hi Darkcoder,
    I bought the LeanTouch+ from the asset store. I was wondering how can i achieve the following style of camera (including the tapping and zoom in).
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    The Lean/Touch+/Examples/Orbit demo scenes show you how to do most of these camera controls. However, the tap to focus functionality shown in that example is quite advanced, and would require a new orbit component entirely. I'll see what I can do.
     
  49. tushtush91

    tushtush91

    Joined:
    Sep 17, 2019
    Posts:
    14
    Oh wow Thank you!!
     
  50. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    145
    One tip
    You can do such things with unitys cinemachine virtual cameras in couple of minutes.
    Search a bit for cinemachine free cams