Search Unity

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

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

  1. Develax

    Develax

    Joined:
    Nov 14, 2017
    Posts:
    67
    LeanLocalization

    Issue 1:

    I can't start typing in the first field (in my case it's English, but actually it can be any language) until I type something into the second field:

    upload_2020-3-3_18-11-14.png

    But
    Ctrl+V
    works just fine at any time.

    Issue 2:

    Can't add a new translation in Prefab.
    I've made a prefab from the
    LeanLocalization
    object. Now, whenever I try to add a new translation in prefab editor it doesn't appear in the prefab but in its instance in the scene. So, either I have to "Apply" changes to the Prefab from the scene object or delete a prefab first from the scene, then add a new translation (in this case it is added to the Prefab as expected) and then instantiate the Prefab back to the scene. Both ways are quite inconvenient.
     
    Last edited: Mar 3, 2020
  2. dehtyar

    dehtyar

    Joined:
    Mar 27, 2017
    Posts:
    1
    LeanLocalization
    Hi, you have a little mistake in script LeanLocalization.cs. Check method SetCurrentLanguage(int). Thanks for plugin.
     
  3. maevin

    maevin

    Joined:
    Dec 3, 2010
    Posts:
    33
    would you mind providing a little more detailed response to the positioning, I do apologize but as I said I have only been using Unity for a short period of time. I fixed the Child issue so that is working correctly now. But having issues with anchoring.
     
  4. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Which exact version of Unity are you using? This sounds like an issue with the new prefab stuff, which I haven't tested Lean Localization with thoroughly yet, I should do though!


    I recommend you follow a tutorial like THIS to understand how all the anchoring and positioning values work.
     
  5. Develax

    Develax

    Joined:
    Nov 14, 2017
    Posts:
    67
    Unity version 2019.3.0f5

    The 1-st issue occurs on regular game objects (not prefabs) as well.
     
  6. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    I can replicate the issue, I'll try and fix it today.
     
  7. dpizzle

    dpizzle

    Joined:
    Feb 2, 2013
    Posts:
    31
    I'm having trouble with the latest Lean Touch+ not working the same as previous versions. Can you view this video and let me know if this is a bug or maybe I'm doing something in a non recommended way that the latest version broke. http://relativedistance.com/leanbug.mp4
     
  8. Develax

    Develax

    Joined:
    Nov 14, 2017
    Posts:
    67
    LeanLocalization

    When does it get fully initialized?
    Couldn't find it in the documentation.

    I've made the LeanLocalization component to be the first in the Script Execution Order settings but it still returns null in the Start methods where I need some localized data.
     
  9. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Thanks for the video. I noticed this issue a while ago and I'm currently waiting for Unity to accept the new version with this fix. In the mean time I sent you a private message with early copy of this next version. Sorry for any issues!


    Initialization occurs in LeanLocalization.OnEnable (should be before any Start messages). Instead of relying on the execution order you can hook into the LeanLocalization.OnLocalizationChanged event, which will be invoked after this, as well as whenever you change language, add translations, etc.
     
  10. Develax

    Develax

    Joined:
    Nov 14, 2017
    Posts:
    67
    Thanks!
    Could you make it be ready after Awake as well?

    ----
    This warning always appears in the log:

     
  11. TsdTeam

    TsdTeam

    Joined:
    Nov 28, 2019
    Posts:
    4
    Hi Darkcoder,
    First of all, thanks for your cool asset (LeanPool).
    Document seem doesn't clear for me. I have read the document but do not understand it well, so I want to ask you something.
    =====
    I created a singleton called PoolManager that contain ref to LeanGameObjectPool (like picture below).
    So anywhere I want to create "missile" I will:
    Code (CSharp):
    1. var go = PoolManager.instance.missile.Spawn(Vector3.zero, quaternion.identity);
    . And Despawn like:
    Code (CSharp):
    1. PoolManager.instance.missile.Despawn(go);
    => In my case I have to create Pool manual, so this is my idea. Is there a right how to use.
    =====
    If my game have 2 type of missile or more, I have to create 2, 3,... gameobjects, add LeanGameObjectPool and drag missile prefab to each LeanGameObjectPool, right?

    Thank you!
     

    Attached Files:

    • 2.png
      2.png
      File size:
      222.5 KB
      Views:
      370
  12. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    I've added it to my to do list alongside the text field bug. I tried to fix the text field bug, but I wasn't able to find a workaround. It looks like some kind of bug with the new UI Elements, as the code looks fine and doesn't do anything crazy. When I have more free time I'll look into it again.


    Yes, each LeanGameObjectPool manages one prefab only. If you add a second missile type then you will have to create another missile pool, another PoolManager field, drag and drop, etc. For this reason I recommend you just use the static LeanPool.Spawn/Despawn methods, so it will all automatically work like magic. While doing it directly like you're doing is faster, it's only marginally faster, and you're losing a lot of development time with this. If your game needs thousands of prefabs to spawn/despawn every few seconds then this may be an optimization to consider, but judging by those prefab names I think this is unnecessary.
     
    Develax likes this.
  13. TsdTeam

    TsdTeam

    Joined:
    Nov 28, 2019
    Posts:
    4
    So I just need declare myGameobject(missile, explosion,...) somewhere, use static
    Code (CSharp):
    1. Lean.Pool.LeanPool.Spawn(ref to:myGameObject );
    2. Lean.Pool.LeanPool.Despawn( ref to:myGameObject );
    your asset will automatically classify each prefab based on their name. Awesome
    -------------
    But if we use above way, we can't setup setting for each pool. So my case still create another missile pool, another PoolManager field, drag and drop, etc.
    ------------
    Thank for your help!
     
  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You can either store a reference to your prefab somewhere and read it when spawning, or you can load it using resources. The prefab and clone GameObject reference is stored, not the name.

    You can still make custom settings for each prefab by adding the LeanGameObjectPool component somewhere in your scene, dropping the prefab in, then setting it up. LeanPool will automatically read the settings from the pool.
     
    TsdTeam likes this.
  15. Bazzajunior

    Bazzajunior

    Joined:
    May 23, 2015
    Posts:
    20
    I'm currently trying to figure out how to use Lean Touch on a vehicle control setup that I previously had working via PlayMaker - but this time around I fancied something a bit cleaner (currently I have to enable/disable parts to switch between mouse and touch input). The old system works by applying a set amount of motor torque to wheel colliders once a player applies a continuous touch/click on a screen. To steer, the player drags their finger/mouse pointer around the screen and the vehicle performs a 'lookAt' to the raycasts provided by the input.

    So far using Lean Touch, I've got the wheel colliders performing as expected; using the 'Lean Finger Down' and 'LeanFingerUp' to trigger the wheel torque, and whilst I've got a test version of 'lookAt' using an Input.GetMouseButtonDown(0), I can't figure out the best way to do the same thing using any Lean Touch option.

    e.g:

    Code (CSharp):
    1. void Update()
    2.     {
    3.         if (Input.GetMouseButtonDown(0))
    4.         {
    5.             Vector3 clickPosition = Vector3.one;
    6.  
    7.             Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    8.             RaycastHit hit;
    9.  
    10.             if (Physics.Raycast(ray, out hit, maxDistance, clickMask))
    11.             {
    12.                 clickPosition = hit.point;
    13.                 transform.LookAt(clickPosition);
    14.             }
    15.         }
    16.     }
    Would anyone be able to give me a prompt as to what is the best way to replace the Mouse Button Down for a correct Lean Touch option?

    Thanks!
     
  16. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    616
    Is there a reason for not having a "LeanLocalizedTextMeshPro" component?

    You have "LeanLocalizedTextMesh" and "LeanLocalizedTextMeshProUGUI" but no "LeanLocalizedTextMeshPro"

    I assume I can just copy and change the ...ProUGUI component to create it myself, but would be nice to have out of the box.

    -Jeff
     

    Attached Files:

  17. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You can use LeanFingerSet to detect every frame a finger touches the screen. From code you can hook into LeanTouch.OnFingerSet/Down/Up, or LeanTouch.GetFingers, and loop through them yourself and check the .Set/Down/Up values.


    This is an oversight, I didn't realize there was a TextMeshPro component. I'll fix this in the next version!
     
    jeffweber likes this.
  18. Bazzajunior

    Bazzajunior

    Joined:
    May 23, 2015
    Posts:
    20
    Thanks @Darkcoder for getting back to me on this one. I've put something in place which is working. The vehicle snaps to face the new position each time the screen is clicked and it's a look and forget (i.e. the vehicle turns to face the clicked & held / touch & held position but doesn't it doesn't adjust if the mouse or finger is dragged on the screen). Is there a way to make this smoother or actually follow the finger/mouse position on the screen? I've tried placing the code into void Update(), but that's made no difference:

    Code (CSharp):
    1. // Update is called once per frame
    2.     public void FingerDownRaycast()
    3.     {
    4.         LeanTouch.OnFingerDown += CheckForRaycast;
    5.     }
    6.  
    7.     void CheckForRaycast(LeanFinger finger)
    8.     {
    9.         Vector3 clickPosition = Vector3.one;
    10.  
    11.         Ray ray = Camera.main.ScreenPointToRay(finger.ScreenPosition);
    12.         RaycastHit hit;
    13.  
    14.         if (Physics.Raycast(ray, out hit))
    15.         {
    16.             clickPosition = hit.point;
    17.             transform.LookAt(clickPosition);
    18.             Debug.Log(clickPosition);
    19.         }
    20.     }


    Cheers,


    Barry
     
    Last edited: Mar 15, 2020
  19. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    291
    Getting this error in the Editor, while out of play mode:

    Code (CSharp):
    1. Failed to RaycastGui because your scene doesn't have an event system! To add one, go to: GameObject/UI/EventSystem
    2. UnityEngine.Debug:LogError(Object)
    3. Lean.Touch.LeanTouch:RaycastGui(Vector2, LayerMask) (at Assets/3rd Party/Lean/Touch/Scripts/LeanTouch.cs:347)
    4. Lean.Touch.LeanTouch:RaycastGui(Vector2) (at Assets/3rd Party/Lean/Touch/Scripts/LeanTouch.cs:297)
    5. Lean.Touch.LeanTouch:PointOverGui(Vector2) (at Assets/3rd Party/Lean/Touch/Scripts/LeanTouch.cs:290)
    6. Lean.Touch.LeanTouch:AddFinger(Int32, Vector2, Single, Boolean) (at Assets/3rd Party/Lean/Touch/Scripts/LeanTouch.cs:706)
    7. Lean.Touch.LeanTouch:PollFingers() (at Assets/3rd Party/Lean/Touch/Scripts/LeanTouch.cs:594)
    8. Lean.Touch.LeanTouch:Update() (at Assets/3rd Party/Lean/Touch/Scripts/LeanTouch.cs:430)
    9.  
    Using current LeanTouch/+ from Asset store, Unity 2019.3.4f1, OSX Catalina

    The scene does have an Event System, LeanTouch works as expected when playing the scene.
     
    StefanoCecere likes this.
  20. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Your FingerDownRaycast method merely registers the CheckForRaycast method to the OnFingerDown event. If you call this from OnWorldFrom then nothing will happen except more registrations.

    Instead, you should hook the OnFinger event to the CheckForRaycast method.



    If it really exists then this is a bug with EventSystem.current, perhaps some order of operations issue. Does the attached LeanTouch.cs fix this? You can paste it into the Lean/Touch/Scripts folder.
     

    Attached Files:

  21. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    291
    Yes that fixes it ... not 100% sure how to reproduce this ... think it might be something like
    EventSystem.current goes to 'sleep' after x minutes of being tabbed out of the editor.
     
    Darkcoder likes this.
  22. Bazzajunior

    Bazzajunior

    Joined:
    May 23, 2015
    Posts:
    20
    Thanks @Darkcoder for your help on that. It's working just as I'd hoped now - you're a superstar :D
     
    Darkcoder likes this.
  23. agittrim

    agittrim

    Joined:
    Jan 29, 2018
    Posts:
    3
    LeanTransition

    Hi Darkcoder, is it possible to get a callback when all transitions finished?
    Also, can we play a transition automatically when the object become active or on Start() event?
     
    Last edited: Mar 18, 2020
  24. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412

    You can add the Event Transition (LeanEvent), but you must join it and/or correctly set the Duration so it executes when the others finish. There's no way to automatically detect when all transitions end. It's possible to detect this, but it's much more efficient to rely on the timing and execution order.

    The attached component will automatically play the specified animation from Start.
     

    Attached Files:

  25. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    Hi,

    Is it possible touch swipe into object specific are?

    using sprite or ui
     
  26. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    I'm not sure I understand. You can detect a swipe in a specific area of the screen using LeanGUI's LeanSwipe component. This can be attached to a UI element (e.g. Image), that you can place anywhere.

    This can be done with LeanTouch+ using the LeanFingerDownCanvas component, and sending the OnFinger event to the LeanManualSwipe component's AddFinger function.
     
  27. agittrim

    agittrim

    Joined:
    Jan 29, 2018
    Posts:
    3
    Ah I see, so I already on the right path. Btw can we get total duration of the transition? So i can set the LeanEvent's duration dynamically?

    Thanks, just what I needed, but the code is only works if I added LeanTransition to the scene, is it normal or am I missing something?
     
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    There's currently no way to calculate this. Why can't you just join it to the last/longest transition?

    That component should automatically add LeanTransition to your scene. I'll test it on Monday when I get back.
     
  29. mrsimmo

    mrsimmo

    Joined:
    May 4, 2013
    Posts:
    12
    Hi there! Amazing asset - a couple of (probably very newbie!) questions!

    1. In order to just detect swipes on a certain area of the screen, am I right in thinking I need to use a LeanGUI swipe component to do that?

    2. I want to trigger an event on a swipe up, but I want the user to be able to interact with a scrollrect (with text in it) as they do so. So the effect is like they are swiping the text up and off the screen, which is then replaced by the event. I can't work out how to allow the touch to interact with the scroll rect, but also register the swipe event....

    Any help greatly appreciated!
    Thanks :)
     
  30. g-augview

    g-augview

    Joined:
    Mar 28, 2017
    Posts:
    13
    Yes it does. Does the hierarchy matter, where the leantouch component is relative to those world UI elements?
     
  31. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Answered you via email :)


    Nope, as long as it's enabled and on an active GameObject it should work fine.
     
  32. TsdTeam

    TsdTeam

    Joined:
    Nov 28, 2019
    Posts:
    4
    Hi Darkcoder.
    How can I make Pool DontDestroyOnload.
    My game work with 2 scene. Loader as start scene and Gamescene as main scene. When I play game and used LeanPool (static), it works very well, but Pool will Instantiate in Gamescene.
    Therefore when I switch to home start scene, Pool will destroy, and when I go to new level, I will init Pool again.
    All I want is Pool will Instantiate as DontDestroyOnload, so at level 2 I can use missile, explosion at level 1 that I have initialized before. Althougt I swich between 2 or 3 scene, Pool just Instantiate once for each prefab reference.
    ---------------
    I tried one way it is add DontDestroyOnload in LeanGameObjectPool, but it wrongs because it creates 2 or more Gameobject LeanGameObjectPool of 1 reference prefab for each level reset. So sad.
    ----------------
    Thanks for your help!
     
    Last edited: Mar 27, 2020
  33. Bentoon

    Bentoon

    Joined:
    Apr 26, 2013
    Posts:
    98
    Hello Carlos,
    First, Thank you so much for Lean Touch+ !
    (I am having an interesting issue with the shaders where they Glitch in editor a lot -
    But doesn't seem to affect play mode)

    My real shader question has to do with your Lean> Common> Object shader I'm trying to enable transparency (for a .png) and cant quite figure the shader code. Is it possible?

    Code (CSharp):
    1. Shader "Lean/Common/ObjectTrans"
    2. {
    3.     Properties
    4.     {
    5.         _MainTex("Main Tex", 2D) = "transparent" {}
    6.         _Color("Color", Color) = (1.0, 1.0, 1.0, .0)
    7.         _Color1("Color 1", Color) = (1.0, 0.5, 0.5, .0)
    8.         _Color2("Color 2", Color) = (0.5, 0.5, 1.0, .0)
    9.         _Rim("Rim", Float) = 1.0
    10.         _Shift("Shift", Float) = 1.0
    11.     }
    12.  
    13.     SubShader
    14.     {
    15.         Tags
    16.         {
    17.             "Queue" = "Geometry"
    18.             "PreviewType" = "Sphere"
    19.             "DisableBatching" = "True"
    20.         }
    21.  
    22.         Pass
    23.         {
    24.             CGPROGRAM
    25.             #pragma vertex Vert
    26.             #pragma fragment Frag
    27.  
    28.             sampler2D _MainTex;
    29.             float4    _Color;
    30.             float4    _Color1;
    31.             float4    _Color2;
    32.             float     _Rim;
    33.             float     _Shift;
    34.  
    35.             struct a2v
    36.             {
    37.                 float4 vertex    : POSITION;
    38.                 float2 texcoord0 : TEXCOORD0;
    39.                 float3 normal    : NORMAL;
    40.                 float4 color     : COLOR;
    41.                
    42.             };
    43.  
    44.             struct v2f
    45.             {
    46.                 float4 vertex : SV_POSITION;
    47.                 float2 uv     : TEXCOORD0;
    48.                 float3 normal : TEXCOORD1;
    49.                 float4 color  : COLOR;
    50.             };
    51.  
    52.             struct f2g
    53.             {
    54.                 float4 color : SV_TARGET;
    55.             };
    56.  
    57.             void Vert(a2v i, out v2f o)
    58.             {
    59.                 o.vertex = UnityObjectToClipPos(i.vertex);
    60.                 o.uv     = i.texcoord0;
    61.                 o.normal = mul((float3x3)UNITY_MATRIX_IT_MV, i.normal);
    62.                 o.color  = i.color * _Color;
    63.                
    64.             }
    65.  
    66.             void Frag(v2f i, out f2g o)
    67.             {
    68.                 float rim = _Shift - pow(saturate(1.0f - normalize(i.normal).z), _Rim);
    69.  
    70.                 o.color = tex2D(_MainTex, i.uv) * lerp(_Color1, _Color2, rim) * i.color;
    71.             }
    72.             ENDCG
    73.         } // Pass
    74.     } // SubShader
    75. } // Shader
     
  34. Bentoon

    Bentoon

    Joined:
    Apr 26, 2013
    Posts:
    98
    Hello Carlos,

    Let me be clear I know that there is the Lean >Common> Alpha but its Unlit and I really like the gradient effect in the Object Shader and wondering if it's and easy fix?

    Thanks!
    ~be



     
  35. Deleted User

    Deleted User

    Guest

    Hi Darkcoder. Thank for great asset.
    In my case:
    I declare a Transform variables:
    Code (CSharp):
    1. Transform car = null;
    When I want to init it, I use:
    Code (CSharp):
    1.  car = Lean.Pool.LeanPool.Spawn(GameManager.instance.car, transform);
    GameManager.instance.car is prefab transform from GameManager (singleton).
    And at the line I want to despawn:
    Code (CSharp):
    1.  
    2.         if (car != null)
    3.         {
    4.             Lean.Pool.LeanPool.Despawn(car);
    5.             car = null;
    6.         }
    But I don't understand why many warning appears.
    You're attempting to despawn a gameObject that wasn't spawned from this pool or This pool contained a null despawned clone, did you accidentally destroy it?

    And this make my project errors, please help me.
     
    Last edited by a moderator: Mar 30, 2020
  36. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    Hi Carlos,

    I use Lean Touch ++, and using following code to move a recttransform in screen overlay canvas which is working fine

    Code (CSharp):
    1. Vector2 screenDelta = finger.ScreenDelta;
    2. if (screenDelta != Vector2.zero)
    3. {
    4.  
    5.                  Vector3 newPos = new Vector3(screenDelta.x, screenDelta.y);
    6.                        
    7.                 ItemToDrag.position += newPos;
    8.  
    9. }

    Now problem is, i changed the canvas to "Screen Space - Camera" for an orhographic camera and now same code doesnt work as expected as ItemToDrag moves instantly.

    Please advise
     
  37. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Try the attached package. If you spawn an object with a null parent then it will now spawn it in the active scene.

    Also, LeanGameObjectPool has the Persist setting, which will make it DontDestroyOnLoad. This is called in Awake though, so it would only work if your pool is manually created (e.g. in your Loader scene).


    If you want the same transparency as the Alpha shader then you must copy over these bits:

    Code (CSharp):
    1. "Queue" = "Transparent"
    and

    Code (CSharp):
    1. Blend SrcAlpha OneMinusSrcAlpha
    2. ZWrite Off
    The final shader should look like this (untested):

    Code (CSharp):
    1. Shader "Lean/Common/Object"
    2. {
    3.     Properties
    4.     {
    5.         _MainTex("Main Tex", 2D) = "white" {}
    6.         _Color("Color", Color) = (1.0, 1.0, 1.0, 1.0)
    7.         _Color1("Color 1", Color) = (1.0, 0.5, 0.5, 1.0)
    8.         _Color2("Color 2", Color) = (0.5, 0.5, 1.0, 1.0)
    9.         _Rim("Rim", Float) = 1.0
    10.         _Shift("Shift", Float) = 1.0
    11.     }
    12.  
    13.     SubShader
    14.     {
    15.         Tags
    16.         {
    17.             "Queue" = "Transparent"
    18.             "PreviewType" = "Sphere"
    19.             "DisableBatching" = "True"
    20.         }
    21.  
    22.         Blend SrcAlpha OneMinusSrcAlpha
    23.         ZWrite Off
    24.  
    25.         Pass
    26.         {
    27.             CGPROGRAM
    28.             #pragma vertex Vert
    29.             #pragma fragment Frag
    30.  
    31.             sampler2D _MainTex;
    32.             float4    _Color;
    33.             float4    _Color1;
    34.             float4    _Color2;
    35.             float     _Rim;
    36.             float     _Shift;
    37.  
    38.             struct a2v
    39.             {
    40.                 float4 vertex    : POSITION;
    41.                 float2 texcoord0 : TEXCOORD0;
    42.                 float3 normal    : NORMAL;
    43.                 float4 color     : COLOR;
    44.             };
    45.  
    46.             struct v2f
    47.             {
    48.                 float4 vertex : SV_POSITION;
    49.                 float2 uv     : TEXCOORD0;
    50.                 float3 normal : TEXCOORD1;
    51.                 float4 color  : COLOR;
    52.             };
    53.  
    54.             struct f2g
    55.             {
    56.                 float4 color : SV_TARGET;
    57.             };
    58.  
    59.             void Vert(a2v i, out v2f o)
    60.             {
    61.                 o.vertex = UnityObjectToClipPos(i.vertex);
    62.                 o.uv     = i.texcoord0;
    63.                 o.normal = mul((float3x3)UNITY_MATRIX_IT_MV, i.normal);
    64.                 o.color  = i.color * _Color;
    65.             }
    66.  
    67.             void Frag(v2f i, out f2g o)
    68.             {
    69.                 float rim = _Shift - pow(saturate(1.0f - normalize(i.normal).z), _Rim);
    70.  
    71.                 o.color = tex2D(_MainTex, i.uv) * lerp(_Color1, _Color2, rim) * i.color;
    72.             }
    73.             ENDCG
    74.         } // Pass
    75.     } // SubShader
    76. } // Shader
    It's hard to say. Those lines of code you posted are fine, but the problem probably lies in the rest of your code, and it's probably hard to see where the issue is.

    You can try adding the LeanPoolDebugger component to your prefab, and this may give you more info.


    This is because in Overlay the x/y positions directly correlate to the screen x/y. Whereas in Camera they're relative to the camera orientation. To fix this you can just modify the .localPosition values instead. If you have some kind of scaling that makes this impossible, then you must rotate your movement values with the camera rotation, like: += yourCamera.transform.rotation * newPos;
     

    Attached Files:

  38. mrsimmo

    mrsimmo

    Joined:
    May 4, 2013
    Posts:
    12
    Hi there - Lean Gui Shapes question!
    I'm trying to work out how to access and change the colour of a LeanCircle component, but am struggling to work out how to access it on the object once I've found it...

    Could you give me a pointer?

    Thanks so much!
     
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    From C# you just read/write the .color property, since it's a property you can't do .color.r = 0.5f; or similar, you must copy the color out first, etc. This property is inherited from MaskableGraphic -> Graphic.
     
  40. Deleted User

    Deleted User

    Guest

    Thank for your reply.
    With another case like this, is it right or wrong?

    Code (CSharp):
    1. private List<Transfrom> lsCar = new List<Transform>();
    2.  
    3. public void InitCar()
    4. {
    5. var  car = Lean.Pool.LeanPool.Spawn(GameManager.instance.car, transform);
    6. lsCar.Add(car);
    7. }
    8.  
    9. void DespawnCar()
    10. {
    11. foreach(var e  in lsCar)
    12. {
    13.     if (e!= null)
    14.         {
    15.             Lean.Pool.LeanPool.Despawn(e);
    16.         }
    17. }
    18. }
    I still got warnings
    You're attempting to despawn a gameObject that wasn't spawned from this pool or This pool contained a null despawned clone, did you accidentally destroy it?


    Am I wrong, thank you!
     
  41. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    It's still hard to say, do you clear lsCar after you despawn everything? If not, you may be calling DespawnCar multiple times, which might trigger this warning.
     
  42. NFMynster

    NFMynster

    Joined:
    Jul 1, 2013
    Posts:
    71
    Hello @Darkcoder
    I've been using your Lean assets forever, am loving them!

    Only recently I started using LeanTouch, and it seems like the LeanTouch.GuiLayers is ignored somehow.

    Am I wrong expecting that if I choose a specific layer, it should only register touches on that particular layer?
     
  43. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    The GuiLayers allow you to specify the layers that are used for the IgnoreStartedOverGui/IgnoreOverGui checks that most Lean components perform, as well as the default layers for the LeanGui.RaycastGui method.
     
  44. g-augview

    g-augview

    Joined:
    Mar 28, 2017
    Posts:
    13
    I fixed it, it was a mix of layer mask and reading LeanFinger.startedOverGui rather than only LeanFinger.isOverGui.
    thanks for fast support
     
    Darkcoder likes this.
  45. antigendf

    antigendf

    Joined:
    Aug 27, 2018
    Posts:
    1
    Hi Carlos, many thanks for your assets.

    I have problems with LeanLocalizedAudioSource. I added the translation, then the audio clip in phrases (Object) and finally the component to the game object with audio source. In the editor window seems to work when i change the language because i see the clip name changes in the inspector, but no sound at all is playing in the scene =(, is there any step am i forgetting?

    Greetings from Mexico.
     
  46. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Did you play your sound after changing the clip? If your sound was already playing when changing the clip then I imagine it will stop playing (haven't tested it), so you must then play it again.
     
  47. BEST-Thanawat

    BEST-Thanawat

    Joined:
    Apr 14, 2020
    Posts:
    7
    Hi Carlos,

    I have a question about how to set up LeanTouch+ like a RTS Camera?
    I want it to look like


    Currently, I used FirstPersonLookMove and configure it in a different way but the result is still not quite good. Could you please suggest me.

    Thank You
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    The OrbitMoveTopDown demo scene works like this. To get zoom you can copy+paste MainCamera from the OrbitZoom or OrbitDolly demo scene, depending on what you prefer.
     
  49. BEST-Thanawat

    BEST-Thanawat

    Joined:
    Apr 14, 2020
    Posts:
    7
    Thank so much :)
     
    Darkcoder likes this.
  50. BEST-Thanawat

    BEST-Thanawat

    Joined:
    Apr 14, 2020
    Posts:
    7
    Hi Carlos,
    After using OrbitMoveTopDown it looks good but the next problem is how to limit the camera movement not to move over the scene?
     
    Last edited: Apr 20, 2020