I’d like to confirm this is a bug, and not something I am doing wrong.
Given the monobehavior below:
If I click in its inspector - createItHidden , then click createItNow, then disable, and renable this monobehavor object:
The created object is visible, not only in the scene, but ALSO in the project’s icons, an inspectors preview’s (materials, models)
[ExecuteInEditMode]
public class HiddenObjectCreator : MonoBehaviour {
public GameObject hiddenObject;
public bool createItNow = false;
public bool createItHidden = false;
private void OnEnable()
{
if(hiddenObject)
hiddenObject.SetActive(true);
}
private void OnDisable()
{
if (hiddenObject)
hiddenObject.SetActive(false);
}
// Update is called once per frame
void Update ()
{
if (createItNow)
{
createItNow = false;
hiddenObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
hiddenObject.transform.localScale = new Vector3(.1f, 2, .1f);
if (createItHidden)
hiddenObject.hideFlags = HideFlags.HideAndDontSave;
}
}
}