Hideflags is an enumeration class that controls the method of destroying object objects to their visibility in the monitoring panel
Dontsave preserving objects to a new scene
If Gameobject Objects are hideflags.dontsave identified, all components gameobject in the new scene will be preserved, but their subclasses Gameobject objects will not be persisted to the new scene
You cannot hideflags.dontsave identify a component of a Gameobject object, such as transform, or an object that is identified by Hideflags.dontsave will persist in the program even if the program has exited. Cause a memory leak, you should manually destroy the
using unityengine;using system.collections;public using Destroyimmediate Class Dontsave_ts:monobehaviour {public gameobject go; Public Transform t; The void Start () {//gameobject object uses Hideflags.dontsave to be preserved in the new scene go.hideflags = Hideflags.dontsave; Gameobject Pl = gameobject.createprimitive (Primitivetype.plane); Pl.hideflags = Hideflags.dontsave; The Gameobject component cannot be set Hideflags.dontsave Transform tf = Instantiate (T, go.transform.position + new Vector3 (2.0f, 0.0f , 0.0f), quaternion.identity) as Transform; Tf.hideflags = Hideflags.dontsave; Import new Scene Application.loadlevel ("newscene2_unity"); }}
Using unityengine;using system.collections;public class newscene2_ts:monobehaviour{ gameobject cube, plane; void Start () { Debug.Log ("newscene2! "); } Destroy the object identified by hideflags.dontsave± with Destroyimmediate () when the program exits void Onapplicationquit () { cube = Gameobject.find ("CUBE0"); Plane = Gameobject.find ("plane"); if (cube) { Debug.Log ("Cube0 destroyimmediate"); Destroyimmediate (cube); } if (plane) { Debug.Log ("Plane destroyimmediate"); Destroyimmediate (plane);}}}
Hideanddontsave preserving objects to a new scene
But it won't appear in the hierarchy panel.
hideinhierarchy--hidden in the hierarchy panel
To hide objects that are not created in the script in the hierarchy panel, you need to use Hideflags.hideinhierarchy in the awake method to take effect
If you hide the parent object, the child object will be hidden. Otherwise
using unityengine;using System.collections;public class Hideinhierarchy_ts: monobehaviour{public gameobject go, sub; Public Transform t; void Awake () {//go,sub,gameobject is an existing object and needs to be used in the Awake method hideflags.hideinhierarchy go.hideflags = Hideflags . Hideinhierarchy; Sub.hideflags = Hideflags.hideinhierarchy; Gameobject.hideflags = Hideflags.hideinhierarchy; } void Start () {//PL,TF is an object created in code and can be used in any method hideflags.hideinhierarchy gameobject Pl = Gameobject.cre Ateprimitive (Primitivetype.plane); Pl.hideflags = Hideflags.hideinhierarchy; Transform tf = Instantiate (T, go.transform.position + new Vector3 (2, 0.0f, 0.0f), quaternion.identity) as Transform; Tf.hideflags = Hideflags.hideinhierarchy; }}
hideininspector--hidden in the Inspector panel
If a gameobject uses Hideflags.hideininspector, all its components will be hidden in the Inspector panel, but the components of its child objects can still be displayed in the Inspector panel
If you hide only one component of the Gameobject object, such as transform, it does not affect the display state of other components of gameobject, such as Renderer,rigidbody, in the Inspector panel
noteditable--the editable object in the Inspector panel
Using unityengine;using System.collections;public class Noteditable_ts:monobehaviour {public gameobject go; Public Transform t; void Start () { //gameobject object uses hideflags.noteditable to make all components of gameobject non-editable // Gameobject objects using hideflags.noteditable do not affect the editable nature of subclass objects go.hideflags = hideflags.noteditable; Gameobject Pl = gameobject.createprimitive (Primitivetype.plane); Pl.hideflags = hideflags.noteditable; Using hideflags.noteditable alone for a component of Gameobject makes this component non-editable and does not affect other components t.hideflags = hideflags.noteditable; Transform tf = Instantiate (T, go.transform.position + new Vector3 (2.0f, 0.0f, 0.0f), quaternion.identity) as Transform;
tf.hideflags = hideflags.noteditable; }}
Unity API Parsing (4)--hideflags class