コード例 #1
0
        private GameObject CreateModuleDisplay(Vector3 position, Quaternion rotation)
        {
            const float scale = 0.215f;

            Canvas    canvas = new GameObject("Canvas", typeof(RectTransform)).AddComponent <Canvas>();
            Transform t      = canvas.transform;

            t.SetParent(this.transform, false);
            canvas.sortingLayerID = 1;

            uGUI_GraphicRaycaster raycaster = canvas.gameObject.AddComponent <uGUI_GraphicRaycaster>();

            var rt = t as RectTransform;

            RectTransformExtensions.SetParams(rt, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f));
            RectTransformExtensions.SetSize(rt, 0.5f, 0.5f);

            t.localPosition = position;
            t.localRotation = rotation;
            t.localScale    = new Vector3(scale, scale, scale);

            canvas.scaleFactor            = 0.01f;
            canvas.renderMode             = RenderMode.WorldSpace;
            canvas.referencePixelsPerUnit = 100;

            CanvasScaler scaler = canvas.gameObject.AddComponent <CanvasScaler>();

            scaler.dynamicPixelsPerUnit = 20;

            uGUI_Icon icon = canvas.gameObject.AddComponent <uGUI_Icon>();

            return(canvas.gameObject);
        }
コード例 #2
0
ファイル: RaycastFixer.cs プロジェクト: MrPurple6411/VRTweaks
 public static void Fix(ref uGUI_GraphicRaycaster raycaster, uGUI_InputGroup __instance)
 {
     if (GameInput.IsPrimaryDeviceGamepad() && !VROptions.GetUseGazeBasedCursor())
     {
         raycaster.enabled = false;
     }
     else
     {
         raycaster.enabled = __instance.focused;
     }
 }
コード例 #3
0
        internal static Canvas CreateModuleDisplay(GameObject anchor, Vector3 position, Quaternion rotation, TechType startingState)
        {
            const float scale = 0.215f;

            Canvas    canvas = new GameObject("Canvas", typeof(RectTransform)).AddComponent <Canvas>();
            Transform t      = canvas.transform;

            t.SetParent(anchor.transform, false);
            canvas.sortingLayerID = 1;

            uGUI_GraphicRaycaster raycaster = canvas.gameObject.AddComponent <uGUI_GraphicRaycaster>();

            var rt = t as RectTransform;

            RectTransformExtensions.SetParams(rt, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f));
            RectTransformExtensions.SetSize(rt, 0.5f, 0.5f);

            t.localPosition = position;
            t.localRotation = rotation;
            t.localScale    = new Vector3(scale, scale, scale);

            canvas.scaleFactor            = 0.01f;
            canvas.renderMode             = RenderMode.WorldSpace;
            canvas.referencePixelsPerUnit = 100;

            CanvasScaler scaler = canvas.gameObject.AddComponent <CanvasScaler>();

            scaler.dynamicPixelsPerUnit = 20;

            uGUI_Icon icon = canvas.gameObject.AddComponent <uGUI_Icon>();

            if (startingState > TechType.None)
            {
                icon.sprite  = SpriteManager.Get(startingState);
                icon.enabled = true;
                canvas.gameObject.SetActive(true);
            }
            else
            {
                canvas.gameObject.SetActive(false);
                icon.enabled = false;
            }

            return(canvas);
        }
コード例 #4
0
        public void Awake()
        {
            manager          = GetComponentInParent <SeaTruckScannerModuleManager>();
            raycaster        = GetComponent <uGUI_GraphicRaycaster>();
            scanner_cullable = transform.Find("scanner_cullable");

            List <uGUI_MapRoomResourceNode> mapRoomNodes = new List <uGUI_MapRoomResourceNode>();

            scanner_cullable.Find("list").gameObject.GetComponentsInChildren(true, mapRoomNodes);

            List <uGUI_SeaTruckResourceNode> seatruckNodes = new List <uGUI_SeaTruckResourceNode>();

            foreach (uGUI_MapRoomResourceNode mapRoomNode in mapRoomNodes)
            {
                uGUI_SeaTruckResourceNode seatruckNode = mapRoomNode.gameObject.AddComponent <uGUI_SeaTruckResourceNode>();
                resourceList.Add(seatruckNode);
            }



            resourceListRoot = scanner_cullable.Find("list").gameObject;
            scanningRoot     = scanner_cullable.Find("scanning").gameObject;
            nextPageButton   = scanner_cullable.Find("list/nav/scroll_down").gameObject;
            SetNextPageButtonEventTriggers();
            prevPageButton = scanner_cullable.Find("list/nav/scroll_up").gameObject;
            SetPrevPageButtonEventTriggers();

            scanner_cullable.Find("scanning/cancelButton").gameObject.AddComponent <uGUI_SeaTruckScannerCancel>();

            activeTechTypeLabel = scanner_cullable.Find("scanning/activeTechType").GetComponent <TextMeshProUGUI>();
            scanningText        = scanner_cullable.Find("scanning/scanningText").GetComponent <TextMeshProUGUI>();
            navText             = scanner_cullable.Find("list/nav/pagenum").GetComponent <TextMeshProUGUI>();

            scanningIcon = scanner_cullable.Find("scanning/icon").GetComponent <uGUI_Icon>();

            startScanningSound      = ScriptableObject.CreateInstance <FMODAsset>();
            startScanningSound.name = "scan";
            startScanningSound.path = "event:/sub/base/map room/scan";

            cancelScanningSound      = ScriptableObject.CreateInstance <FMODAsset>();
            cancelScanningSound.name = "option_tweek";
            cancelScanningSound.path = "event:/interface/option_tweek";

            hoverSound      = ScriptableObject.CreateInstance <FMODAsset>();
            hoverSound.name = "select";
            hoverSound.path = "event:/sub/base/map room/select";

            pageChangeSound      = ScriptableObject.CreateInstance <FMODAsset>();
            pageChangeSound.name = "text_type";
            pageChangeSound.path = "event:/interface/text_type";

            segmentListener = transform.parent.GetComponentInParent <SeaTruckSegmentListener>();

            segmentListener.onPlayerExited += OnPlayerExit;

            Sprite scanning_background = ImageUtils.LoadSpriteFromFile($"{Main.modFolder}/Assets/scanning_background_02.png");
            Sprite scanning_foreground = ImageUtils.LoadSpriteFromFile($"{Main.modFolder}/Assets/scanning_foreground_02.png");

            GameObject animation = scanningRoot.transform.Find("animation").gameObject;

            GameObject scanningBackground = new GameObject("scanningBackground", new Type[] { typeof(RectTransform) });

            scanningBackground.transform.SetParent(scanningRoot.transform, false);
            scanningBackground.transform.SetSiblingIndex(0);
            scanningBackground.transform.localScale    = new Vector3(0.62f, 0.62f, 0.62f);
            scanningBackground.transform.localPosition = new Vector3(0, -12f, 0);
            Image newScanningBackground = scanningBackground.AddComponent <Image>();

            newScanningBackground.sprite = scanning_background;

            Image animationImage = animation.GetComponent <Image>();

            animationImage.sprite = scanning_foreground;

            uGUI_RotateImage rotateImage = animation.GetComponent <uGUI_RotateImage>();

            rotateImage.rotationTime = -4;
        }
コード例 #5
0
 public static bool Prefix(ref uGUI_GraphicRaycaster raycaster, uGUI_BuilderMenu __instance)
 {
     RaycastFixer.Fix(ref raycaster, __instance);
     return(false);
 }