I am having trouble understanding how to access fields of a singleton class instance. I have read on it a bit, and am modeling my implementation after number four here. This is what I have in my singleton class:
using UnityEngine;
using System.Collections;
public sealed class Materials
{
private static readonly Materials materials = new Materials();
private static string wooly {get; set;}
/*static Materials()
{
wooly = "static";
}*/
private Materials()
{
wooly = "private";
}
public static Materials Instance
{
get
{
return materials;
}
}
}
In another code I am using simply:
public string p;
public Materials m;
void Start()
{
m = Materials.Instance;
p = m...; //Ellipses not part of actual code - this is just where the issue comes up
}
The problem is when I type "p = Materials.Instance. " or "p = m. " intellisense does not allow me to get the “wooly” property in the Materials class. If I enter it anyway, I get an error.
This is made all the more frustrating by various posts on StackExchange stating this very approach - that is not working for me - as the solution to someone else’s issue. So can someone please point out what is wrong with this, or how to access information from a singleton?
P.S. I am still new to this, this is in part a proof of concept for myself that took the better part of the evening, and is inconclusive.