publicclassOfflineData : MonoBehaviour { public Rigidbody m_RigidBody; public Collider m_Collider; public Transform[] m_AllPoint; publicint[] m_AllPointChildCount; publicbool[] m_AllPointActive; public Vector3[] m_Pos, m_Scale; public Quaternion[] m_Rot;
///<summary> /// 还原属性 ///</summary> publicvirtualvoidResetProp() { int allPointCount = m_AllPoint.Length; for (int i = 0; i < allPointCount; i++) { Transform tempTrans = m_AllPoint[i]; if (tempTrans != null) { tempTrans.localPosition = m_Pos[i]; tempTrans.localRotation = m_Rot[i]; tempTrans.localScale = m_Scale[i];
if (m_AllPointActive[i]) { if (!tempTrans.gameObject.activeSelf) { tempTrans.gameObject.SetActive(true); } } else { if (tempTrans.gameObject.activeSelf) { tempTrans.gameObject.SetActive(false); } }
if (tempTrans.childCount > m_AllPointChildCount[i]) { int childCount = tempTrans.childCount; for (int j = m_AllPointChildCount[i]; j < childCount; j++) { GameObject tempObj = tempTrans.GetChild(j).gameObject; if (!ObjectPoolManager.Instance.IsPoolManagerCreat(tempObj)) { GameObject.Destroy(tempObj); } } } } } } ///<summary> /// 初始属性,在编辑器环境下赋值好 ///</summary> publicvirtualvoidBindData() { m_Collider = gameObject.GetComponentInChildren<Collider>(true); m_RigidBody = gameObject.GetComponentInChildren<Rigidbody>(true); m_AllPoint = gameObject.GetComponentsInChildren<Transform>(true); int allPointCount = m_AllPoint.Length; m_AllPointChildCount = newint[allPointCount]; m_AllPointActive = newbool[allPointCount]; m_Pos = new Vector3[allPointCount]; m_Rot = new Quaternion[allPointCount]; m_Scale = new Vector3[allPointCount]; for (int i = 0; i < allPointCount; i++) { Transform temp = m_AllPoint[i] as Transform; m_AllPointChildCount[i] = temp.childCount; m_AllPointActive[i] = temp.gameObject.activeSelf; m_Pos[i] = temp.localPosition; m_Rot[i] = temp.localRotation; m_Scale[i] = temp.localScale; } } }