Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Haugen · Jun 22, 2014 at 09:10 AM · camerascreensimulatorin-world

In-world "screen" from camera?

Background

I've made a prototype of a space simulator, It's based loosely on the idea of a "space shuttle simulator". I'm going for the realistic approach, which means that I'm trying to shun exterior views.

The problem

I want to have screens in my cockpit, so the player can swivel their head and look at a virtual screen. I've been using "Normalized Viewport Rectangles" in my prototyping process; but that's not a permanent solution. I am unsure if this is possible, and even more unsure of where to begin my research.

Any pointers in the right direction would be appreciated!

-Frank

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Bunny83 · Jun 22, 2014 at 09:17 AM

For this you need Unity pro since you need RenderTextures

It's possible to workaround that limitation in the Free version, but it has horrible performance as you would use Texture2D.ReadPixels.

edit

Well, you can get the effect of a RenderTexture with a script like this:

 // C#
 using UnityEngine;
 using System.Collections;
 
 [RequireComponent(typeof(Camera))]
 public class CustomRT : MonoBehaviour
 {
     public Rect rect;
     public Material mat;
     Texture2D texture;
     void Start()
     {
         camera.pixelRect = rect;
         texture = new Texture2D((int)rect.width,(int)rect.height,TextureFormat.ARGB32,false);
         mat.mainTexture = texture;
     }
     
     void OnPostRender()
     {
         texture.ReadPixels(rect,0,0);
         texture.Apply();
     }
 }

Do the following steps:

  • Attach the script to a second camera.

  • Change the camera's depth to be rendered before your main camera

  • Create a material and assign it to the "mat" field

  • Choose a rect size for the RT. Note: You can't use a larger size than your screen has!

  • Use the material on whatever geometry you like

The result looks like this:
webplayerExample

ps: I've added a link at the bottom to a UnityPackage which contains the example scene.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Haugen · Jun 22, 2014 at 09:36 AM 0
Share

Wouldn't this just "screenshot" from somewhere on the "main viewport"?

The CPU-issue on the free version, I can live with until I have a "marketable product", (I'll just have a VERY low frame-rate on the virtual displays)

avatar image Bunny83 · Jun 22, 2014 at 11:28 AM 1
Share

I've updated my answer with an example.

avatar image Haugen · Jun 23, 2014 at 07:41 PM 0
Share

Ah! YES!! this is awesome! (the documentation was a bit vague, but an example like this isn't)

Thanks!

avatar image meat5000 ♦ · Jun 23, 2014 at 08:18 PM 0
Share

Could you handle the free version in a thread?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

why my unity games run on android devieces,the screen will be wrong. 0 Answers

how to have an object positioned relative to the screen(like a button) 1 Answer

UI render doesn't sync with Camera movement 2 Answers

Why doesn't my players camera work and why does it spaz out randomly 1 Answer

Keeping screen width and scaling screen height for different screen resolutions 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges