Example #1
0
        public void Enable(IHandController ctl)
        {
            events      = ctl.Events;
            otherEvents = ctl.Other.Events;
            player      = ctl.Player;

            ctl.Events.GripPressed        += OnGrabStart;
            ctl.Events.GripReleased       += OnGrabEnd;
            ctl.Other.Events.GripPressed  += OnDoubleGrabStart;
            ctl.Other.Events.GripReleased += OnGrabEnd;
            ctl.OnFixedUpdate             += FixedUpdate;

            readoutObj = GameObject.Instantiate(ctl.Player.SimpleReadout, ctl.gameObject.transform, false);

            readout = readoutObj.GetComponent <SimpleReadout>();

            readout.Scale    = 0.002f;
            readout.Size     = new Vector2(100.0f, 30.0f);
            readout.Position = new Vector3(0.0f, 0.15f, -0.15f);

            readout.transform.localRotation = Quaternion.Euler(65.0f, 0.0f, 0.0f);

            grab = false; // Reset the state to avoid weird behavior

            UpdateReadout();
        }
Example #2
0
        public void Enable(IHandController ctl)
        {
            if (lineObj != null)
            {
                GameObject.Destroy(lineObj);
            }
            if (readoutObj != null)
            {
                GameObject.Destroy(readoutObj);
            }

            hand = ctl;
            ctl.Events.TriggerPressed += Advance;
            ctl.OnFixedUpdate         += FixedUpdate;

            lineObj    = GameObject.Instantiate(ctl.Player.MeasureLine, ctl.gameObject.transform, false);
            readoutObj = GameObject.Instantiate(ctl.Player.SimpleReadout, ctl.gameObject.transform, false);

            line    = lineObj.GetComponent <LineRenderer>();
            readout = readoutObj.GetComponent <SimpleReadout>();

            readout.Scale    = 0.002f;
            readout.Size     = new Vector2(100.0f, 30.0f);
            readout.Position = new Vector3(0.0f, 0.0f, 0.1f);

            readout.transform.localRotation = Quaternion.Euler(45.0f, 0.0f, 0.0f);

            UpdateLine();
        }