Esempio n. 1
0
        private static void moveCursor(MFDPTacticalSituationDisplay tsd, GameObject buttonObject)
        {
            Vector3 targetPos = buttonObject.transform.position;

            targetPos = ClampedSelectorPosition(targetPos, tsd.selectorTf);
            tsd.selectorTf.position = targetPos;

            TSDContactIcon snapIcon = (TSDContactIcon)tsdTraverse.Field("snapIcon").GetValue();

            if (snapIcon != buttonObject.GetComponent <TSDContactIcon>())
            {
                tsdTraverse.Method("UnSnapCursor").GetValue();
            }


            if ((TSDContactIcon)tsdTraverse.Field("snapIcon").GetValue() != null)
            {
                tsdTraverse.Method("M_OnInputButtonDown").GetValue();
                return;
            }
            tsdTraverse.Field("snapIcon").SetValue(buttonObject.GetComponent <TSDContactIcon>());
            tsdTraverse.Method("M_OnInputButtonDown").GetValue();
        }
Esempio n. 2
0
        public static void Postfix(MFDPTacticalSituationDisplay __instance, ref TSDContactIcon __result)
        {
            if (VTOLAPI.GetPlayersVehicleEnum() == VTOLVehicles.F45A)
            {
                GameObject f45       = VTOLAPI.GetPlayersVehicleGameObject();
                GameObject soiButton = GetChildWithName(f45, "ScaleButton (1)");
                GameObject hvrObj    = GetChildWithName(soiButton, "hvrObj");
                tsdTraverse = Traverse.Create(__instance);

                GameObject contactHvrObj = UnityEngine.Object.Instantiate(hvrObj, __result.transform);

                float   scaler         = 1.3f;
                Vector2 hvrObjOrigSize = contactHvrObj.GetComponent <Image>().rectTransform.sizeDelta;
                contactHvrObj.GetComponent <Image>().rectTransform.sizeDelta *= scaler;

                __result.gameObject.SetActive(false);
                VRInteractable interact = __result.gameObject.AddComponent <VRInteractable>();
                interact.interactableName = "Select";
                interact.button           = VRInteractable.Buttons.Trigger;
                interact.radius           = 0;
                interact.useRect          = true;
                interact.rect.center      = Vector3.zero;
                interact.rect.extents     = new Vector3(10, 10, 20);
                interact.requireMotion    = false;
                interact.toggle           = false;
                interact.tapOrHold        = false;
                interact.sqrRadius        = 0;
                interact.OnInteract       = new UnityEvent();
                interact.OnInteract.AddListener(f45.GetComponentInChildren <MFDPortalManager>().PlayInputSound);
                interact.OnInteract.AddListener(delegate { moveCursor(__instance, interact.gameObject); });

                VRIHoverToggle hoverToggle = __result.gameObject.AddComponent <VRIHoverToggle>();
                hoverToggle.hoverObj = contactHvrObj;
                __result.gameObject.SetActive(true);
            }
        }