Minimap

Open World - Scripts - Minimap

How to make a circular minimap in Unity3D

To make a circluar minimap first create a UI Image object and on the inspector add a mask component and a circle texture as the sourse image. Now create a UI Raw Image and make it a child of the Image. With the first two steps done in the project area create a new RenderTexture. Now in the scene make a new Camera and with the camera selected on the inspector drag the RenderTexture you just created and place it in the Target Texture slot and the final step select the Raw image and drag the RenderTexture into the Texture slot as soon as you do this the Raw Image should update to show the camera with the RenderTexture view.

[ln(56)]

Minimap.cs 479B


using System.Collections;
using UnityEngine;
using DG.Tweening;

public class Minimap : MonoBehaviour
{
    [SerializeField] Camera MapCam;
    private void Start() => ZoomOut();

    void ZoomIn() => MapCam.DOOrthoSize(350, 3);
    void ZoomOut() => MapCam.DOOrthoSize(750, 3).OnComplete(() => Wait());
    void Wait() => StartCoroutine(Countdown());

    IEnumerator Countdown()
    {
        yield return new WaitForSeconds(4);
        ZoomIn();
    }
}
Powered by w3.css