Search Unity

Runtime Transform Gizmos (Move, Rotate, Scale, Universal, Scene Gizmo, Navigation Camera)

Discussion in 'Assets and Asset Store' started by XGT08, Sep 13, 2018.

  1. j_ho_74

    j_ho_74

    Joined:
    Aug 13, 2014
    Posts:
    24
    Hi
    almost the same here except for HDRP.
    Are there any plans to support the "new" render pipelines?

    All the best
    Joerg
     
    zim22 likes this.
  2. XGT08

    XGT08

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

    There are currently no plans to support these pipelines just yet. The whole thing seems messy to me and currently I'm staying away from it. Once it stabilizes, I will consider supporting new pipelines.
     
  3. zim22

    zim22

    Joined:
    Feb 25, 2018
    Posts:
    44
    How difficult will it be to add HDRP support myself? How many files/shaders must be modified? I need a Universal gizmo manipulator (Move/Rotate) in my project...
     
  4. j_ho_74

    j_ho_74

    Joined:
    Aug 13, 2014
    Posts:
    24
    If I would take a guess you would have to rebuild all the shader that come with RTG in Shadergraph for HDRP
    Cheers J
     
  5. zim22

    zim22

    Joined:
    Feb 25, 2018
    Posts:
    44
    Yes, you are right. But no need to use ShaderGraph. Just use HDRP/Lit.shader source file as a base.
     
  6. j_ho_74

    j_ho_74

    Joined:
    Aug 13, 2014
    Posts:
    24
    Hi zim22
    did you get RTG working in HDRP?
    Cheers J
     
  7. zim22

    zim22

    Joined:
    Feb 25, 2018
    Posts:
    44
    I think I made a mistake somewhere rewriting shaders to HDRP - it does not look very good.
    Nevertheless, I can share my code with plugin's author.
     
  8. j_ho_74

    j_ho_74

    Joined:
    Aug 13, 2014
    Posts:
    24
    Would be great :)
     
  9. dhtpdud528

    dhtpdud528

    Joined:
    Apr 8, 2018
    Posts:
    23
    I'm touched by your Asset! It's exactly the one I've been looking for.
    Is it possible to change the size of the gizmo?
     
    XGT08 likes this.
  10. XGT08

    XGT08

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

    If you click on the RTGizmosEngine object in the hierarchy an inspector will appear. On the top you have a toolbar that allows you to select the gizmos that you would like to have their settings displayed. After you clicked on a gizmo, there is a 3D look and feel section. In there there is a scale property. That can be used to increase or decrease the gizmo size.

    Cheers,
    Andrew
     
    dhtpdud528 likes this.
  11. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    65
    Hello,

    can the slider length be adjusted for all axes separately?
    I need to adjust the length of the Gizmo axes to the object being scaled:
    i.e.: x-Axis: 1.3m, y-Axis:1.5m, z-Axis 3.2m.

    Best regards,
    Christian
     
  12. XGT08

    XGT08

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

    I'm afraid not, the slider length is common to all axes.

    Cheers,
    Andrew
     
  13. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    65
    Hello,

    could you implement this in the next releases?
    Also if you don't plan to implement SRP compatibility, I can't use your Asset and will try to get a refund.

    Best regards,
    Christian
     
  14. j_ho_74

    j_ho_74

    Joined:
    Aug 13, 2014
    Posts:
    24
    Hi
    "Also if you don't plan to implement SRP compatibility, I can't use your Asset and will try to get a refund."

    Me, too.

    Kind regards
    Joerg
     
  15. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    @chrpetry @j_ho_74
    The package description states clearly that scriptable render pipelines are not supported. Why did you purchase the asset in the first place?
     
  16. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    65
    Hello,

    alright. Sad, that you don't plan to maintain/update this.

    Best regards,
    Christian
     
  17. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    The package is maintained and updated, just not with SRPs. I have no obligation to add features I do not wish to support. This is why I specifically stated this in the package description.
     
  18. j_ho_74

    j_ho_74

    Joined:
    Aug 13, 2014
    Posts:
    24
    Hi
    sure you have no obligation, but it might be an opportunity to offer a separate package(s) which are srp/urp/hrdp ready.
    or the customer friendly version would be a upgrade version.
    There are several assets in the store which utilze this practice.

    just my 2 cents
    J
     
  19. bearforceone

    bearforceone

    Joined:
    Apr 12, 2018
    Posts:
    2
    Hi,
    I saw in previous posts that the universal gizmo is compatible with iOS and Android, however after building and testing on my iPad these universal gizmos are not visible. Any ideas on a fix for something like this? Thanks!
     
  20. XGT08

    XGT08

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

    Are you using SRP in your project? The pack does not support SRP.

    Regarding mobile support, it's kind of unofficial so to speak :) I am not very keen on mobile/touch screen devices in general. However, it should work.
     
  21. Spirals0

    Spirals0

    Joined:
    Aug 19, 2020
    Posts:
    5
    Ughh I miss the discount price, how often is it on sale?
     
  22. XGT08

    XGT08

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

    This depends on Unity when they invite me to participate. So I'm afraid I can't really say.
     
  23. siowchenying

    siowchenying

    Joined:
    Oct 27, 2020
    Posts:
    5
    Hello,

    I want to ask if it is possible to change each gizmo's axes, and have different unique gizmos in each scene. This is because I want to have multiple Universal Gizmo, but some of which may have a visible scaling feature (the white cube), and some may have the scaling feature disabled (invisible white cube).

    I can't seem to change the LookAndFeel3D in a way that does not affect all gizmos, so I can't create unique gizmo instances with different axes visibility. (maybe color as well)

    If there is any doubts, feel free to ask me for clarification.
     
  24. XGT08

    XGT08

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

    By default all gizmos share the same look and fell but this can be changed using the following code:
    Note: This code assumes you have created a move gizmo and would like to make the settings unique.
    Code (CSharp):
    1. moveGizmo.SharedLookAndFeel3D = null;
    2. moveGizmo.SharedLookAndFeel2D = null;
    3. moveGizmo.SharedSettings3D = null;
    4. moveGizmo.SharedSettings2D = null;
    When setting the Shared### property to null, the gizmo will use its own settings belonging to that category.

    Cheers,
    Andrew
     
    xfsadsbot and siowchenying like this.
  25. siowchenying

    siowchenying

    Joined:
    Oct 27, 2020
    Posts:
    5
    Nice, it worked perfectly. Thank you for the prompt reply.
     
  26. ematsuno

    ematsuno

    Joined:
    Oct 13, 2015
    Posts:
    27
    I have multiple objects on the screen, but I only want to have the current operating gizmo showing.
    Since these objects are being generated at run time, and I don't want the gizmo to show, I attach the object on mouse click.


    I don't want of the gizmos showing for any of the other objects when I click on a new object.
    How would I detach all of the other gizmos?


    public class touchattach: MonoBehaviour
    {

    ObjectTransformGizmo transformGizmo = RTGizmosEngine.Get.CreateObjectRotationGizmo();
    private void OnMouseDown()
    {
    RemoveAllTargets();
    transformGizmo = RTGizmosEngine.Get.CreateObjectRotationGizmo();
    transformGizmo.SetTargetObject(gameObject);
    transformGizmo.SetTransformSpace(GizmoSpace.Local);
    }

    private void RemoveAllTargets()
    {
    // how do you recommend I do this?
    // There is no "UnsetTargetObject() or ClearTargetObjects(). How would I do this?
    }


    }
     
  27. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    It is not very clear as to what you are trying to do. But if you need to enable/disbale the gizmos, then this video could prove useful:
     
    ematsuno likes this.
  28. ematsuno

    ematsuno

    Joined:
    Oct 13, 2015
    Posts:
    27
    The above code hides the axis for the Rotation Gizmo, but it still rotates.

    How do I disable the interactability in those directions?
     
  29. ematsuno

    ematsuno

    Joined:
    Oct 13, 2015
    Posts:
    27

    That was what I was looking for, thanks
     
  30. Deleted User

    Deleted User

    Guest

    I Recently Purchased Your Asset. it seems to work very well with my project. However i have a custom input manager in my game. I mean the players can change their input buttons. But RTG App doesnt have any options to change hotkeys for snapping and other features

    Can you please tell me how can i change the hotkeys. i mean to say how to make RTG register and save new hotkeys instead of the default ones.
     
    Last edited by a moderator: Dec 17, 2020
  31. XGT08

    XGT08

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

    You can do this from the Inspector. Modules that use hotkeys (such as the camera for example) allow you to change the hotkeys from the Inspector.

    So for the camera, for example, click on the RTFocusCamera object in the hierarchy view and this will bring up an Inspector in which you can change all sorts of settings, including the hotkeys.

    Cheers,
    Andrew
     
  32. gamergetik

    gamergetik

    Joined:
    Dec 16, 2020
    Posts:
    4
    No Actually what i meant is how can i change those via scripts not via inspector.

    I have found a workaround which i am using for now. Like setting
    Code (CSharp):
    1. moveGizmo.UseSnapEnableHotkey = false;
    2. moveGizmo.Use2DModeEnableHotkey = false;
    3. moveGizmo.UseVertSnapEnableHotkey = false;
    and then checking for user specified inputbutton and enabling it.

    I am wondering is there any way to manually change the hotkeys because while digging down the project i found you have Hotkeys getters only and not setters.

    The asset is great so far. Thanks Andew for saving our time.
     
  33. kristoof

    kristoof

    Joined:
    Aug 26, 2013
    Posts:
    89
    Hey!
    I just bought your asset for my game.
    However, it really slows down my project.
    In my editor I have 70-ish FPS, as soon as I enable the RTG components (or just start the scene with it enabled) my FPS drops to around 10.
    The profiler says RTGApp.Update() takes around 40-45ms.
    I really don't have that much, my whole game has to fit into around 16 ms with everything (render, cpu, gamecode, physics etc..) so the max would be 1ms that I can allocate for the gizmos+editing feature.
    I can't even deep profile because my unity just freezes.

    I tried deep profiling the sample scene too, I can observe the same behavior, most of the performance goes to RTGApp.Update()

    I attached some screenshots (can't upload profiler data here because it's 100mb) .
    rtg.png nortg.png profiler.png
    My specs:

    CPU: Intel Core i7-9750H (6 core 12 thread)
    GPU: GeForce RTX 2060 (laptop model but not the cut-down MAX-Q)
    16 Gb ram

    Can you point me to some performance docs?
    Great project but I can't use this the way it is.
    Thanks!
     
    DarkRides likes this.
  34. XGT08

    XGT08

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

    Hmm.... I think this is happening sometimes when there are too many objects in the scene. If you are not using vertex snapping, you could make the following change: inside the RTScene class (in RTScene.cs) find the Update_SystemCall function and comment its contents. Again, this will work as long as you are not using vertex snapping.

    For the moment, I can't think of a way to optimize this. The plugin simply needs to detect any new objects in the scene and then loop through all of them in order to detect any transform changes. This is where the overhead comes from.

    So do you need vertex snapping in your app?

    Cheers,
    Andrew
     
    kristoof likes this.
  35. XGT08

    XGT08

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

    I will take a quick look today and see if there is a good reason why there are no setters for the Hotkeys API. I don't think that there's a good reason behind it. If so, I will change the API to allow the changing of hotkeys via script. I will keep you posted.

    Cheers,
    Andrew
     
  36. XGT08

    XGT08

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

    I took a look over the code and it seems that you can already change the hotkeys.

    So for example, in order to adjust the move gizmo hotkeys, you could do something like this:

    moveGizmo.Hotkeys.Enable2DMode.LShift = false;
    moveGizmo.Hotkeys.Enable2DMode.LCtrl = true;

    You can have a look at the Hotkeys class in the Hotkyes.cs file in the Input folder and you can get an idea of the properties which you can use the modify hotkeys. It's pretty intuitive.

    But let me know if you need more help.

    Cheers,
    Andrew
     
  37. gamergetik

    gamergetik

    Joined:
    Dec 16, 2020
    Posts:
    4
    Thanks for the update. However i have modified the scripts and wrote additional scripts for my specific purpose. :)

    Thanks Andrew for making this awesome plugin. I will let you know if i come into other bugs/problems.
     
    XGT08 likes this.
  38. kristoof

    kristoof

    Joined:
    Aug 26, 2013
    Posts:
    89
    Thanks for the info!
    I don't really use vertex snapping, the only thing I need is a simple translate and rotate gizmo.
    Commenting out the suggested code removed the huge performance hit :D

    Thanks for the help!
     
  39. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
    I can confirm that the performance is very bad. It remained bad until I disabled the RTGAPP script

    AMD Radeon RX 5700 XT
    AMD Ryzen Threadripper 2970WX 24 core
    64 GB RAM

    upload_2020-12-26_10-1-49.png

    upload_2020-12-26_10-3-45.png
     
  40. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
    The code should be refactored so as to separate the concerns of rendering the gizmos, selecting objects in the scene, input, and functionality. Outside of a demo pretty much nobody wants users to just move any object in the scene. Games will have their own code that determines when objects can be moved or not, which objects to show gizmos for. Games will probably have their own code to read and handle input with keymapping and so forth.

    *Edit*

    Interfaces:

    To expand on this, you want each system in RTG to be modular and make no assumptions in order to work with non-trivial use cases.

    Input should make no assumptions about the controller type. I should be able to use a Joystick, mouse, gamepad, foot pedals, voice commands, or mind meld with my computer. It doesn't matter, the interface should only get the numbers for the amount to rotate, translate. If a button or objects needs to be pressed, that should be an interface that has OnPress, DragStart, HoverStart, etc.

    For vertex snapping, I should be supplying the points to snap to. I only may want to snap to certain points on an object, and only certain objects in the scene.

    Displaying Gizmos should likewise use an interface - what to display, where to display it, and so on. Don't make any assumptions about the scene or controls.

    This can all be tied together in the demo, but still be independently modular.

    Performance:

    You should never use FindObjectsOfType, which is used in MonoSingleton.cs. It is called from RTCameraBackground.Get every frame in OnRenderObject if the user doesn't need a background.
     
    Last edited: Dec 26, 2020
    kristoof likes this.
  41. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,905
    The performance issues have absolutely nothing to do with separation of concerns. The plugin already allows you to attach the gizmos to objects, show/hide them as you wish etc. I think it's already pretty flexible.

    The problem is that, under the hood, the plugin needs to know about all objects in the scene and when any of their transforms have changed. This allows the vertex snapping of the move gizmo to work without having to attach colliders to game objects. Since Unity, doesn't inform me when a new object is created, I have to acquire this information using whatever functionality I have at my disposal.

    I could let the client just call functions such as OnObjectCreated whenever they create a game object in their scene, however, I still need to know when the transforms change.
     
  42. voonfoo98

    voonfoo98

    Joined:
    Nov 11, 2017
    Posts:
    4
    Hi, the scene gizmo axis is not pointing at the center of the square anymore after rotating it about the y-axis by 45 degree. Is there a fix to this issue?

    upload_2020-12-28_15-58-15.png

    This is the code used to rotate the scene gizmo.
    Code (CSharp):
    1. Gizmo gizmo = RTGizmosEngine.Get.GetSceneGizmoByCamera(RTFocusCamera.Get.TargetCamera).OwnerGizmo;
    2. gizmo.Transform.Rotation3D = Quaternion.Euler(new Vector3(0, 45f, 0));
     
    Last edited: Dec 28, 2020
  43. XGT08

    XGT08

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

    There is no issue here. The scene gizmo is never meant to be rotated. It has its own internal logic for rendering itself. It is meant to provide a snapshot of the relationship between the world axes and the scene camera.
     
  44. voonfoo98

    voonfoo98

    Joined:
    Nov 11, 2017
    Posts:
    4
    Oh I see. I have some use case for the project that I am working on right now that needed the scene gizmo to rotate. May I know how should I go about making this work?
     
  45. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
    If rendering, input, and interacting with the world were separate concerns, by which I mean split into 3 modules, then performance would not be an issue if I only using the rendering module.

    I using your asset for rendering.

    I have my own code for interacting with the world.

    I am using Rewired for input, which supports remapped controls and gamepad input. When rewired notifies me of an input that is used by my code as well as yours it only works because I set the default controls to happen to match what your input code expects. It also means I can't support gamepads. Your input code should be a separate module that works with the rest of the system through interfaces, so I and others can use alternate input devices such as gamepads and/or rewired.

    Vertex snapping should be a separate concern/module so users who want it can provide their own inputs, in such a way that it runs with reasonable performance. Your current approach is too slow and won't work for anyone, plus not everyone necessarily wants to use it.
     
  46. XGT08

    XGT08

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

    You keep mentioning Input, when in fact this issue has nothing to do with inputs. This may be another issue separate from this one if you insist on it being an issue. The main idea is that in order to support vertex snapping the implementation which is slowing things down has to be there in one way or another. The way concerns are separated is completely irrelevant. Looping through all those objects still has to be done and this will be slow no matter where it's done.

    That being said, there may be ways around it, such as falling back to using Unity colliders for raycasts which would enable vertex snapping for objects that have colliders attached to them. But even then, I still need a way to keep track of all objects visible on the screen which I am not sure how to do efficiently at the moment.

    Is vertex snapping mandatory? No. But since the gizmos are supposed to get as near as possible to the Unity gizmos, I figured it would be nice to make it available. There may be an option to turn it on/off in the future instead of commenting code in the RTScene class.

    Also, I am not ware of the multitude of all input devices out there, but in all honestly, I regard the mouse and keyboard as the best choice when working with gizmos. I am saying this because you mentioned gamepads. I have never tried using a gamepad for this sort of thing and probably never will for the simple reason that I don't think it would be an intuitive input interface in this particular situation. It may come down to what we are used to in the end, but for me personally, it would be a no-no. I think in general, applications that use such entities as gizmos for manipulating object transforms, will use a mouse-keyboard combo for input.

    Again, making it a separate concern will not solve anything other than the fact that it would be plugged when needed and unplugged when not needed. Which I can still do with a setting inside the inspector without having to split anything apart. But it still would not solve the issue that when it is needed, it will slow things down no matter how much amount of separation/split/divides etc you apply to it.

    Your concern stems from the fact that you don't need it and it was slowing things down. Good, understood. For the moment, you can turn it off by commenting the code in the RTScene class.

    My concern is that when it is needed, it will be slow no matter what. All the SOLID principles in the world will not make it fast. If anything, probably slower. So as long as Unity doesn't provide a mechanism for me to know:
    1. when a game object is created/destroyed in the scene;
    2. when a game object transform's has changed;
    This performance issue will still be there.

    Cheers,
    Andrew
     
  47. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
    Bugfix:

    Code (CSharp):
    1.  
    2. public void RemoveGizmo(Gizmo gizmo)
    3. {
    4.             // KevinJ: If code removes a gizmo while it is being dragged, _draggedGizmo is never cleared and gizmos cannot be interacted with again until the scene is reset
    5.             gizmo.EndDragSession();
    6.             UnregisterGizmo(gizmo);
    7. }
     
  48. Dino_Labs

    Dino_Labs

    Joined:
    May 31, 2017
    Posts:
    1
    Hi, I tried this for my own work, and it works quite well!
    I wonder, are there any plans for the VR support?
    Or, where should I look for enabling this?

    Thanks :)
     
  49. XGT08

    XGT08

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

    There is currently no plan to support VR I'm afraid.

    There is something which you could try, but I am not sure how well it would work since I do not have any experience with VR.

    There is an abstract class called InputDeviceBase defined in InputDeviceBase.cs:
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3.  
    4. namespace RTG
    5. {
    6.     public abstract class InputDeviceBase : IInputDevice
    7.     {
    8.         public event InputDeviceDoubleTapHandler DoubleTap;
    9.  
    10.         private float _doubleTapDelay = 0.5f;
    11.         private float _lastTapTime = 0.0f;
    12.  
    13.         private bool _didDoubleTap;
    14.         private int _maxNumDeltaCaptures;
    15.         private InputDeviceDeltaCapture[] _deltaCaptures;
    16.  
    17.         public bool DidDoubleTap { get { return _didDoubleTap; } }
    18.         public float DoubleTapDelay { get { return _doubleTapDelay; } set { _doubleTapDelay = Mathf.Max(value, 0.0f); } }
    19.         public abstract InputDeviceType DeviceType { get; }
    20.  
    21.         public InputDeviceBase()
    22.         {
    23.             SetMaxNumDeltaCaptures(50);
    24.         }
    25.  
    26.         public void SetMaxNumDeltaCaptures(int maxNumDeltaCaptures)
    27.         {
    28.             _maxNumDeltaCaptures = Mathf.Max(1, maxNumDeltaCaptures);
    29.             _deltaCaptures = new InputDeviceDeltaCapture[_maxNumDeltaCaptures];
    30.         }
    31.  
    32.         public bool CreateDeltaCapture(Vector3 deltaOrigin, out int deltaCaptureId)
    33.         {
    34.             deltaCaptureId = 0;
    35.             while (deltaCaptureId < _maxNumDeltaCaptures && _deltaCaptures[deltaCaptureId] != null) ++deltaCaptureId;
    36.             if (deltaCaptureId == _maxNumDeltaCaptures)
    37.             {
    38.                 deltaCaptureId = -1;
    39.                 return false;
    40.             }
    41.  
    42.             var deltaCapture = new InputDeviceDeltaCapture(deltaCaptureId, deltaOrigin);
    43.             _deltaCaptures[deltaCaptureId] = deltaCapture;
    44.  
    45.             return true;
    46.         }
    47.  
    48.         public void RemoveDeltaCapture(int deltaCaptureId)
    49.         {
    50.             if (deltaCaptureId >= 0 && deltaCaptureId < _maxNumDeltaCaptures) _deltaCaptures[deltaCaptureId] = null;
    51.         }
    52.  
    53.         public Vector3 GetCaptureDelta(int deltaCaptureId)
    54.         {
    55.      
    56.             if (deltaCaptureId >= 0 &&
    57.                 deltaCaptureId < _maxNumDeltaCaptures && _deltaCaptures[deltaCaptureId] != null) return _deltaCaptures[deltaCaptureId].Delta;
    58.             return Vector3.zero;
    59.         }
    60.  
    61.         public abstract Vector3 GetFrameDelta();
    62.         public abstract Ray GetRay(Camera camera);
    63.         public abstract Vector3 GetPositionYAxisUp();
    64.         public abstract bool HasPointer();
    65.         public abstract bool IsButtonPressed(int buttonIndex);
    66.         public abstract bool WasButtonPressedInCurrentFrame(int buttonIndex);
    67.         public abstract bool WasButtonReleasedInCurrentFrame(int buttonIndex);
    68.         public abstract bool WasMoved();
    69.  
    70.         public void Update()
    71.         {
    72.             UpateFrameDeltas();
    73.             UpdateDeltaCaptures();
    74.             DetectAndHandleDoubleTap();
    75.         }
    76.  
    77.         protected abstract void UpateFrameDeltas();
    78.  
    79.         private void UpdateDeltaCaptures()
    80.         {
    81.             int deltaCaptureId = 0;
    82.             Vector3 devicePosition = GetPositionYAxisUp();
    83.             while (deltaCaptureId < _maxNumDeltaCaptures && _deltaCaptures[deltaCaptureId] != null)
    84.             {
    85.                 _deltaCaptures[deltaCaptureId++].Update(devicePosition);
    86.             }
    87.         }
    88.  
    89.         private void DetectAndHandleDoubleTap()
    90.         {
    91.             if (WasButtonPressedInCurrentFrame(0))
    92.             {
    93.                 if ((Time.time - _lastTapTime) < _doubleTapDelay)
    94.                 {
    95.                     _lastTapTime = 0.0f;
    96.                     _didDoubleTap = true;
    97.                     if (DoubleTap != null) DoubleTap(this, GetPositionYAxisUp());
    98.                 }
    99.                 else
    100.                 {
    101.                     _didDoubleTap = false;
    102.                     _lastTapTime = Time.time;
    103.                 }
    104.             }
    105.         }
    106.     }
    107. }
    108.  
    This abstract class is currently implemented for mouse and touch devices only. You can check out the implementation in the MouseInputDevice.cs and TouchInputDevice.cs.

    So you could derive InputDeviceBase and create a device for VR.

    After that you need to open RTInputDevice.cs:
    Code (CSharp):
    1.  
    2. //#define INPUT_DEVICE_VR_CONTROLLER
    3. using UnityEngine;
    4.  
    5. namespace RTG
    6. {
    7.     public class RTInputDevice : MonoSingleton<RTInputDevice>
    8.     {
    9.         private IInputDevice _inputDevice;
    10.  
    11.         public IInputDevice Device { get { return _inputDevice; } }
    12.         public InputDeviceType DeviceType { get { return _inputDevice.DeviceType; } }
    13.  
    14.         public void Update_SystemCall()
    15.         {
    16.             _inputDevice.Update();
    17.         }
    18.  
    19.         private void Awake()
    20.         {
    21.             #if !UNITY_EDITOR && (UNITY_IOS || UNITY_ANDROID || UNITY_WP_8_1)
    22.             _inputDevice = new TouchInputDevice(10);
    23.             #elif INPUT_DEVICE_VR_CONTROLLER
    24.             //_inputDevice = new MyVRCtrlImplementation(...);
    25.             #else
    26.             _inputDevice = new MouseInputDevice();
    27.             #endif
    28.         }
    29.     }
    30. }
    31.  
    and uncomment the top line #define INPUT_DEVICE_VR_CONTROLLER. Then inside the Awake function, you will need to instantiate your VRDevice implementation (the one that derives from InputDeviceBase).

    I hope this helps, but let me know if you have any further questions.

    Cheers,
    Andrew
     
  50. drew55

    drew55

    Joined:
    Dec 13, 2017
    Posts:
    44
    I bought this and had a question... in CameraEx.cs, where does the constant viewHeightScalePersp come from? Is it just a "fitter" constant to make things consistent? Are there any other factors?

    `const float viewHeightScalePersp = 0.046f;`