Search Unity

Runtime Level Design

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

  1. Qbasic8

    Qbasic8

    Joined:
    May 22, 2014
    Posts:
    16
    Hello, I was wondering where in your code I could find what mode the Gizmo's are in (Move, Rotate, Scale)... I am making an on screen display informing the user (since my level designer isn't use to the controls of Unity) which mode they are in.
     
  2. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    Hi, been trying to find a way to set the type of gizmo through code. For example change to rotation gizmo. Searching the forum and API docs has not been successful (it's Friday so it could well be me!). Any pointers please Octave? Thanks.
     
  3. XGT08

    XGT08

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

    :) It's not documented it seems. You can accomplish that by writing:
    Code (CSharp):
    1. RTObjectSelectionGizmos.Get.SetWorkGizmo(ObjectSelectionGizmoId.MoveGizmo);
    This code activates the move gizmo. The ObjectSelectionGizmoId is a static class that contains integer ids for all gizmos. Hope this helps.
     
    code-blep likes this.
  4. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    Yep! That worked :)

    One other quick question please. I am modifying (destroying and replacing) a selected object. I am trying to add the new object back into the selected list, ready for further changes. Is there a way to do this in the API? Many thanks!
     
  5. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,909
    You can use the API to change the selection from script. You can find info about this here: https://rld.readthedocs.io/en/latest/ChangingTheObjectSelection/
     
  6. AlexSbysh

    AlexSbysh

    Joined:
    Feb 23, 2015
    Posts:
    4
    Hello! When I select any child object, parent object with all its children is selected as one selection.
    Is there any way to select just one child object as separated selection? (Unity 2019.1.3)
    child_cubes.png
     
  7. XGT08

    XGT08

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

    You should write this code somewhere in your initialization code:
    Code (CSharp):
    1. ObjectSelectEntireHierarchy.Get.SetActive(false);
     
    AlexSbysh likes this.
  8. AlexSbysh

    AlexSbysh

    Joined:
    Feb 23, 2015
    Posts:
    4
    I created simple script
    Code (CSharp):
    1. public class RLDAppInit : MonoBehaviour
    2. {
    3.     private void Awake()
    4.     {
    5.         ObjectSelectEntireHierarchy.Get.SetActive(false);
    6.     }
    7. }
    and attached it to "RLDApp" object on scene.

    But nothing changed. :confused:
     
  9. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,909
    Ok. Try the following:

    Code (CSharp):
    1.     public class RLDAppInit : MonoBehaviour
    2.     {
    3.         private void Awake()
    4.         {
    5.             RLDApp.Get.Initialized += OnAppInitialized;
    6.         }
    7.  
    8.         private void OnAppInitialized()
    9.         {
    10.               ObjectSelectEntireHierarchy.Get.SetActive(false);
    11.         }
    12.     }
    13.  
     
    AlexSbysh likes this.
  10. AlexSbysh

    AlexSbysh

    Joined:
    Feb 23, 2015
    Posts:
    4
    It works now, thanks!
     
  11. Qbasic8

    Qbasic8

    Joined:
    May 22, 2014
    Posts:
    16
    Hello. I was wondering if their is a way to 'refresh' the gizmo's. If I rotate a gameObject with the gizmo, then alter the rotation through code (UI inputfield for x,y,z) the gameObject rotates, but the gizmo will of course be incorrect. If you deselect the object and select it again the gizmo shows correctly. Is there a method to just "Refresh" the selection?
     
  12. XGT08

    XGT08

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

    You will have to retrieve a reference to each gizmo and then call a method to refresh the gizmo:
    Code (CSharp):
    1. RTObjectSelectionGizmos.Get.GetGizmoById(ObjectSelectionGizmoId.MoveGizmo).ObjectTransformGizmo.RefreshPositionAndRotation();
    2. RTObjectSelectionGizmos.Get.GetGizmoById(ObjectSelectionGizmoId.RotationGizmo).ObjectTransformGizmo.RefreshPositionAndRotation();
    3. RTObjectSelectionGizmos.Get.GetGizmoById(ObjectSelectionGizmoId.ScaleGizmo).ObjectTransformGizmo.RefreshPositionAndRotation();
    4. RTObjectSelectionGizmos.Get.GetGizmoById(ObjectSelectionGizmoId.UniversalGizmo).ObjectTransformGizmo.RefreshPositionAndRotation()
    5. RTObjectSelectionGizmos.Get.GetGizmoById(ObjectSelectionGizmoId.BoxScaleGizmo).BoxGizmo.FitBoxToTargetHierarchy();
    6. RTObjectSelectionGizmos.Get.GetGizmoById(ObjectSelectionGizmoId.ExtrudeGizmo).ObjectExtrudeGizmo.FitBoxToTargets();
     
    Last edited: Jun 21, 2019
  13. Qbasic8

    Qbasic8

    Joined:
    May 22, 2014
    Posts:
    16

    I'm sure I am doing something dumb, but I have no .RefreshPositionAndRotation in the above code when put into my script. Any ideas?

    Error - Their is no definition for RefreshPositonAndRotation and no extension method RefreshPositonAndRotation
     
  14. XGT08

    XGT08

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

    It was a mistake on my side. I have made the necessary corrections in my initial post.
     
  15. Qbasic8

    Qbasic8

    Joined:
    May 22, 2014
    Posts:
    16
    Thanks, that did the trick! Great product by the way!
     
    XGT08 likes this.
  16. CastleSeven

    CastleSeven

    Joined:
    Jan 24, 2018
    Posts:
    6
    Hi, I'm attempting to use RLD in a scene (not the first) in the software I'm writing. Here's the "Designer" scene that will let my users create their scene:
    upload_2019-6-24_15-18-19.png

    Prior to loading this scene, they will build a mesh collection in the previous scene, and that collection gets preserved via DontDestroyOnLoad. Unfortunately it seems like RLD cannot interact with objects that are marked DontDestroyOnLoad. Is there a way to change this behavior? If I drag my Mesh Collection out of DontDestroyOnLoad and into the "Designer" scene, it works fine.

    upload_2019-6-24_15-20-51.png
     
  17. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Hello, I've had a trawl through some of the forum but can't find any similar questions with answers, so will ask here (sorry if I missed any previous questions on the same things):

    1. I want all movement to be grid snapped. When you first place a new object it isn't snapped to grid, so when you move it and hold the snap to grid modifier key, it bases the snapping on the position the object was at right before you pressed the snap to grid modifier key. What is the best way to force snap to grid? (All my models will be a multiple of the grid size dimension wise)

    2. When you place a new piece from the UI, how would you select the new prefab in code so you can move the new prefab?

    3. What is the suggested way to prevent overlapping of placed prefabs?

    4. When you use the Extrude tool, with the mouse down on the selected prefab, you can move left and right and create new prefab instances in the exact same locations as existing ones (you can't see them as they are in the same place as existing ones). How do you prevent this?

    5. My prefab examples are 25cm i.e. a quarter of a grid unit. When moving using snapping, they are jumping 1m from the current position. I set the Cell size X and Y to 0.25 in the RT Scene Grid but this didn't affect the snapping interval, where do you set this please?
     
    Last edited: Jul 1, 2019
  18. XGT08

    XGT08

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

    1. Placed objects (the ones created when you click on a prefab preview) are not snapped to the grid. You can use selection grid snap to snap it to the grid. Hold down B, select a pivot and then hold down the left mouse button and move the mouse to snap. It is somewhat similar to vertex snapping inside the Unity Editor, but it works at the object bonding box level.

    2. You will need to register a handler for the PrefabSpawned event:
    Code (CSharp):
    1. RTPrefabLibDb.Get.PrefabSpawned += OnPrefabSpawned;
    2.  
    3. void OnPrefabSpawned(RTPrefab prefab, GameObject spawnedObject)
    4. {
    5.       // Use RTObjectSelection.Get to access the selection module and use one of the functions described here:
    6.       // https://rld.readthedocs.io/en/latest/ChangingTheObjectSelection/
    7. }
    3. This is not possible.

    4. Hold down Left Shift;

    5. If you are moving them with the move gizmo, you will need to set the snap step of the move gizmo. Select the RTObjectSelectionGizmos in the Inspector and then:

    SnapIncrements.png

    You can also change these values from script:
    Code (CSharp):
    1. MoveGizmo moveGizmo = RTObjectSelectionGizmos.Get.GetGizmoById(ObjectSelectionGizmoId.MoveGizmo);
    2. moveGizmo.Settings3D.XSnapStep = myXSnapValue;
    3. moveGizmo.Settings3D.YSnapStep = myYSnapValue;
    4. moveGizmo.Settings3D.ZSnapStep = myZSnapValue;
    Hope this helps,
    Andrew
     
  19. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Hi Andrew, thanks for going through each point, I've spent around 8 hours now going through things and really getting to grips with the system. Your responses will help fill in some of the gaps.

    The only request I have (and happy if you don't feel it would benefit your asset so prefer not to implement it) is to offer some overrideable function to check if the placement when instantiating new prefabs is allowed i.e. let us code the logic to check if placement of new prefabs is valid. Default if we do not implement the handler is TRUE, if we override and return FALSE then the new prefab should not be created. If this isn't something you would like to consider, it would just be trickier implementing this ourselves as we would be amending your classes rather than extending them so could never upgrade if you released a newer version.

    Thanks again, going to leave a review now :) or I would if it would save the review text!
     
    Last edited: Jul 1, 2019
  20. XGT08

    XGT08

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

    I understand. I think you should be able to already do that by using the instructions at point number 2 in my previous post. When the prefab is spawned, you can check if the spawned object overlaps any other objects (using Unity.Physics API) and then destroy spawnedObject if it does.

    Cheers,
    Andrew
     
  21. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,909
    No problem :) If you wish to leave a review, I think you would have better luck using the old store. The new one is buggy with all sorts of things.
     
  22. papazingo81

    papazingo81

    Joined:
    Jun 2, 2019
    Posts:
    14
    Hi, Andrew i have an issue after importing RLD, when adding objects to a created Prefab Library the preview image is incorrect. instead of showing the mesh preview it has this one:



    Im using probuilder meshes if that helps.

    Please help, thanks
     
  23. papazingo81

    papazingo81

    Joined:
    Jun 2, 2019
    Posts:
    14
    Has anyone worked out how to spawn in objects from the UI, and have them be selected automatically ready to be placed? Im stumped at the moment. :(
     
  24. XGT08

    XGT08

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

    Please see point number 2 in this answer: https://forum.unity.com/threads/runtime-level-design.380151/page-10#post-4701443

    Regarding the issue with the prefab previews. As long as the prefab hierarchy has at least one mesh object in it, it will show the mesh. In your case, it seems that a mesh object does not exist, but the plugin detected a particle system object and is using that. Are you sure those prefabs have meshes?
     
  25. papazingo81

    papazingo81

    Joined:
    Jun 2, 2019
    Posts:
    14
    Yeah i say that post, but still cant work it out.. im a bit of a Noob when it comes to C#. Just wondering if any1 had some luck and could give me a slight push in the right direction.

    As for the Mesh it seems right to me,

     
  26. papazingo81

    papazingo81

    Joined:
    Jun 2, 2019
    Posts:
    14
    Hi Andrew is it Possible to automatically Select Object-to-Object Snap mode without a Key press (after spawn for example)? If so can you point me in the right direction,as i've gone through the API docs and im note sure where to start. thanks.
     
  27. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,909
    This is not currently possible. I will have to first check if there is some way I can add this feature.
     
  28. papazingo81

    papazingo81

    Joined:
    Jun 2, 2019
    Posts:
    14
    Ok thanks bud
     
  29. papazingo81

    papazingo81

    Joined:
    Jun 2, 2019
    Posts:
    14
    Not sure if its just me, but when i use the extrude gizmo on a Gameobject, im unable to select the extruded part afterwards. Is this normal?

    Its actually anything i place down, once its been placed i cannot select the item again, any ideas m8?
     
    Last edited: Jul 5, 2019
  30. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,909
    Works fine for me. I can select the extruded parts with no issue.

    What do you mean when you say anything I place down. Place down in what way?
     
  31. papazingo81

    papazingo81

    Joined:
    Jun 2, 2019
    Posts:
    14
    Yeah sorry Andrew, it was my fault, my script was calling SetSelectedObjects in a loop for some reason so it was overriding every other selection. Fixed it though.

    Im mainly using your object2object snap and want to know if you will be implementing grid snap with mouse movement? (for example every 1m)

    Or point me in the direction where i can edit a script to implement this?
     
  32. XGT08

    XGT08

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

    Grid snapping in this manner is not currently possible in RLD. You could implement this by capturing the PrefabSpawned event in the RTPrefabLibDb class and taking control of the spawned object.

    However, I am currently working on a new plugin which can be integrated with RLD and this plugin will support this functionality. It will take around 2 weeks to be approved on the store, but it will be super handy.
     
    papazingo81 and tapticc like this.
  33. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Hi, I solved this by ignoring the snap modifier button being pressed, so the code assumes the button is being pressed always. I did this for the move and rotate gizmos so they always snap, but it's hard-coded so would lose it should I ever update the asset (don't think I will need to but that depends on if it needs changes for the new asset due to be released soon)
     
  34. XGT08

    XGT08

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

    Sorry for the late reply. Can you please describe the functionality that you desire?
     
    tapticc likes this.
  35. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,909
    Hi everyone,

    I just wanted to let you know that I have recently released a plugin that is a great complement to RLD.
    Note: The plugin contains a script called RLDIntegration.cs which shows all the steps required to integrate with RLD. The script is meant to be studied and not used as is in the project :)

    The plugin is called Runtime Spawner and can be found here.

    Here are 3 video tutorials:

    Prop placement:


    Grid snapping:


    Spawn Effects:


    For those of you who would develop for Linux or MAC OS, there is an issue you need to be aware of. Please watch this video to see what I am talking about:
     
  36. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Hello, I just wanted any prefab placed to align to a grid (as if you were dragging using the snap modifier). I just hard coded this but would be a nice option out of the box to place snapped to grid. Also rotating, it is preferable to place a prefab 90 degrees to an axis rather than 62.672 and then struggle to rotate properly to a 90 degree angle. Not difficult to code but would be nice out of the box. I have your new asset which helps of course!
     
  37. astratakis

    astratakis

    Joined:
    Mar 18, 2019
    Posts:
    10
    Hello and thank you for this amazing asset. Is it possible to call Undo / Redo from code? I see that it only checks for the shortcut to execute each function.
    Thank you in advance.
     
    XGT08 likes this.
  38. XGT08

    XGT08

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

    If you go inside the RTUndoRedo.cs file, you can make the Undo and Redo functions public. Currently they are marked as private. Once you make them public, you could write:
    Code (CSharp):
    1. RTUndoRedo.Get.Undo();
    2. RTUndoRedo.Get.Redo();
     
    astratakis likes this.
  39. astratakis

    astratakis

    Joined:
    Mar 18, 2019
    Posts:
    10
    Thank you for your reply. That is my current implementation. I just didn't want to change the library in case of an update.
     
  40. XGT08

    XGT08

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

    I will remember to make those public in the next update. There is no reason why they should be private :) So no worries there.
     
  41. juliocdep

    juliocdep

    Joined:
    Sep 30, 2010
    Posts:
    30
    Hi,

    How the scale snapping works? It is set to 1 in all axes, but when I try to use it, it increase by a fraction number that seems relative to distance from camera instead of increase by 1. Is it a bug or something that I not understood?
     
  42. astratakis

    astratakis

    Joined:
    Mar 18, 2019
    Posts:
    10
    Hello again,
    I want to implement the following behavior: I select an object and then if a handler is not selected I want to drag it using ZXDblSlider. Is there a way to start the event of clicking and dragging the ZXDblSlider without actually pressing on it?
     
  43. XGT08

    XGT08

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

    No, this is not possible, dragging is only done in response to the user dragging the mouse.
     
  44. XGT08

    XGT08

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

    I will have to take a look at this and get back to you once I have an answer.
     
  45. XGT08

    XGT08

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

    It turns out it was a bug. I have sent you a PM with a link to the updated pack.
     
  46. reflipd

    reflipd

    Joined:
    Jun 4, 2019
    Posts:
    5
    Can this be used for realtime multiplayer?
     
  47. XGT08

    XGT08

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

    No, I don't think so. I have not taken any steps to ensure that.
     
  48. RickC

    RickC

    Joined:
    Dec 1, 2012
    Posts:
    4
    Hi

    I believe I will be buying this product as it does what I need it to do! However I do need the ability to select a placed object, have a UI window pop up with details about the object and to change some of those details in the UI at runtime. Obviously this would enable a user far greater power on changing an objects attributes etc.

    So I guess the real question is, does ugui integrate easily, and do you have any examples of this?
     
    Last edited: Aug 27, 2019
  49. XGT08

    XGT08

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

    This functionality is not part of the product. The product is concerned with the level design aspects of things. From there, you can build on it as you wish. So once a game object (or collection of objects) has been selected, you can get access to those objects and implement whatever UI is necessary for your app.

    Cheers,
    Andrew
     
  50. imagoculturae

    imagoculturae

    Joined:
    Apr 8, 2014
    Posts:
    81
    So...I convinced my boss to by this great tool for architectural visualization...however it seams not to work under HDRP.
    Here are the issues:
    - In the PrefabLibDB the shader is not recognized and the texture of the object does not appear
    - I am not able to select the object at runtime
    - on the top right corner appears another view of the camera instead of the xyz gizmo.

    If I use a standard 3d Project everything works fine, this only happens when using HDRP.
    Could you give some help?
    Many thanks and keep up the great work!!!