// ------------------------------------------------------------------ // recursively update the transform depth in child layers // ------------------------------------------------------------------ public void RecursivelyUpdateTransformDepth() { UpdateTransformDepth(); foreach (Transform child in transform) { exLayer2D layer = child.GetComponent <exLayer2D>(); if (layer) { layer.RecursivelyUpdateTransformDepth(); } } }
/////////////////////////////////////////////////////////////////////////////// // functions /////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ void Reset() { if ( GetComponent<exLayer2D>() == null ) { switch ( plane ) { case exPlane.Plane.XY: layer2d = gameObject.AddComponent<exLayerXY>(); break; case exPlane.Plane.XZ: layer2d = gameObject.AddComponent<exLayerXZ>(); break; case exPlane.Plane.ZY: layer2d = gameObject.AddComponent<exLayerZY>(); break; } layer2d.plane = this; layer2d.UpdateDepth(); } }
// ------------------------------------------------------------------ /// OnEnable functoin inherit from MonoBehaviour, /// When exPlane.enabled set to true, this function will be invoked, /// exPlane will enable the renderer and layer2d if they exist. /// /// \note if you inherit from exPlane, and implement your own Awake function, /// you need to override this and call base.OnEnable() in your OnEnable block. // ------------------------------------------------------------------ protected virtual void OnEnable() { if ( renderer != null ) renderer.enabled = true; // NOTE: though we have ExecuteInEditMode, user can Add/Remove layer2d in Editor if ( layer2d == null ) { layer2d = GetComponent<exLayer2D>(); } if ( layer2d ) { layer2d.enabled = true; } }
// ------------------------------------------------------------------ /// Awake functoin inherit from MonoBehaviour. /// /// \note if you inherit from exPlane, and implement your own Awake function, /// you need to override this and call base.Awake() in your Awake block. // ------------------------------------------------------------------ protected virtual void Awake() { if ( camera_ == null ) camera_ = Camera.main; meshFilter = GetComponent<MeshFilter>(); layer2d = GetComponent<exLayer2D>(); }