For some reason I’m unable to see my class in the inspector. Not sure why.
using UnityEngine;
using System.Collections;
public class tes : MonoBehaviour {
// Trying inside the main class
[System.Serializable]
class Test
{
public int p = 5;
public Color c = Color.white;
}
}
// Trying outside the main class
[System.Serializable]
class Test
{
public int p = 5;
public Color c = Color.white;
}
Here’s a modified script, which is still not working.
using UnityEngine;
using System.Collections;
public class tes : MonoBehaviour {
[System.Serializable]
class Test
{
public int p = 5;
public Color c = Color.white;
}
}
[System.Serializable]
public class Test : MonoBehaviour
{
public int p = 5;
public Color c = Color.white;
}
Each file can only show a single MonoBehaviour in the inspector. What I think you’re meaning to do is create an instance of your Test class inside of your tes class.
I’m aware of only one monobehaviour allowed, was just showing angrypenguin that it would produce the same results.
Yes I’m trying to create an instance of Test class inside of the tes class. I’ve done this many times before of course, but I’ve blanked out. I’m half asleep trying to make this thing in the middle of the night
public class tes : MonoBehaviour {
public Test test; // <----- this line here
// Trying inside the main class
[System.Serializable]
class Test
{
public int p = 5;
public Color c = Color.white;
}
}
// Trying outside the main class
[System.Serializable]
class Test
{
public int p = 5;
public Color c = Color.white;
}