Exemplo n.º 1
0
        /*
         * void CreateCameraIfNeeded()
         * {
         *  if (uiCamera) return;
         *
         *  var go = new GameObject("uHomography UI Camera");
         *  go.transform.localPosition = new Vector3(0f, 0f, -9999f);
         *  go.transform.SetParent(transform);
         *
         *  uiCamera = go.AddComponent<Camera>();
         *  uiCamera.clearFlags = CameraClearFlags.Depth;
         *  uiCamera.orthographic = true;
         *  uiCamera.orthographicSize = 5.5f;
         *  uiCamera.useOcclusionCulling = false;
         *  uiCamera.allowHDR = false;
         *  uiCamera.allowMSAA = false;
         *  uiCamera.nearClipPlane = 1f;
         *  uiCamera.farClipPlane = 100f;
         *  uiCamera.depth = 100;
         *
         *  var raycaster = go.AddComponent<Physics2DRaycaster>();
         *  raycaster.eventMask = 1 << layer;
         * }
         */

        void CreateVertexIfNeeded(ref DraggableVertex vertex, Vector3 pos)
        {
            if (vertex || !uiImage)
            {
                return;
            }

            var prefab = Resources.Load <GameObject>(VertexPrefabPath);

            Assert.IsNotNull(prefab, VertexPrefabPath + " was not found.");

            var go = Instantiate(prefab, uiImage.transform);

            go.transform.localPosition = pos;
            vertex = go.GetComponent <DraggableVertex>();
            Assert.IsNotNull(vertex, "The Vertex prefab does not have DraggableVertex component.");

            vertex.camera = uiCamera;
        }
Exemplo n.º 2
0
        void CreateVertexIfNeeded(ref DraggableVertex vertex, Vector3 pos)
        {
            if (vertex || !uiCamera)
            {
                return;
            }

            var prefab = Resources.Load <GameObject>(VertexPrefabPath);

            Assert.IsNotNull(prefab, VertexPrefabPath + " was not found.");

            var go = Instantiate(prefab, uiCamera.transform);

            //var go = Instantiate(prefab, anchor.transform);

            go.transform.localPosition = pos;
            float taille = (image.rectTransform.sizeDelta.x > image.rectTransform.sizeDelta.y ? image.rectTransform.sizeDelta.x : image.rectTransform.sizeDelta.y) / 10f;

            go.transform.localScale = new Vector3(taille, taille, 1f);
            vertex = go.GetComponent <DraggableVertex>();
            Assert.IsNotNull(vertex, "The Vertex prefab does not have DraggableVertex component.");

            vertex.camera = uiCamera;
        }