- Home /
Enabling a hidden GameObject with a MeshRenderer - makes it visible in previews.
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;
}
}
}
hidenobjectinpreviews.png
(21.6 kB)
Comment
Pretty confident this is a bug so I submitted it: https://fogbugz.unity3d.com/default.asp?963576_vqhe22588ak8k2f0
Best Answer
Answer by Glurth · Nov 03, 2017 at 05:54 PM
Got an email back from Unity; it is indeed a bug: https://fogbugz.unity3d.com/default.asp?963576_vqhe22588ak8k2f0