jinincarnate / off-screen-indicator

A simple solution for implementing target indicator, waypoint or HUD navigation system in unity.
GNU General Public License v3.0
84 stars 16 forks source link

no redraw of canvas after rotating mobile device. #6

Open coudys opened 1 year ago

coudys commented 1 year ago

I have few canvases in my project and when changing between portrait and landscape on my android device, all UI canvases adjust to it apart from this UI off screen indicator canvas. Seems the rectangle of canvas remains either portrait in landscape or vice versa. Indicator arrows are there, just not reaching new canvas limits.

mohit-mittal-cosm commented 1 year ago

the code uses screen space overlay canvas, which means it takes in account the screen height and width and caches it. so you will need to update the screen width and height when ever you rotate your device

IAFahim commented 5 months ago

@coudys You could just add this line to OffScreenIndicator

public class OffScreenIndicator : MonoBehaviour
{
// rest of the code

    void Awake()
    {
        mainCamera = Camera.main;
        TargetStateChanged += HandleTargetStateChanged;
    }

    private void Update()
    {
        screenCentre = new Vector3(Screen.width, Screen.height, 0) / 2;
        screenBounds = screenCentre * screenBoundOffset;
    }

// rest of the code
}

I have never in my life seen more clean code for any unity project than this repo. This man is a clean code genius. And expert programmer. I wanted to apply to your company just so that I could meet this person. I pray, where every you might be, I hope you have a really satisfying life.