Asset Store Description
Requires Unity 5.3.2 or higher.
Off Screen Indicator is a plugin for Unity and easily configurable system to handle UI indicators on-screen and off-screen, it allows to use any sprite, and also rotates the sprite if we are using any arrow image. It can display UI in a Canvas or in 3D World Space for VR (Tested in Oculus Rift).
Coded in C#, object oriented driven, allows code extension to handle other interface different than UI Canvas or world space for VR.We plan to add new features if they are useful for common use, and some customers ask for them. And we are open to help you if you need to understand the code.
DemoScript.cs – Example code for demos, show how easily you can add a offscreen arrow in realtime via code.
FPSCanvasTest.unity – Demo Scene, where you can see how it works OffScreenIndicator with a FirstPersonCharacter Standard Asset, and displaying the arrows in Canvas.
FPSVRTest.unity – Demo Scene, using VR (Tested in Oculus Rift DK2) instead of Canvas.
ThirdPersonTopViewTest.unity – Demo Scene, using ThirdPersonCharacter with a cenital top view, and displaying the arrows in Canvas.
Scripts / FirstPersonVRCharacter
You can remove this folder if you are not using VR. In this folder you can find the FirstPersonCharacter Prefab modified to work with VR, and display arrows in world space in a given distance to the viewer (easily configurable). The MouseLook is modified to change only character rotation, and pov camera will be moved only with the VR device.
Scripts / Helpers
Convenience methods for debugging.
Example sprites used in the demo scenes.
Using the package from scratch
- Create empty 3D Project
- Import OffScreenIndicator package
- Add a plane for the ground
- Add a cube to use as target
- Create a Canvas adding for example a Text
- Create empty GameObject to add Logic
- Locate the script OffScreenIndicator/Scripts/OffScreenIndicator.css
- Add it as a script component to the empty GameObject
- Let’s add one Indicator
- Set color and sprites for the Indicator when the target is on screen and off screen, if you don’t set sprite it won’t be displayed
- Add the cube as a target, the IndicatorID is the desired element of the Indicators Array
- Set the Canvas object in the script component
- Press Play, and see how the Indicator in the canvas follows the target
- You can force the sprite to rotate pointing to the target
- Let’s add the FPSController from Standard Assets
- Disable the MainCamera and verify the FPSController Camera is tagged as MainCamera
- Move Character Controller and check how the Indicator works
- You can change the transition from the onscreen sprite to the offscreen sprite, as the duration
- You can change the indicator size and the padding to borders
Adding and removing Indicators in real time
- Let’s add a button to add a new target
- Create a new script to add the logic for the button
- This code is included in the DemoScenes folder
- This is the important stuff: the method AddIndicator(Transform target, int indicatorID) adds the indicator of the given transform using the Indicator id.
- Now link the button with the script
- Let know the script which object to instantiate
- Tune the OffScreenIndicator parameters to your needs
- You can create all the indicators you want with their given colors, sprites and transitions
- You can add an offset applied in the Canvas space (pixel units)
- Let’s use a random indicator in the AddTarget script
How to use VR (tested with Oculus)
- Locate the prefab OffScreenIndicator/Scripts/FirstPersonVRCharacter/Prefabs/FPSVRController.prefab
- Remove the old FPSController. Place FPSVRController on the scene
- Go to File > Build Settings > Player Settings > Other Settings and check the Virtual Reality Supported checkbox
- The component OffScreenIndicator must have checked the Virtual Reality Supported checkbox
- In the scene window you can see the debug information of the OffScreenIndicator, the green plane is where arrows are drawn
- Configure VR parameters to prevent the clipping, remember that the UI in VR has to be in the world space
When I deploy the apk to an android device, the indicators do not show.
The size of the Canvas must be Constant Pixel-Size, or the resolution of the screen must have the same size of the Reference Resolution, otherwise, the canvas will resize to match the final screen size. This should be probably the problem, there are some users who already have deployed to Android without any problem. Please, let us know if this is not your problem.
Regarding this stuff, the size of the arrows may vary from one mobile device to another (due to DPI), in most devices is not noticeable, but we plan to address this issue in a next version of OffScreenIndicator.
How can I notice if I’m adding indicators correctly?
You may notice this because you will have child objects attached to Canvas with the name “Indicator”.
Indicators are added correctly, but I can’t see them in scene
Locate the Indicators Gameobjects in the Hierarchy window and double click on them. You should see them in the scene view, confirm that they are inside of the canvas.
If the object is selected, but you yest can not see it, please verify that the color of the image is not transparent.
I can see the indicators, but they go out of screen, and they are not over the desired Gameobject.
The size of the Canvas must be Constant Pixel-Size, or the resolution of the screen must have the same size of the Reference Resolution, otherwise, the canvas will resize to match the final screen size.
If you want to Scale your own UI Canvas elements to all screen sizes and aspect ratios, then you should use Two different Canvas, one of them with your UI which will scale, and the other one with constant Pixel size.
In this section we will add some possible features to be added to Off Screen Indicator, some of them may not be so necessary, any way they appear here, if we see users interested in those features they will be added.
Screen Proportional indicators size
Actually the size of the indicators are pixel size based, which may lead to problems when focused to mobile devices, due to DPI differences between models.
This feature let OffScreenIndicator display indicators in a a size proportional to screen.
Object Bounds Size
When targets are on screen the indicator resizes to object bounds.
Indicators display distance to camera / player
The Indicators show a text indicating the distance to the targeted object.
Indicators display a label
The indicators show a text indicating a label related to the object.
Please fill in this form to ask for any feature that you would need for this package