private static void InitializeGameObject(GameObject go, TSVector position, TSQuaternion rotation)
        {
            ICollider[] tsColliders = go.GetComponentsInChildren<ICollider>();
            if (tsColliders != null) {
                for (int index = 0, length = tsColliders.Length; index < length; index++) {
                    PhysicsManager.instance.AddBody(tsColliders[index]);
                }
            }

            TSTransform rootTSTransform = go.GetComponent<TSTransform>();
            if (rootTSTransform != null) {
                rootTSTransform.Initialize();

                rootTSTransform.position = position;
                rootTSTransform.rotation = rotation;
            }

            TSTransform[] tsTransforms = go.GetComponentsInChildren<TSTransform>();
            if (tsTransforms != null) {
                for (int index = 0, length = tsTransforms.Length; index < length; index++) {
                    TSTransform tsTransform = tsTransforms[index];

                    if (tsTransform != rootTSTransform) {
                        tsTransform.Initialize();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void InitializeGameObject(GameObject go, TSVector position, TSQuaternion rotation)
        {
            ICollider[] tsColliders = go.GetComponentsInChildren <ICollider>();
            if (tsColliders != null)
            {
                foreach (ICollider tsCollider in tsColliders)
                {
                    PhysicsManager.instance.AddBody(tsCollider);
                }
            }

            TSTransform rootTSTransform = go.GetComponent <TSTransform>();

            if (rootTSTransform != null)
            {
                rootTSTransform.Initialize();

                rootTSTransform.position = position;
                rootTSTransform.rotation = rotation;
            }

            TSTransform[] tsTransforms = go.GetComponentsInChildren <TSTransform>();
            if (tsTransforms != null)
            {
                foreach (TSTransform tsTransform in tsTransforms)
                {
                    if (tsTransform != rootTSTransform)
                    {
                        tsTransform.Initialize();
                    }
                }
            }

            TSTransform2D rootTSTransform2D = go.GetComponent <TSTransform2D>();

            if (rootTSTransform2D != null)
            {
                rootTSTransform2D.Initialize();

                rootTSTransform2D.position = new TSVector2(position.x, position.y);
                rootTSTransform2D.rotation = rotation.ToQuaternion().eulerAngles.z;
            }

            TSTransform2D[] tsTransforms2D = go.GetComponentsInChildren <TSTransform2D>();
            if (tsTransforms2D != null)
            {
                foreach (TSTransform2D tsTransform2D in tsTransforms2D)
                {
                    if (tsTransform2D != rootTSTransform2D)
                    {
                        tsTransform2D.Initialize();
                    }
                }
            }
        }