Purpose is to simplify on screen direction indicator common in 3D games where an arrow head is pointing toward a game object, or a waypoint or an enemy or an objective.
Setting up this system is pretty straight forward.
-
There are a total of two script
OnScreenPointerControllerandOnScreenPointerObject. -
OnScreenPointerControlleris a singleton. This script mainly contains enviroment info needed for this plugin. -
OnScreenPointerControllerneeds two references. Camera related to player and uiRectTransform. -
RectTransformwill contain all the pointers. Purpose is to have one place for managing all pointers. -
OnScreenPointerControllerhas Camera reference. If it is null, plugin will try to findMain Cameraand use it. -
OnScreenPointerObjectis attached is to target game object whose position we intend to track in realtime during our gameplay session.-
offset_localis normalized screen size inxandydirection. During final result calculation,offset_local.xis multiplied withscreenWidthand result is the padding from screen edges. (same process repeats foryandscreenHeight). -
MoveInCicleis use to place pointer at a fix distance from screen center. Smaller dimension is choosen from screen size and pointer is placed along that angle. Distance from center is controlled bycircleSizeNormalized. Example: pointer is placed at a mid-way from screen center to screen edge whencircleSizeNormalizedis0.5 -
inScreenSprite: Pointer Image when object is with in screen area whether visible or not. -
outScreenSprite: Pointer Image when object is not in screen. Object may be infront of player but not in periphery of camera view. Object may be in back of player/camera. -
uiImagePrefab: Prefab configured forinScreenSprite/outScreenSprite. Can be a complex assembly of views chained togather. However, current implementation has the assumption that parent Prefab will have aImagecomponent.
-