Example #1
0
    // Token: 0x06000042 RID: 66 RVA: 0x00003568 File Offset: 0x00001768
    public void Collapse()
    {
        base.transform.parent = null;
        while (this.head.childCount > 0)
        {
            this.head.GetChild(0).parent = base.transform;
        }
        global::UnityEngine.GUILayer component = this.head.GetComponent <global::UnityEngine.GUILayer>();
        bool flag = component != null;

        if (flag)
        {
            global::UnityEngine.Object.DestroyImmediate(component);
            base.gameObject.AddComponent <global::UnityEngine.GUILayer>();
        }
        bool flag2 = this.ears != null;

        if (flag2)
        {
            while (this.ears.childCount > 0)
            {
                this.ears.GetChild(0).parent = base.transform;
            }
            global::UnityEngine.Object.DestroyImmediate(this.ears.gameObject);
            this._ears = null;
            base.gameObject.AddComponent(typeof(global::UnityEngine.AudioListener));
        }
        bool flag3 = this.origin != null;

        if (flag3)
        {
            bool flag4 = this.origin.name.EndsWith(" (origin)");
            if (flag4)
            {
                global::UnityEngine.Transform origin = this.origin;
                while (origin.childCount > 0)
                {
                    origin.GetChild(0).parent = origin.parent;
                }
                global::UnityEngine.Object.DestroyImmediate(origin.gameObject);
            }
            else
            {
                base.transform.parent = this.origin;
            }
        }
        global::UnityEngine.Object.DestroyImmediate(this.head.gameObject);
        this._head = null;
        bool flag5 = base.name.EndsWith(" (eye)");

        if (flag5)
        {
            base.name = base.name.Substring(0, base.name.Length - " (eye)".Length);
        }
    }
        // Token: 0x06000601 RID: 1537 RVA: 0x0001D368 File Offset: 0x0001B568
        public static global::System.Collections.Generic.IEnumerable <global::UnityEngine.Transform> Children(this global::UnityEngine.Transform transform)
        {
            int num;

            for (int i = 0; i < transform.childCount; i = num + 1)
            {
                yield return(transform.GetChild(i));

                num = i;
            }
            yield break;
        }
Example #3
0
    // Token: 0x06000065 RID: 101 RVA: 0x0000472C File Offset: 0x0000292C
    public void AttachToCamera(global::SteamVR_Camera vrcam)
    {
        bool flag = this.target == vrcam.head;

        if (!flag)
        {
            this.target = vrcam.head;
            global::UnityEngine.Transform parent  = base.transform.parent;
            global::UnityEngine.Transform parent2 = vrcam.head.parent;
            parent.parent        = parent2;
            parent.localPosition = global::UnityEngine.Vector3.zero;
            parent.localRotation = global::UnityEngine.Quaternion.identity;
            parent.localScale    = global::UnityEngine.Vector3.one;
            vrcam.enabled        = false;
            global::UnityEngine.GameObject gameObject = global::UnityEngine.Object.Instantiate <global::UnityEngine.GameObject>(vrcam.gameObject);
            vrcam.enabled   = true;
            gameObject.name = "camera";
            global::UnityEngine.Object.DestroyImmediate(gameObject.GetComponent <global::SteamVR_Camera>());
            global::UnityEngine.Object.DestroyImmediate(gameObject.GetComponent <global::SteamVR_CameraFlip>());
            this.cam                     = gameObject.GetComponent <global::UnityEngine.Camera>();
            this.cam.fieldOfView         = this.config.fov;
            this.cam.useOcclusionCulling = false;
            this.cam.enabled             = false;
            this.colorMat                = new global::UnityEngine.Material(global::EscalationVR.UnityHelper.GetShader("Custom/SteamVR_ColorOut"));
            this.alphaMat                = new global::UnityEngine.Material(global::EscalationVR.UnityHelper.GetShader("Custom/SteamVR_AlphaOut"));
            this.clipMaterial            = new global::UnityEngine.Material(global::EscalationVR.UnityHelper.GetShader("Custom/SteamVR_ClearAll"));
            global::UnityEngine.Transform transform = gameObject.transform;
            transform.parent        = base.transform;
            transform.localPosition = new global::UnityEngine.Vector3(this.config.x, this.config.y, this.config.z);
            transform.localRotation = global::UnityEngine.Quaternion.Euler(this.config.rx, this.config.ry, this.config.rz);
            transform.localScale    = global::UnityEngine.Vector3.one;
            while (transform.childCount > 0)
            {
                global::UnityEngine.Object.DestroyImmediate(transform.GetChild(0).gameObject);
            }
            this.clipQuad      = global::UnityEngine.GameObject.CreatePrimitive(5);
            this.clipQuad.name = "ClipQuad";
            global::UnityEngine.Object.DestroyImmediate(this.clipQuad.GetComponent <global::UnityEngine.MeshCollider>());
            global::UnityEngine.MeshRenderer component = this.clipQuad.GetComponent <global::UnityEngine.MeshRenderer>();
            component.material             = this.clipMaterial;
            component.shadowCastingMode    = 0;
            component.receiveShadows       = false;
            component.useLightProbes       = false;
            component.reflectionProbeUsage = 0;
            global::UnityEngine.Transform transform2 = this.clipQuad.transform;
            transform2.parent        = transform;
            transform2.localScale    = new global::UnityEngine.Vector3(1000f, 1000f, 1f);
            transform2.localRotation = global::UnityEngine.Quaternion.identity;
            this.clipQuad.SetActive(false);
        }
    }
Example #4
0
 // Token: 0x060000CB RID: 203 RVA: 0x00009254 File Offset: 0x00007454
 public global::UnityEngine.Transform FindComponent(string componentName)
 {
     global::UnityEngine.Transform transform = base.transform;
     for (int i = 0; i < transform.childCount; i++)
     {
         global::UnityEngine.Transform child = transform.GetChild(i);
         bool flag = child.name == componentName;
         if (flag)
         {
             return(child);
         }
     }
     return(null);
 }
Example #5
0
    // Token: 0x060000D1 RID: 209 RVA: 0x000096E4 File Offset: 0x000078E4
    public void UpdateComponents()
    {
        global::UnityEngine.Transform transform = base.transform;
        bool flag = transform.childCount == 0;

        if (!flag)
        {
            using (global::SteamVR_RenderModel.RenderModelInterfaceHolder renderModelInterfaceHolder = new global::SteamVR_RenderModel.RenderModelInterfaceHolder())
            {
                global::Valve.VR.VRControllerState_t vrcontrollerState_t = (this.index != global::SteamVR_TrackedObject.EIndex.None) ? global::SteamVR_Controller.Input((int)this.index).GetState() : default(global::Valve.VR.VRControllerState_t);
                for (int i = 0; i < transform.childCount; i++)
                {
                    global::UnityEngine.Transform    child    = transform.GetChild(i);
                    global::Valve.VR.CVRRenderModels instance = renderModelInterfaceHolder.instance;
                    bool flag2 = instance == null;
                    if (flag2)
                    {
                        break;
                    }
                    global::Valve.VR.RenderModel_ComponentState_t renderModel_ComponentState_t = default(global::Valve.VR.RenderModel_ComponentState_t);
                    bool flag3 = !instance.GetComponentState(this.renderModelName, child.name, ref vrcontrollerState_t, ref this.controllerModeState, ref renderModel_ComponentState_t);
                    if (!flag3)
                    {
                        global::SteamVR_Utils.RigidTransform rigidTransform = new global::SteamVR_Utils.RigidTransform(renderModel_ComponentState_t.mTrackingToComponentRenderModel);
                        child.localPosition = rigidTransform.pos;
                        child.localRotation = rigidTransform.rot;
                        global::UnityEngine.Transform transform2 = child.FindChild("attach");
                        bool flag4 = transform2 != null;
                        if (flag4)
                        {
                            global::SteamVR_Utils.RigidTransform rigidTransform2 = new global::SteamVR_Utils.RigidTransform(renderModel_ComponentState_t.mTrackingToComponentLocal);
                            transform2.position = transform.TransformPoint(rigidTransform2.pos);
                            transform2.rotation = transform.rotation * rigidTransform2.rot;
                        }
                        bool flag5 = (renderModel_ComponentState_t.uProperties & 2U) > 0U;
                        bool flag6 = flag5 != child.gameObject.activeSelf;
                        if (flag6)
                        {
                            child.gameObject.SetActive(flag5);
                        }
                    }
                }
            }
        }
    }
Example #6
0
    // Token: 0x060000CD RID: 205 RVA: 0x000092E8 File Offset: 0x000074E8
    private bool LoadComponents(global::SteamVR_RenderModel.RenderModelInterfaceHolder holder, string renderModelName)
    {
        global::UnityEngine.Transform transform = base.transform;
        for (int i = 0; i < transform.childCount; i++)
        {
            global::UnityEngine.Transform child = transform.GetChild(i);
            child.gameObject.SetActive(false);
            this.StripMesh(child.gameObject);
        }
        bool flag = string.IsNullOrEmpty(renderModelName);
        bool result;

        if (flag)
        {
            result = true;
        }
        else
        {
            global::Valve.VR.CVRRenderModels instance = holder.instance;
            bool flag2 = instance == null;
            if (flag2)
            {
                result = false;
            }
            else
            {
                uint componentCount = instance.GetComponentCount(renderModelName);
                bool flag3          = componentCount == 0U;
                if (flag3)
                {
                    result = false;
                }
                else
                {
                    int num = 0;
                    while ((long)num < (long)((ulong)componentCount))
                    {
                        uint num2  = instance.GetComponentName(renderModelName, (uint)num, null, 0U);
                        bool flag4 = num2 == 0U;
                        if (!flag4)
                        {
                            global::System.Text.StringBuilder stringBuilder = new global::System.Text.StringBuilder((int)num2);
                            bool flag5 = instance.GetComponentName(renderModelName, (uint)num, stringBuilder, num2) == 0U;
                            if (!flag5)
                            {
                                transform = this.FindComponent(stringBuilder.ToString());
                                bool flag6 = transform != null;
                                if (flag6)
                                {
                                    transform.gameObject.SetActive(true);
                                }
                                else
                                {
                                    transform                  = new global::UnityEngine.GameObject(stringBuilder.ToString()).transform;
                                    transform.parent           = base.transform;
                                    transform.gameObject.layer = base.gameObject.layer;
                                    global::UnityEngine.Transform transform2 = new global::UnityEngine.GameObject("attach").transform;
                                    transform2.parent           = transform;
                                    transform2.localPosition    = global::UnityEngine.Vector3.zero;
                                    transform2.localRotation    = global::UnityEngine.Quaternion.identity;
                                    transform2.localScale       = global::UnityEngine.Vector3.one;
                                    transform2.gameObject.layer = base.gameObject.layer;
                                }
                                transform.localPosition = global::UnityEngine.Vector3.zero;
                                transform.localRotation = global::UnityEngine.Quaternion.identity;
                                transform.localScale    = global::UnityEngine.Vector3.one;
                                num2 = instance.GetComponentRenderModelName(renderModelName, stringBuilder.ToString(), null, 0U);
                                bool flag7 = num2 == 0U;
                                if (!flag7)
                                {
                                    global::System.Text.StringBuilder stringBuilder2 = new global::System.Text.StringBuilder((int)num2);
                                    bool flag8 = instance.GetComponentRenderModelName(renderModelName, stringBuilder.ToString(), stringBuilder2, num2) == 0U;
                                    if (!flag8)
                                    {
                                        global::SteamVR_RenderModel.RenderModel renderModel = global::SteamVR_RenderModel.models[stringBuilder2] as global::SteamVR_RenderModel.RenderModel;
                                        bool flag9 = renderModel == null || renderModel.mesh == null;
                                        if (flag9)
                                        {
                                            bool flag10 = this.verbose;
                                            if (flag10)
                                            {
                                                string text = "Loading render model ";
                                                global::System.Text.StringBuilder stringBuilder3 = stringBuilder2;
                                                global::UnityEngine.Debug.Log(text + ((stringBuilder3 != null) ? stringBuilder3.ToString() : null));
                                            }
                                            renderModel = this.LoadRenderModel(instance, stringBuilder2.ToString(), renderModelName);
                                            bool flag11 = renderModel == null;
                                            if (flag11)
                                            {
                                                goto IL_2BD;
                                            }
                                            global::SteamVR_RenderModel.models[stringBuilder2] = renderModel;
                                        }
                                        transform.gameObject.AddComponent <global::UnityEngine.MeshFilter>().mesh             = renderModel.mesh;
                                        transform.gameObject.AddComponent <global::UnityEngine.MeshRenderer>().sharedMaterial = renderModel.material;
                                    }
                                }
                            }
                        }
IL_2BD:
                        num++;
                    }
                    result = true;
                }
            }
        }
        return(result);
    }