/// <summary> /// Register this widget with the manager. /// </summary> void Start() { if (mScreen == null && material != null) { mColor = color; mTrans = transform; mPos = mTrans.position; mRot = mTrans.rotation; mScale = mTrans.lossyScale; mDepth = depth; mScreen = SGScreen.GetScreen(mMat = material, mLayer = gameObject.layer, mGroup = group, true); OnStart(); mScreen.AddWidget(this); } }
/// <summary> /// Check to see if anything has changed, and if it has, mark the screen as having changed. /// </summary> public bool ScreenUpdate() { // Call the virtual function bool retVal = OnUpdate(); // If the material or layer has changed, act accordingly if (mMat != material || mGroup != group || mLayer != gameObject.layer || mColor != color) { if (mMat != null) { mScreen.RemoveWidget(this); } mMat = material; mColor = color; mPos = mTrans.position; mRot = mTrans.rotation; mScale = mTrans.lossyScale; mLayer = gameObject.layer; mDepth = depth; mGroup = group; retVal = true; if (mMat != null) { mScreen = SGScreen.GetScreen(mMat, mLayer, mGroup, true); mScreen.AddWidget(this); } } // Check to see if the position, rotation or scale has changed else if (mMat != null) { Vector3 pos = mTrans.position; Quaternion rot = mTrans.rotation; Vector3 scale = mTrans.lossyScale; if (mDepth != depth || mPos != pos || mRot != rot || mScale != scale) { mPos = pos; mRot = rot; mScale = scale; mDepth = depth; retVal = true; } } return(retVal); }