Fix my comment: Vector2 readonly/const alternative

Hi Guys,

I basically described my issue in the comment. Any ideas?

using UnityEngine;
using System.Collections;


public static class GridReference : object {

    // These want to be readonly or const. However readonly is instance only and can't have a Vector2 as a const
    private static Vector2 MAPGRIDS_LARGE_TOTAL = new Vector2(9, 6);
    private static Vector2 MAPGRIDS_LARGE_USEABLE = new Vector2(6, 4);
    private static Vector2 MAPGRIDS_SMALL_TOTAL = new Vector2(900, 600);
    private static Vector2 MAPGRIDS_SMALL_USEABLE = new Vector2(600, 400);

what is the problem with readonly?

    private static readonly Vector2 MAPGRIDS_LARGE_TOTAL = new Vector2(9, 6);
1 Like

Didn’t realised you could make a static readonly, awesome :slight_smile:

ah, I thought you knew about it… the Topic and the comment in your code confused me very much :smile:

1 Like