Exemplo n.º 1
0
        public static void CreatePUIRoot()
        {
            GameObject PUIRootGo = new GameObject("PUIRoot");
            PUIRoot    puiRoot   = PUIRootGo.AddComponent <PUIRoot> ();
            Canvas     canvas    = PUIRootGo.AddComponent <Canvas> ();

            if (canvas.renderMode == RenderMode.WorldSpace)
            {
                canvas.worldCamera = GameObject.FindObjectOfType <Camera> ();
            }

            RectTransform puiRectTransform = PUIRootGo.GetComponent <RectTransform> ();

            puiRectTransform.sizeDelta          = new Vector2(2880, 1600);
            puiRectTransform.localScale         = Vector3.one / 1000;
            puiRectTransform.anchoredPosition3D = new Vector3(0, 1.67f, 1);

            PUIRootGo.AddComponent <CanvasScaler> ();
            PUIRootGo.AddComponent <GraphicRaycaster> ();

            GameObject eventSystemGo = new GameObject("EventSystem");

            eventSystemGo.AddComponent <EventSystem> ();
            eventSystemGo.AddComponent <StandaloneInputModule> ();
        }
Exemplo n.º 2
0
 private void OnEnable()
 {
     t = target as PUIRoot;
     mRectTransform = t.gameObject.GetComponent <RectTransform> ();
     t.distance     = mRectTransform.anchoredPosition3D.z;
     t.height       = mRectTransform.anchoredPosition3D.y;
 }