Ejemplo n.º 1
0
 void Install()
 {
     foreach (Transform t in objs)
     {
         ScreenPosSync s      = t.FindComponent <ScreenPosSync>();
         Camera        dstCam = CameraEx.GetCamera(t.gameObject.layer);
         if (s.srcObj == null)
         {
             s.srcObj = srcCam.gameObject.CreateChild(t.name + "_sync").transform;
         }
         // set the src position based on the destination object position
         Vector3 screenPos = dstCam.WorldToScreenPoint(t.position);
         Vector3 srcPos    = srcCam.ScreenToWorldPoint(screenPos);
         float   distance  = Vector3.Distance(dstCam.transform.position, t.position);
         srcPos           += srcCam.transform.forward * distance; // depth
         s.srcObj.position = srcPos;
     }
 }
Ejemplo n.º 2
0
        private void SpawnClickEffect(GameObject o)
        {
            if (UICamera.hoveredObject == null)
            {
                return;
            }
            Vector3 clickPos     = UICamera.lastWorldPosition;
            Camera  mainCam      = Camera.main;
            Camera  singletonCam = CameraEx.GetCamera(gameObject.layer);

            if (singletonCam != null && mainCam != null && mainCam != singletonCam)
            {
                clickPos = singletonCam.ScreenToWorldPoint(new Vector3(UICamera.lastEventPosition.x, UICamera.lastEventPosition.y, 0));
            }
            ParticleControl particle = particlePool.GetInstance();

            particle.ignoreTimeScale    = true;
            particle.transform.position = clickPos;
            particle.Play();
        }