Search Unity

Runtime Level Design

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

  1. JenniB

    JenniB

    Joined:
    Feb 15, 2018
    Posts:
    62
    Does not work :(
    When i click on the duck and move the appearing gizmo, the house is moving too.
     
  2. JenniB

    JenniB

    Joined:
    Feb 15, 2018
    Posts:
    62
    This is my Start method:
    Code (CSharp):
    1. private void Start() {
    2.         /* Disable that the whole hierarchy is selected */
    3.         ObjectSelectEntireHierarchy.Get.SetActive(false);
    4.         /* Selection Handler */
    5.         RTObjectSelection.Get.Changed += OnSelectionChanged;
    6.     }
    The structure of the model looks like this:

    upload_2018-7-30_18-26-8.png
     
  3. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    I believe what is happening here is that The RLDApp class has its Start function executed after your own start function and it overrides the value. I make a call to ObjectSelectEntireHierarchy.Get.SetActive(true) inside Start.

    Please move the code inside the OnPostInit function inside the RLDApp class.
     
  4. JenniB

    JenniB

    Joined:
    Feb 15, 2018
    Posts:
    62
    Now it works thanks! :)

    But when you create an update for this plugin, perhaps all the changes i made in the RLDApp class get deleted?
     
  5. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    That's true indeed. I will think if a better way to do this and I believe I will use events.

    Meanwhile, you can move the code back to your own Start function and adjust the script execution order such that the RDLApp script executes before your own script. Let me know if you need any help with this.
     
  6. JenniB

    JenniB

    Joined:
    Feb 15, 2018
    Posts:
    62
    Thanks :) Will I tell you when i need help.


    Another thing i want to do in my application is to disable the selection method "multi select via rectangle shape" in some situations. Is this possible somehow?

    Edit: I have a Box around a gameObject and when I change the size of this box at runtime with the mouse movement, i do not want to select some other objects.
     
  7. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    In order to disable multi-select, you can perform the following steps:
    1. select the RTObjectSelection game object in the hierarchy view;
    2. in the Inspector, click on the General tab;
    3. Uncheck the Can multi-select toggle.

    To do it from code, you would have to write:
    Code (CSharp):
    1. RTObjectSelection.Get.Settings.CanMultiSelect = false;
    I am not sure what you mean by this :)
     
  8. JenniB

    JenniB

    Joined:
    Feb 15, 2018
    Posts:
    62
    I mean by that, that I have a box gameobject around my model and when I resize it in game mode with my mouse, then the multiSelect mode is triggered :D
     
  9. JenniB

    JenniB

    Joined:
    Feb 15, 2018
    Posts:
    62
    Another issue i saw is when toggling the gizmos is taking too long.
    In Game mode when i click on an gameobject with my mouse and right after that i move the mouse to another position, since the toggling of the gizmos is taking so long, this multiSelect Mode is triggered.

    I do not know why it takes so long :oops:
     
  10. JenniB

    JenniB

    Joined:
    Feb 15, 2018
    Posts:
    62
    It works :)
     
  11. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    Gizmo activation should be instant. Can you should me a screenshot of your scene?
     
  12. JenniB

    JenniB

    Joined:
    Feb 15, 2018
    Posts:
    62
    upload_2018-8-1_16-14-53.png
    Now i saw that this delay just appears when I click on the object for the first time. After that it is always instant.

    But sometimes when i click on it, the onSelectionChanged() method gets fired, but it will noch be selected via gizmo :eek:
    Just at some position on the object.
     
  13. JenniB

    JenniB

    Joined:
    Feb 15, 2018
    Posts:
    62

    You found any reason for that?
     
  14. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    "Now i saw that this delay just appears when I click on the object for the first time. After that it is always instant."
    Please open the RLDApp.cs file an look inside the Start function. At the end of the function there should be this line of code:

    Code (CSharp):
    1. RTMeshCompiler.CompileEntireScene();
    I'm having some trouble understanding this issue. Can you give more details? Also if you are using an OnSelectionChanged handler, please send me a screenshot.
     
  15. JenniB

    JenniB

    Joined:
    Feb 15, 2018
    Posts:
    62
    Hello :)
    Thanks for your answer!
    In my scene i load asynchronously a 3D Model. RTMeshCompiler.CompileEntireScene() and therefore the Start() method of the RLDApp is executed before loading the model. Even when i defined the script execution order. So I think that the scene is compiled without this model and therefore the delay occures. What do you think?

    Thanks!
     
  16. JenniB

    JenniB

    Joined:
    Feb 15, 2018
    Posts:
    62
    I reproduced this issue by just clicking on the 3D model. I made a Debug.Log( ) in my onSelectionChanged handler and saw that the Debug counter increased but the 3D model was not selected. This issue occured by clicking in this marked area. But after reclicking on it, it got selected. So it just happends sometimes.

    upload_2018-8-17_15-56-26.png

    My handler for OnSelectionChanged:

    Code (CSharp):
    1. void OnSelectionChanged(ObjectSelectionChangedEventArgs args) {
    2.         List<GameObject> selectedObjects = RTObjectSelection.Get.SelectedObjects;
    3.         Debug.Log(selectedObjects.Count);
    4.         if (selectedObjects.Count > 0) {
    5.             /* Objects are selected -> enable Object detail view */
    6.  
    7.             /* Count without Selection Box */
    8.             int numSelectedObjects = selectedObjects.Count;
    9.             if (selectedObjects.Any((gameObject) => gameObject.GetComponent<CappedSectionBox>() != null)) {
    10.                 numSelectedObjects -= 1;
    11.             }
    12.             if (numSelectedObjects > 0) {
    13.                 /* Show detail view */
    14.                 NumberofSelectedUi.GetComponent<Text>().text = numSelectedObjects + " object(s) selected";
    15.                 ObjectsDetailsUi.SetActive(true);
    16.             }
    17.         } else {
    18.             /* None Objects are selected -> disable Object detail view */
    19.             ObjectsDetailsUi.SetActive(false);
    20.         }
    21.         foreach (GameObject selectedObject in selectedObjects) {
    22.             Debug.Log("onSelectionChanged: " + selectedObject.ToString());
    23.         }
    24.     }
     
  17. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    Ok. I see. I think you are right.

    In that case, whenever you load the model, please also execute the following code:

    Code (CSharp):
    1. Mesh mesh = gameObject.GetMesh();
    2. if (mesh == null) return false;
    3.  
    4. var rtMesh = RTMeshDb.Get.GetRTMesh(mesh);
    5. if (rtMesh == null) return false;
    6.  
    7. rtMesh.BuildTree();
    where gameObject is the object that contains the mesh. The idea is to just acquire a reference to the loaded model and then use that to retreive an rtMesh by calling RTMeshDb.Get.GetRTMesh(mesh); Finally call BuildTree

    Regarding the other issue, I have no idea why that is happening. I haven't had a chance to look into it yet, but as soon as I find something, I will let you know.
     
    JenniB likes this.
  18. JenniB

    JenniB

    Joined:
    Feb 15, 2018
    Posts:
    62
    Now it works thanks :)
     
  19. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    That's great to hear :)
     
  20. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    628
    Think I might have found a bug, when I try changing the Scene Gizmo position via the Placement, Screen Corner drop down to anything other than Top Right, then every time I run my project the dropdown defaults back to Top Right.

    Any ideas how I can fix?

    Thanks!
     
  21. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    Hi Greg,

    I have just sent you an e-mail which contains the fix.

    Thanks,
    Andrew
     
    Greg-Bassett likes this.
  22. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    628
    Many thanks! Works perfect!
     
  23. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    628
    Another query... I tried duplicating the RTSceneGrid gameobject so that I could have a grid for each axis, but it caused errors in the console.

    Do you know why? and whether it would be easy to modify the code to allow more than one grid plane?

    No big deal, just a nice to have...

    Thanks!

    Greg
     
  24. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    Hi Greg,

    Oh.. :) Unfortunately The RTSceneGrid class is a singleton. Therefore I always make the asumption in my code that there is only one grid available. It would definitely be possible to have multiple grids in the scene at some point, but I am not sure about the implications. I mean off the top of my head there isn't a quick fix for that. I will spend some more time to think about this and if I think it's feasible, I will add it in the future :)

    Thanks,
    Andrew
     
    Greg-Bassett likes this.
  25. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    628
    OK, np! As I say it would be a nice to have feature in RLD for the future... I use the ProGrids asset in the Unity Editor and it really helps having multiple grids sometimes when laying out a level.

     
    XGT08 likes this.
  26. JenniB

    JenniB

    Joined:
    Feb 15, 2018
    Posts:
    62
    Is it somehow possible to minimize the icons? for example the icon for the light in game mode?
     
  27. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    You have to select the RTScene object and in the Inspector, you have to modify the Non-mesh object size property. This will modify the size of the light and particle system icons at the same time. It is not possible to specify independent sizes for each.

    Note: Changing this size will also change the way you interact with the objects. You can think of this size as the size of a collider attached to the light and particle system objects. The smaller it gets, the more precise mouse clicks need to be to select lights, particle systems etc
     
  28. JenniB

    JenniB

    Joined:
    Feb 15, 2018
    Posts:
    62
    Hello :)
    When loading a big model into my scene with over 1 million vertices and thousand of nodes the following error occurs:

    Code (CSharp):
    1. StackOverflowException: The requested operation caused a stack overflow.
    2. RLD.SphereTreeNode`1[UnityEngine.GameObject].EncapsulateChildrenBottomUp () (at Assets/Runtime Level Design/Scripts/Runtime Package Common/BVH/SphereTreeNode.cs:155)
    3. RLD.SphereTreeNode`1[UnityEngine.GameObject].EncapsulateChildrenBottomUp () (at Assets/Runtime Level Design/Scripts/Runtime Package Common/BVH/SphereTreeNode.cs:155)
    4. RLD.SphereTreeNode`1[UnityEngine.GameObject].EncapsulateChildrenBottomUp () (at Assets/Runtime Level Design/Scripts/Runtime Package Common/BVH/SphereTreeNode.cs:155)
    5. RLD.SphereTreeNode`1[UnityEngine.GameObject].EncapsulateChildrenBottomUp () (at Assets/Runtime Level Design/Scripts/Runtime Package Common/BVH/SphereTreeNode.cs:155)
    6. RLD.SphereTreeNode`1[UnityEngine.GameObject].EncapsulateChildrenBottomUp () (at Assets/Runtime Level Design/Scripts/Runtime Package Common/BVH/SphereTreeNode.cs:155)
    Any idea how I can get rid of this error? Minimize the amount of nodes?
     
  29. Icezman

    Icezman

    Joined:
    Mar 31, 2017
    Posts:
    7
    Hello,

    I'm really happy about your asset so far. I'm trying to use only some features for a project I'm working on.
    In case of the move Gizmo, I would like to have the snapping always on. In the inspector I can change the hotkeys for it, but I failed to find in the code where I can just put the snap on programmatically.

    In general, I would like to know how to programmatically put on things that require a hot key.
     
    XGT08 likes this.
  30. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    Hi there @Icezman,

    Enabling snapping for a gizmo is done using the following function call:
    Code (CSharp):
    1. // Enable snapping for the move gizmo
    2. Gizmo gizmo = RTObjectSelection.Get.GetGizmoById(ObjectSelectionGizmoId.Move);
    3. gizmo.MoveGizmo.SetSnapEnabled(true);
    4.  
    5. // Same for other gizmo types
    However, I just realized that this is not enough because the state of the hotkey will override this. I will have to make some changes in code to allow you to do this.

    In general, you can look inside the following classes: MoveGizmo, RotationGizmo, ScaleGizmo, UniversalGizmo and spot the public functions. Most of these are really well named so you should identify their purpose easily. Let me know if you need more help.

    And I will get back to you with the changes required to allow you to activate the snap states from code.
     
  31. XGT08

    XGT08

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

    I'm afraid I will need some models to play around with in order to spot the issue. Do you own the models? Are you allowed to share one of them? If yes, please export a Unity package which contains a prefab that uses the model. No materials or textures are needed.
     
  32. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    Hi @Icezman

    I have sent you a PM with the link to the updated pack.

    So here is a screenshot which should help you understand how to activate the states from code:

    GizmoStates.png

    So, these states can be modified for the move, rotate, scale and universal gizmos.

    You have to turn off the hotkey for that state by using one of the Use### properties. For example,
    if you want to control the snapping for the move gizmo from code, you will need to set the UseSnapEnableHotkey property to false and then call the SetSnapEnable function to enable snapping.

    Let me know if this helps.
    Andrew
     
  33. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    @Icezman
    I made a mistake and included the code that is shown in the image above inside the RLDApp class. You can find this code at the end of the Start function and delete it from there. Sorry about that.
     
  34. Icezman

    Icezman

    Joined:
    Mar 31, 2017
    Posts:
    7
    Thanks for the changes tailored made for me :).
    Also, I've managed to even change the snapping step at runtime as well.
    Thank you for your help.

    Can now everything that you normally enable through Hotkeys be enables programmatically as well?
     
  35. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    For the move, rotate, scale and universal gizmos, yes. There are other parts of the API where this may still not be possible. But if you find that you need more of these changes, let me know and I will try to see what I can do.

    In order to change the gizmo settings from code, you need to access the settings via properties such as:
    RTObjectSelectionGizmos.Get.MoveGizmoSettings;
    RTObjectSelectionGizmos.Get.MoveGizmoLookAndFeel;
    etc.
     
  36. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    Hi, Loving RLD! However I would love to see support for more Object Selection Types out of the box. For example Camera selection. At the moment it only seems to support Mesh, Light and Particle.
     
  37. XGT08

    XGT08

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

    Happy to hear you like RLD.

    You can select cameras, by checking the Camera item in the Selectable object types mask:
     
  38. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    lol! How did I miss that? Thank you!
     
  39. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    Oh, for further clarity, I also meant there seems to be no Icon for Camera, and other objects types in in RT Scene. Only Particle and Light.
     
  40. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    Possible Bug found! Not sure where to report it.

    When adding "Camera" in the Selectable Object Types in RT Object Selection, the following error appears:
    Mask menu has no instance
    UnityEditor.MaskCallbackInfo:SetMaskValueDelegate(Object, String[], Int32)


    After that, at run time, single mouse button clicks fail to select an object. Only drag selection allows object(s) to be selected.

    Deselecting Camera results in normal selection behavior.

    Using Latest Builds of Official Unity and RLD.
     
  41. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    I will investigate this. Thanks for reporting.
     
  42. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    @JenniB
    I have received your message and I will look into it. Thanks!
     
  43. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    @Hexagon-Neuron
    Hi there,

    I've sent you a PM with the updated package that contains the following:
    1. a bug fix which would cause you to select the RTFocus camera object when camera selection was enabled;
    2. you can now render camera icons in the scene;
    3. all icons have been repalced with the ones that Unity uses inside the Unity editor.

    I have not managed to reproduce the error that you showed me. Let me know if it still happens.

    Cheers,
    Andrew
     
  44. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    Fantastic! Will check it out now :)
     
  45. quentin_brun

    quentin_brun

    Joined:
    Sep 12, 2017
    Posts:
    5
    Hi,

    I think there is a bug in the RTGizmosEngine class. SceneGizmoLookAndFeel is not maked as "SerializeField" so when making change from the inspector, the scene gizmo tab of the RT Gizmo engine is not saved.

    I fixed it locally but it would be great if you could fix it in your next release or explain how to save these preferences.

    Thank,
    Quentin
     
  46. quentin_brun

    quentin_brun

    Joined:
    Sep 12, 2017
    Posts:
    5
    Hi,

    It seem that you already fixed it in 2.1.1, I apologize.

    Have a good day!
     
  47. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    No problem. Yes, the issue was fixed.
     
  48. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    Hi Andrew. Quick question please :)

    I need to assign SetTargetCamera during runtime, after other stuff has happened in the scene.

    I do so like this:
    RTFocusCamera.Get.SetTargetCamera(CameraPrefab.GetComponent<Camera>())

    Whilst assigning SetTargetCamera works, the camera gizmos and selection tools etc are broken in various ways. It's like the wrong camera is being used for certain functions.

    Is there anything I should be aware of or best practices when assigning SetTargetCamera at runtime?

    Thanks!
     
  49. XGT08

    XGT08

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

    So if you are trying to use a separate camera for the purposes of using multiple viewports, it would be helpful to read: https://rld.readthedocs.io/en/latest/TheRTCameraViewportsClass/

    Otherwise, it should work with the following line of code:
    Code (CSharp):
    1. RTGizmosEngine.Get.AddRenderCamera(camera);
    My recommendation is to use the viewport API even if your intentions are different. I say this because the viewport API is the module that knows what needs to be done when a new camera is activated and the plugin listens to events such as when the focus camera has changed etc. So to make your code future-proof :) , you should use the viewport API.

    Let me know if you have any further questions.
     
  50. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    Great to know, and has already given me some ideas. Thank you!