Hi,
I'm trying to create an Editor script that uses a reference to a Material in the Inspector.
In the following code, the variable 'myMat' appears in the Inspector, but I get an error "An object reference is required to access non-static member `TestScript.myMat'" at the end where I am trying to access the variable. If I make myMat static, I no longer get the error, but myMat is not shown in the Inspector.
using UnityEngine;
using UnityEditor;
using System.Collections;
[System.Serializable]
public class TestScript : ScriptableObject
{
public Material myMat;
class OtherClass
{
public OtherClass (Material mat)
{
Material classMat = mat;
}
public MakeStuff(/*Big function that makes stuff with myMat*/);
}
[MenuItem ("GameObject/TestScript")]
static void MenuTestScript()
{
OtherClass newClass = new OtherClass(myMat);
newClass.MakeStuff();
}
}
Is there a way to satisfy both? Thanks.