コード例 #1
0
        /// <summary>
        /// Create realtime comic panel. Invoke this Method as a coroutine.
        /// </summary>
        /// <param name="panel">Comic panel object.</param>
        /// <param name="size">Panel size.</param>
        /// <param name="camera">RenderCamera to use.</param>
        protected IEnumerator Realtime(GameObject panel, Vector2 size, RenderCamera camera)
        {
            RenderTexture rendered = RenderTexture.GetTemporary((int)size.x, (int)size.y, 24, RenderTextureFormat.Default, RenderTextureReadWrite.Default, 4);

            // Setup camera
            camera.targetTexture = rendered;

            // Display GUI panel
            panel.GetComponentInChildren <RawImage>(true).texture = rendered as Texture;
            panel.SetActive(true);

            // Delay before cleanup
            if (_mutualLifetime)
            {
                yield return(_sequenceFinishDelay);
            }
            else
            {
                yield return(_lifetimeDelay);
            }

            // Cleanup panel after its lifetime
            panel.GetComponentInChildren <RawImage>(false).texture = null;
            camera.targetTexture = null;
            RenderTexture.ReleaseTemporary(rendered);
            panel.SetActive(false);
            _renderCameraStack.ReleaseRenderCamera(camera);
        }
コード例 #2
0
        public RenderCamera GetRenderCamera(Vector3 position, Transform focus, Transform parent)
        {
            for (int i = 0; i < _mainStack.Count; i++)
            {
                if (_mainStack[i].activeSelf == false)
                {
                    _mainStack[i].focus = focus;
                    _mainStack[i].SetPosition(position);
                    _mainStack[i].transform.SetParent(parent);
                    _mainStack[i].gameObject.SetActive(true);
                    return(_mainStack[i]);
                }
            }

            RenderCamera newRenderCam = new RenderCamera("SnapPanel Camera " + _mainStack.Count.ToString("D"), _depth);

            newRenderCam.focus = focus;
            newRenderCam.SetPosition(position);
            newRenderCam.transform.SetParent(parent);
            newRenderCam.gameObject.SetActive(true);

            _mainStack.Add(newRenderCam);

            return(newRenderCam);
        }
コード例 #3
0
        /// <summary>
        /// Create static comic panel. Invoke this Method as a coroutine.
        /// </summary>
        /// <param name="panel">Comic panel object.</param>
        /// <param name="size">Panel size.</param>
        /// <param name="camera">RenderCamera to use.</param>
        protected IEnumerator Snapshot(GameObject panel, Vector2 size, RenderCamera camera)
        {
            RenderTexture rendered = RenderTexture.GetTemporary((int)size.x, (int)size.y, 24, RenderTextureFormat.Default, RenderTextureReadWrite.Default, 4);

            // Setup camera
            camera.targetTexture = rendered;


            // Setup render path and render camera view
            RenderTexture currentRT = RenderTexture.active;

            RenderTexture.active = camera.targetTexture;

            camera.Render();

            // Read pixels from render pipeline and save it in a 2D texture
            Texture2D content = new Texture2D((int)size.x, (int)size.y);

            content.ReadPixels(new Rect(Vector2.zero, size), 0, 0);
            content.Apply();

            // Reset render path and release temporary render texture
            RenderTexture.active = currentRT;
            camera.targetTexture = null;
            RenderTexture.ReleaseTemporary(rendered);
            _renderCameraStack.ReleaseRenderCamera(camera);

            // Display GUI panel
            panel.GetComponentInChildren <RawImage>(true).texture = content as Texture;
            panel.SetActive(true);

            // Delay before cleanup
            if (_mutualLifetime)
            {
                yield return(_sequenceFinishDelay);
            }
            else
            {
                yield return(_lifetimeDelay);
            }


            // Cleanup panel after its lifetime
            panel.GetComponentInChildren <RawImage>(false).texture = null;
            panel.SetActive(false);
        }
コード例 #4
0
 public void ReleaseRenderCamera(RenderCamera renderCam)
 {
     renderCam.gameObject.SetActive(false);
 }
コード例 #5
0
 /// <summary>
 /// Clones the RenderCamera original and returns the clone.
 /// </summary>
 /// <param name="original">Original.</param>
 /// <param name="parent">Parent that will be assigned to the new object.</param>
 public static RenderCamera Instantiate(RenderCamera original, Transform parent)
 {
     GameObject.Instantiate(original.gameObject, parent);
     return(original);
 }
コード例 #6
0
 /// <summary>
 /// Clones the RenderCamera original and returns the clone.
 /// </summary>
 /// <param name="original">Original.</param>
 public static RenderCamera Instantiate(RenderCamera original)
 {
     GameObject.Instantiate(original.gameObject);
     return(original);
 }
コード例 #7
0
 /// <summary>
 /// Destroys the specified RenderCamera.
 /// </summary>
 /// <param name="renderCamera">RenderCamera to destroy.</param>
 /// <param name="t">The optional amount of time to delay before destroying the object.</param>
 public static void Destroy(RenderCamera renderCamera, float t)
 {
     GameObject.Destroy(renderCamera.gameObject, t);
 }
コード例 #8
0
 /// <summary>
 /// Destroys the specified RenderCamera.
 /// </summary>
 /// <param name="renderCamera">RenderCamera to destroy.</param>
 public static void Destroy(RenderCamera renderCamera)
 {
     GameObject.Destroy(renderCamera.gameObject);
 }
コード例 #9
0
 /// <summary>
 /// Clones the RenderCamera original and returns the clone.
 /// </summary>
 /// <param name="original">Original.</param>
 /// <param name="position">Position for the new object.</param>
 /// <param name="rotation">Orientation of the new object.</param>
 /// <param name="parent">Parent that will be assigned to the new object.</param>
 public static RenderCamera Instantiate(RenderCamera original, Vector3 position, Quaternion rotation, Transform parent)
 {
     GameObject.Instantiate(original.gameObject, position, rotation, parent);
     return(original);
 }
コード例 #10
0
 /// <summary>
 /// Clones the RenderCamera original and returns the clone.
 /// </summary>
 /// <param name="original">Original.</param>
 /// <param name="parent">Parent that will be assigned to the new object.</param>
 /// <param name="instantiateInWorldSpace">If set to <c>true</c> instantiate in world space.</param>
 public static RenderCamera Instantiate(RenderCamera original, Transform parent, bool instantiateInWorldSpace)
 {
     GameObject.Instantiate(original.gameObject, parent, instantiateInWorldSpace);
     return(original);
 }