Ejemplo n.º 1
0
    public void OnGrabbed(HandTarget handTarget)
    {
        grabbingHandTarget = handTarget;

        HumanoidControl humanoid = handTarget.humanoid;

        if (humanoid == null)
        {
            return;
        }

        if (interactionPointer != null)
        {
            interactionPointer.active = true;
        }

        ControllerInput controllerInput = humanoid.GetComponent <ControllerInput>();

        if (controllerInput == null)
        {
            return;
        }

        if (handTarget.isLeft)
        {
            controllerInput.leftTrigger1Input.SetMethod(Fire, InputEvent.EventType.Start);
        }
        else
        {
            controllerInput.rightTrigger1Input.SetMethod(Fire, InputEvent.EventType.Start);
        }
    }
Ejemplo n.º 2
0
    public void OnLetGo()
    {
        if (grabbingHandTarget == null)
        {
            return;
        }

        HumanoidControl humanoid = grabbingHandTarget.humanoid;

        if (humanoid == null)
        {
            return;
        }

        if (interactionPointer != null)
        {
            interactionPointer.active = false;
        }

        ControllerInput controllerInput = humanoid.GetComponent <ControllerInput>();

        if (controllerInput == null)
        {
            return;
        }

        if (grabbingHandTarget.isLeft)
        {
            controllerInput.leftTrigger1Input.SetMethod((InputEvent.FloatMethod)null, InputEvent.EventType.None);
        }
        else
        {
            controllerInput.rightTrigger1Input.SetMethod((InputEvent.FloatMethod)null, InputEvent.EventType.None);
        }
    }
Ejemplo n.º 3
0
        //private ControllerInput GetControllerInput(out bool isleft) {
        //    isleft = false;
        //    HandInput settings = (HandInput)target;

        //    HandTarget handTarget = settings.GetComponent<HandTarget>();
        //    if (handTarget == null)
        //        return null;

        //    isleft = handTarget.isLeft;
        //    HumanoidControl humanoid = handTarget.humanoid;
        //    return humanoid.GetComponent<ControllerInput>();

        //}

        #region Inspector
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            HandTargetInspector(handInput);

            SetEventInput(handInput);
            //SetHandPoseInputList(handInput);

            if (handInput.handTarget != null)
            {
                HumanoidControl  humanoid           = handInput.handTarget.humanoid;
                ControllerInput  controllerSettings = humanoid.GetComponent <ControllerInput>();
                SerializedObject sInput             = new SerializedObject(controllerSettings);
                if (controllerSettings != null)
                {
                    SetControllerInput(sInput, handInput.gameObject, controllerSettings, handInput.handTarget.isLeft);
                }
                sInput.ApplyModifiedProperties();
            }

            CopyFromControllerInputList();

            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 4
0
        private void CopyFromControllerInputList()
        {
            HandInput settings = (HandInput)target;

            HandTarget handTarget = (HandTarget)handTargetProp.objectReferenceValue;

            if (handTarget == null)
            {
                return;
            }

            HumanoidControl humanoid        = handTarget.humanoid;
            ControllerInput controllerInput = humanoid.GetComponent <ControllerInput>();

            if (controllerInput == null)
            {
                return;
            }

            if (handTarget.isLeft)
            {
                CopyFromControllerInput(controllerInput.leftVerticalInput, settings.controllerInput[0]);
                CopyFromControllerInput(controllerInput.leftHorizontalInput, settings.controllerInput[1]);
                CopyFromControllerInput(controllerInput.leftStickButtonInput, settings.controllerInput[2]);
                CopyFromControllerInput(controllerInput.leftStickTouchInput, settings.controllerInput[3]);
                CopyFromControllerInput(controllerInput.leftButtonOneInput, settings.controllerInput[4]);
                CopyFromControllerInput(controllerInput.leftButtonTwoInput, settings.controllerInput[5]);
                CopyFromControllerInput(controllerInput.leftButtonThreeInput, settings.controllerInput[6]);
                CopyFromControllerInput(controllerInput.leftButtonFourInput, settings.controllerInput[7]);
                CopyFromControllerInput(controllerInput.leftTrigger1Input, settings.controllerInput[8]);
                CopyFromControllerInput(controllerInput.leftTrigger2Input, settings.controllerInput[9]);
                CopyFromControllerInput(controllerInput.leftOptionInput, settings.controllerInput[10]);
            }
            else
            {
                CopyFromControllerInput(controllerInput.rightVerticalInput, settings.controllerInput[0]);
                CopyFromControllerInput(controllerInput.rightHorizontalInput, settings.controllerInput[1]);
                CopyFromControllerInput(controllerInput.rightStickButtonInput, settings.controllerInput[2]);
                CopyFromControllerInput(controllerInput.rightStickTouchInput, settings.controllerInput[3]);
                CopyFromControllerInput(controllerInput.rightButtonOneInput, settings.controllerInput[4]);
                CopyFromControllerInput(controllerInput.rightButtonTwoInput, settings.controllerInput[5]);
                CopyFromControllerInput(controllerInput.rightButtonThreeInput, settings.controllerInput[6]);
                CopyFromControllerInput(controllerInput.rightButtonFourInput, settings.controllerInput[7]);
                CopyFromControllerInput(controllerInput.rightTrigger1Input, settings.controllerInput[8]);
                CopyFromControllerInput(controllerInput.rightTrigger2Input, settings.controllerInput[9]);
                CopyFromControllerInput(controllerInput.rightOptionInput, settings.controllerInput[10]);
            }
        }
Ejemplo n.º 5
0
        private static void GetPlaymakerEvents(HumanoidControl humanoid)
        {
            if (humanoid == null)
            {
                return;
            }

            PlayMakerFSM fsm = humanoid.GetComponent <PlayMakerFSM>();

            if (fsm == null)
            {
                playmakerEvents = null;
                return;
            }

            playmakerEvents = fsm.FsmEvents;

            playmakerEventNames    = new string[playmakerEvents.Length + 1];
            playmakerEventNames[0] = " ";
            for (int i = 0; i < playmakerEvents.Length; i++)
            {
                playmakerEventNames[i + 1] = playmakerEvents[i].Name;
            }
        }