Search Unity

Runtime Level Design

Discussion in 'Assets and Asset Store' started by XGT08, Jan 17, 2016.

  1. jh092

    jh092

    Joined:
    Sep 2, 2018
    Posts:
    55
    Hi Andrew,

    I'm wondering if it's possible to click and drag an object in one action. To explain:

    Current steps with nothing selected, I have to click on an object (so it becomes selected) and then click and hold on the relevant part of the gizmo to move the object around.

    Desired steps with nothing selected, mouse down on an object and start moving it immediately (lets say on the x/z axis).

    Is there some way I can make this happen?

    Many thanks and best wishes

    John
     
  2. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hi there John,

    At the moment this is not possible. In order to do any kind of manipulation, you need to have at least one object selected. After that, there are different ways to manipulate the objects, such as gizmos, surface snap, grid snap.

    I guess you could add this sort of functionality by implementing a new mode for the tool.
    I would probably activate this when holding down the SHIFT key or something like this. When that happens, you could call ObjectSelection.Get.SetEnabled(false) in order to avoid selecting new objects. Then, when the left mouse button is pressed, simply do a raycast and check if an object has been hit. If so, then you may proceeed with the behabiour you desire.

    Andrew
     
  3. jh092

    jh092

    Joined:
    Sep 2, 2018
    Posts:
    55
    Understood, thanks very much Andrew.

    John
     
  4. AlexisTix

    AlexisTix

    Joined:
    Apr 21, 2020
    Posts:
    2
    Hi
    There is one feature I really miss in this asset
    When you click to spawn a object, would it be possible to have a setting to auto select that object and go into "s" mode so you can freely move the object the moment you spawn it?
    I'm really trying to change my workflow to not need this, but it's slowing me down

    edit:
    Just saw your runtime spawner asset. Not sure how it works with Runtime Level Designer? Do you just click the object in the prefab list and then instead of spawning the item where you are looking the runtime spawner takes over and allow you to place the object?
     
    Last edited: Aug 1, 2022
  5. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hi there,

    Sorry for the late reply.

    Yes, the Runtime Spawner takes control of the prefab. I will have to take a look at it again to remember the API for doing this and I will get back to you.

    Cheers,
    Andrew
     
  6. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    @AlexisTix

    So, in your case, you would have to do something like this:

    Code (CSharp):
    1. private void OnPrefabSpawned(RTPrefab prefab, GameObject spawnedObject)
    2. {
    3.     // Select the object that was spawned when clicking on the prefab preview
    4.     RTObjectSelection.Get.SetSelectedObjects(new List<GameObject>{ spawnedObject }, false);
    5.  
    6.     // Start snapping
    7.     RTObjectSelection.Get.BeginObjectToObjectSnapSession();
    8. }
    This function is a handler that you must register somewhere in your initialization code at app startup:
    Code (CSharp):
    1. RTPrefabLibDb.Get.PrefabSpawned += OnPrefabSpawned;
    Please send me an e-mail at octamodius@yahoo.com so that I can send you the updated package. I had to add the BeginObjectToObjectSnapSession function so you don't have it in the current pack you are using.

    Cheers,
    Andrew
     
  7. dmenefee

    dmenefee

    Joined:
    Oct 14, 2019
    Posts:
    142
    Hi Andrew. I'm seeing unexpected behavior in my editor when I have objects with LODs. When I try to select other objects, the LOD objects are instead selected, no matter where they are. They are all selected, one by one, as I click on the unrelated object, until finally the one I clicked on is selected. If I disable the LOD objects, selection works normally. The objects with LODs do not have a mesh filter in the root g.o.; all meshes are child objects, as is usual for LOD g.o.'s. Is there something I can do to make sure this works?

    Note: I have designated a 'grabbable' layer for all objects which can be selected. Only the root g.o. in an LOD is marked as grabbable; if I mark the LODs, nothing changes. All other objects' root g.o. is grabbable, including the ones which only have colliders for their root g.o.
    thanks for any help!

    Edit: One clue is that the LOD objects are set to a scale of 100 (they are too small to use otherwise). Perhaps the calculation used to determine the size of their sphere in the scene node tree is not working right. When I step through the selection code, the apparent radius of the objects is over 50,000 meters, which is clearly incorrect. All the LOD objects with the huge scale are included in every raycast, requiring the click-through to cycle through them.

    Edit 2: It appears that the problem lay in the organization of the LOD objects and a weird interaction with a mesh collider that used a custom mesh. Rather than trying to figure it out, I just replaced those with single meshes and a progressive runtime mesh optimizer. Now selection works just fine.
     
    Last edited: Oct 2, 2022
    XGT08 likes this.
  8. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hi there,

    Sorry for the late reply.

    Glad to hear it was sorted out. It is possible that the custom mesh attached to the mesh collider was causing issues. However, I can't know for sure without actually looking at it closely. Let me know if you encounter any further issues.

    Cheers,
    Andrew
     
    dmenefee likes this.
  9. Pingquin

    Pingquin

    Joined:
    Oct 2, 2013
    Posts:
    12
    Will the updated version be released soon? Because I also need that BeginObjectToObjectSnapSession.
     
  10. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hi there,

    The update is now available on the asset store.
     
    Pingquin and dmenefee like this.
  11. Pingquin

    Pingquin

    Joined:
    Oct 2, 2013
    Posts:
    12
    I am currently working on something like The Sims which I need to place GameObject on specific part of game world. For that, I need to know what GameObject's surface I'm holding over(gameobject I'm snapping to) so that I can do some logic before placing the GameObject. For example, auto-rotate before placing or some object should not be placed on the floor/ignore floor completely and only snap to the wall(like windows).
    Do you have a solution for that?

    Maybe some event handler like:

    Code (CSharp):
    1. public delegate void HoldOver(GameObject gameObjectToSnapTo);
    Code (CSharp):
    1. RTObjectSelection.Get.HoldOver += OnHoldOver;
    Code (CSharp):
    1. void OnHoldOver(GameObject gameObjectToSnapTo)
    2. {
    3.     //gameObjectToSnapTo.GetComponent<SomeCustomScript>();
    4.     //do some logic
    5. }
     

    Attached Files:

    • rld.png
      rld.png
      File size:
      156.3 KB
      Views:
      106
    Last edited: Oct 15, 2022
  12. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hi there,

    I made some changes to the code to allow for this, so please send me an e-mail at octamodius@yahoo.com so that I can send you the updated pack.

    The way it is done doesn't involve a handler. You will have to use a polling technique somewhere inside an update function.

    For example:
    Code (CSharp):
    1. // Check if object-2-object snapping is enabled
    2. if (RTObjectSelection.Get.IsObject2ObjectSnapSessionActive)
    3. {
    4.       // Get the surface object and do something with it.
    5.       // Note: The object can be null (e.g. the surface is the scene grid)
    6.       if (RTObjectSelection.Get.Object2ObjectSnapSessionSurfaceObject != null)
    7.       {
    8.             // Do something with the object
    9.       }
    10. }
     
    Pingquin likes this.
  13. Pingquin

    Pingquin

    Joined:
    Oct 2, 2013
    Posts:
    12
    Hello, I try using Snap destination Layers in Object2Object snap and it seem like every layer is getting ignored and it only snap only when Can climb objects is set to "True"(even when all layer is unchecked). Is this a bug?

    What I want to do is to have the barrel snapping to only the floor layer.
    PS. In the clip, green wall is set to Wall layer and yellow floor is set to Floor layer
     
  14. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hello,

    Make sure the read-write enabled flag is set for the mesh assets that you are using in your project. This is necessary because object-2-object snapping needs mesh vertex data.

    If you want to snap only to the floor layer, you need to set the destination layers to Floor and not Wall.
     
  15. xzavier2142

    xzavier2142

    Joined:
    Jul 15, 2019
    Posts:
    16
    Having an issue where Can't get the RTPrefabLibDbUI to load anything, It just Null Exception Errors on a standalone build

    Steps to reproduce:
    Create new URP project in unity 2021.3.2f1
    Import RTD
    Add RTD to Scene
    Add UI Lib Prefab via the Create RT UI button
    Add a Simple Cube Prefab and a Test Library

    Save and Build
    Open Run Standalone

    upload_2022-11-27_22-10-57.png


    Empty Prefab

    Error is

    "/Assets/Runtime Level Design/Scripts/Runtime Package Common/Prefab Management/RTPrefabLibDbUI.cs Line: 27)"

    NullReferenceException: Object reference not set to an instance of an object
    at RLD.RTPrefabLibDbUI.Awake () [0x00075] in H:\RTDTest\Assets\Runtime Level Design\Scripts\Runtime Package Common\Prefab Management\RTPrefabLibDbUI.cs:27

    Can anyone reproduce?
     
  16. xzavier2142

    xzavier2142

    Joined:
    Jul 15, 2019
    Posts:
    16
    I've ran more Tests, I can confirm that Unity Version 2021.3.2f1 Does not like this version of RLD but 2021.3.14f1 works just fine.
     
  17. xkinginthecastlecastlex

    xkinginthecastlecastlex

    Joined:
    Nov 7, 2018
    Posts:
    93
    @XGT08 Hi,
    I have a weird bug in my project. I hope you can help.
    How can I deactive a Particle System Icon for all objects that are on a specific Layer?
    I went to RTObjectSelection and deactivated the Layer in "selectable layers" but the icons do still appear in my scene for the object with this layer..

    any idea how to solve that?
     
  18. mentalgear

    mentalgear

    Joined:
    Jul 19, 2019
    Posts:
    23
    Hi, now that it finally works with URP I'm looking into purchasing this for our project.

    Can anyone give an assessment on how performance scales with content/items per level? Does the amount of available building items (prefabs) have an impact on performance?

    We are looking to use this with 1000s of prefabs, with a level also needing to hold up to 10.000s items.

    I think many would also appreciate a WebGL demo to get a true felling before purchasing this asset, which also reduces returns for you.
     
    Last edited: May 2, 2023
  19. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hello,

    This is not currently possible. I will look into it to see if I can make it work.
     
  20. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hello,

    There are 3 desktop demos you can find in the package description under the section Try the Demos.

    Regarding performance, I expect there to be a performance hit when using a large number of objects because the plugin has to loop through all objects in the scene every update and detect any changes such as:
    1. new objects that have been added;
    2. the type of objects that have been added (camera, light etc);
    3. transforms that have changed etc;
    How big the performance hit will of course depend on the machine the app is running on. I have a pretty fast system so in my case I would probably not notice a big hit. But I can not guarantee that it will run smooth on slower systems.
     
  21. xzavier2142

    xzavier2142

    Joined:
    Jul 15, 2019
    Posts:
    16
    Back on this again.

    Setup a Brand new install on a another PC, Installed Unity Version 2021.3.24f1 installed only RLD and added a LibraryUI object added one prefab to a new Library and built standalone, I get
    NullReferenceException: Object reference not set to an instance of an object and the Library is blank.

    Is it possible that RLD only works with specific versions of unity?
     
  22. xzavier2142

    xzavier2142

    Joined:
    Jul 15, 2019
    Posts:
    16

    After Spending a few hours with your code I found in some instances the methods would be incorrectly executed out of order

    So for the RTPrefabLibDbUI.cs

    I changed the Awake Method to:


    private void Awake()
    {
    _activeLibDropDown = gameObject.GetComponentInChildren<RTActiveLibDropDown>();
    _prefabScrollView = gameObject.GetComponentInChildren<RTPrefabScrollView>();
    _hoveredPrefabNameLabel = gameObject.GetComponentInChildren<RTHoveredPrefabNameLabel>();
    _prefabSearch = gameObject.GetComponentInChildren<RTPrefabSearch>();
    if(_prefabSearch != null)
    _prefabSearch.Awake();

    _prefabScrollView.PrefabPreviewHoverEnter += OnPrefabPreviewHoverEnter;
    _prefabScrollView.PrefabPreviewHoverExit += OnPrefabPreviewHoverExit;
    PrefabSearch.SearchField.onValueChanged.AddListener(OnPrefabSearchFieldValueChanged);
    }


    Where the search would wait for the searches awake method to execute before the UI's Awake method. as if you let it execute out of order the Prefab viewer will not work

    for the RTPrefabSearch.cs I changed the awake method to:


    public void Awake()
    {
    _searchField ??= GetComponentInChildren<InputField>();
    }


    These 2 small changes will mean that RTPrefabSearch executes first then RTPrefabLibDbUI.

    If anyone else comes across this glitch this is the fix.
     
  23. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hi there,

    Sorry for the late reply. Currently a bit busy and I can't look into this right now. But it's great to hear you found a solution for this :) I will update the code as soon as possible.

    Cheers,
    Andrew
     
  24. OwlbearInteractive

    OwlbearInteractive

    Joined:
    Jun 7, 2023
    Posts:
    1
    Hi Andrew, I'm having an issue where when I extrude a prefab with LOD meshes, it seems to want to just extrude out copies of the LODs instead of the base gameobject, and child them to the originally spawned prefab. This is obviously a problem, as it locks them together and then as soon as any rotations are done, everything goes mad. The base gameobject has an LOD group and a mesh collider, and the child gameobjects just have mesh filters and mesh renderers. Is there something I need to change to make it behave as one might expect?
     
  25. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hi there,

    I think in this case, you could try to 2 things.

    The simplest solution should be to call ObjectSelectEntireHierarchy.Get.SetActive(true). This will make sure that when you click on a game object the entire hierarchy will be selected. The extrude gizmo will only spawn the top most parent(s) in the selection so this should fix the issue you mentioned.

    The solution above, should work, but in case it doesn't you can try using the pre select customize event. Please see the doc for more details. This allows you to customize which objects get selected. So for example, if you click on a child of the LOD hierarchy, you could detect that and select the parent (base) object instead.

    Hope this helps,
    Andrew
     
  26. KrisGungrounds

    KrisGungrounds

    Joined:
    Aug 20, 2019
    Posts:
    14
    Great asset! Wondering does it also works for 2D games and painting with 2D sprites/tiles? Is it possible to freeze the view?
     
  27. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hi there,

    Thanks! You can select sprite and manipulate them with the gizmos, but painting tiles is not supported.

    About freezing the view, I'm not sure what that means :)
     
  28. xzavier2142

    xzavier2142

    Joined:
    Jul 15, 2019
    Posts:
    16
    Hi Andrew,

    I've noticed alot of spelling mistakes within the Docs, do you mind if I provide you selections and area's where the mistakes are so you can correct them, I can create a Google Doc.

    Jack
     
    XGT08 likes this.
  29. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hi there,

    Sure, if it's something you would like to do, it is welcome :)

    Thank you,
    Andrew
     
  30. xzavier2142

    xzavier2142

    Joined:
    Jul 15, 2019
    Posts:
    16
    Hey Andrew,

    I've been testing the solution provided above about using ObjectSelectEntireHierarchy.Get.SetActive(true); to make sure that it doesn't duplicate objects with LOD's their LOD This works as it extrudes the parent as intended, but I've found that this does not apply to Scaling, Moving or Rotating, Any other Gizmo it moves the LOD0 which messes up the LOD system as if it moves the LOD0 and not the parent,

    when I move away LOD1 now shows the object in it's original position and rotation, is there something I can do to make sure all other Gizmo's affect the parent and not any of the children?

    Cheers
    Jack
     
  31. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hi Jack,

    All gizmos use the same approach so there must be something that's missing here. Maybe you selected all LOD's but didn't include their parent. The parent has to be selected. Just tested this out with a simple cube hierarchy (no LOD) but the principle is the same. Before transforming the objects, the parents are extracted from the selected objects and the children are ignored.

    Can you please make sure that you indeed have the entire LOD hierarchy selected?
     
  32. ignarmezh

    ignarmezh

    Joined:
    Mar 23, 2017
    Posts:
    56
    Hi, @XGT08 !
    Do we have a new method when we can block the whole Input RDL system?
     
  33. xzavier2142

    xzavier2142

    Joined:
    Jul 15, 2019
    Posts:
    16
    Thanks for getting back in touch

    I've made a short 1 minute video of the issue I'll also highlight what I'm doing in code maybe I've misunderstood



    This is what I'm doing in the hopes it's selecting the entire hierarchy. The Object is setup Parent > LOD0, 1, 2,

    The video demonstrates that even after firing off ObjectSelectEntireHierachy when I move the prefab only the LOD moves the parent does not.

    Code (CSharp):
    1. private void OnPreDeselectCustomize(ObjectPreDeselectCustomizeInfo customizeinfo,
    2.             List<GameObject> tobedeselected)
    3.         {
    4.  
    5.             ObjectSelectEntireHierarchy.Get.SetActive(true);
    6.            
    7.         }
    8.  
    9.  
    10.         private void OnPreSelectCustomize(ObjectPreSelectCustomizeInfo customizeinfo, List<GameObject> tobeselected)
    11.         {
    12.             ObjectSelectEntireHierarchy.Get.SetActive(true);
    13.         }
    - Jack
     
  34. xzavier2142

    xzavier2142

    Joined:
    Jul 15, 2019
    Posts:
    16
    upload_2023-6-16_16-9-58.png

    On any Input do this. This will disable RLD or RTD depending what plugin you use while you type when you come off the textbox it will just turn back on.
     
    ignarmezh likes this.
  35. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hi Jack,

    Thanks for making the recording!

    I can see that the position of the parent doesn't move. But It's very interesting because it should work.

    First of all, let's try this: ObjectSelectEntireHierarchy.Get.SetActive(true); doesn't have to be called every time. You can just call it once at app startup and it will stay active. In fact this class actually uses its own preselect customize handlers. That's what it's doing behind the scenes.

    Can you please try this first, and see if it works?

    EDIT: In my local version of RLD, ObjectSelectEntireHierarchy.Get.SetActive(true); is actually called in the Start function inside RLD.cs So you don't really need to call it.

    I think what you need to do is this:
    -select the RTObjectSelection object in the hierarchy;
    -in the Insepctor, make sure the Selectable object types field has the Empty object type checked.
    Just tested this with an LOD hierarchy and it works for me.
    Andrew
     
    Last edited: Jun 16, 2023
  36. xzavier2142

    xzavier2142

    Joined:
    Jul 15, 2019
    Posts:
    16
    Thanks for this, I'm finding if you make Selectable Object types Empty, my Tree which is layer Tree and has 3 LODS on it is not selectable,

    The parent has a mesh collider and nothing else and a LOD Group.
    The children all have mesh and materials

    Is this why? does the parent need a mesh?

    -Jack
     
  37. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    The parent doesn't need to have a mesh, but the default selection settings don't allow empty objects to be selected. So, just make sure you adjust the Selectable object types field to also include empty objects. And that's it :)
     
  38. xzavier2142

    xzavier2142

    Joined:
    Jul 15, 2019
    Posts:
    16
    I will do some more testing. Thanks for getting back in touch super fast, I do have a question, have you thought about setting up a Support Discord just for your Assets so others can discuss code improvements and support each other faster, unity forums are sometimes awful for support

    - Jack
     
  39. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Not a huge fan of Discord. I try to answer as fast as I can when there is nothing else I have to do.
    Let me know if you manage to make it work. It should work :)
     
  40. xzavier2142

    xzavier2142

    Joined:
    Jul 15, 2019
    Posts:
    16
    I'm also working with our Dev team too see if we can improve the codebase, anything we find we'll give you a Direct Message.

    -Jack
     
  41. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Sure thing :)
     
  42. xzavier2142

    xzavier2142

    Joined:
    Jul 15, 2019
    Posts:
    16
    I managed to get it working, I found that in my case I can't select anypart of my tree I have to select a small area near the base, this is fine for me but It's not likely fine for the clientbase, is the area which can be selected be made larger?

    upload_2023-6-16_19-29-38.png

    I have also updated the selection line to be an outline just something I'm working on

    - Jack
     
  43. ignarmezh

    ignarmezh

    Joined:
    Mar 23, 2017
    Posts:
    56
    And I have one more question.
    Does "Runtime Collider Light Gizmos" work with the RLD successfully or only with RTG?
     
  44. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hello,

    'Runtime Collider & Light Gizmos' has been deprecated and it was merged with RTG. So RTG now contains all the functionality in 'Runtime Collider Light Gizmos'.

    RLD doesn't currently have collider & light gizmos. Maybe in a future update.
     
    ignarmezh likes this.
  45. ignarmezh

    ignarmezh

    Joined:
    Mar 23, 2017
    Posts:
    56
    @XGT08 I have one more question, how can I change position of scene's axes and cap box gizmo with Presp or Vert lable under (it is in the right corner of sceen of window)? Because I have custom UI and I want to change sometimes this position. I can’t find where in your code their position is set to change it custom.
     
  46. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hi there,

    Select the RTGizmosEngine object in the hierarchy view, and in the Inspector, activate the Scene Gizmo tab. The controls shown in the image below will allow you to change its position:
    scene_gizmo_pos_ui.png
     
    ignarmezh likes this.
  47. ignarmezh

    ignarmezh

    Joined:
    Mar 23, 2017
    Posts:
    56
    @XGT08 How can I display "Persp" and "Vert" label under the Canvas'es elements?
    I have dynamic UI elements and sometimes I can move them to this area and there is a problem when they are displayed above the UI.
    upload_2023-8-7_12-28-52.png
     
  48. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hello,

    The position of the label can not be modified. It always appears below the scene gizmo. But you can turn the label on/off as needed:

    Code (CSharp):
    1. Gizmo g = RTGizmosEngine.Get.GetSceneGizmoByCamera(yourCamera).OwnerGizmo;
    2.  
    3. g.SceneGizmo.LookAndFeel.IsCamPrjSwitchLabelVisible = false;
    4.  
    5.  
    EDIT: In order to access the screen rectangle where the gizmo is being drawn, this should do the trick: Rect gizmoScreenRect = g.SceneGizmo.SceneGizmoCamera.Camera.pixelRect;

    You should be able to use this to check if there is an overlap between the UI panels and the scene gizmo rectangle.
     
    Last edited: Aug 7, 2023
    ignarmezh likes this.
  49. artificcz

    artificcz

    Joined:
    Aug 2, 2021
    Posts:
    2
    Hello,

    I would like to limit buildable area. E.g. a cube 50x50x50m. Do you have any tips how to do this?
     
  50. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    Hi there,

    It's not really possible I'm afraid. You could try something like this, but it would work only for the gizmos, the selection mechanism would still be able to push objects outside the build area:

    Code (CSharp):
    1. class Limits : MonoBehaviour, IRTTransformGizmoListener
    2. {
    3.        [SerializeField]
    4.        private Vector3 _minLimit = new Vector3(-50.0f, -50.0f, -50.0f);
    5.        [SerializeField]
    6.        private Vector3 _maxLimit = new Vector3(50.0f, 50.0f, 50.0f);
    7.  
    8.        public bool OnCanBeTransformed(Gizmo transformGizmo)
    9.        {}
    10.  
    11.        public void OnTransformed(Gizmo transformGizmo)
    12.        {
    13.              // Clamp object position
    14.              gameObject.transform.position = Vector3.Max(gameObject.transform.position, _minLimit);
    15.              gameObject.transform.position = Vector3.Min(gameObject.transform.position, _maxLimit);
    16.              gizmo.ObjectTransformGizmo.RefreshPosition();
    17.        }
    18. }
    This should reside in a script which must be attached to all game objects that will be transformed by gizmos.