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
0
Question by Rekaens · May 18, 2010 at 06:22 PM · camerasizeresizeminimapmini-map

Camera placement / size behavior

im totally lost here...

[url]http://img41.imageshack.us/img41/5498/unity1.jpg[/url]

as you can see, i got a minimap going on in the upper corner wich works great and all, just had a second camera put up and scaled it as you can see in the inspector,

my problem is that i want people regarding of resolution to have the same SIZE of the minimap window, and only the locations move accordingly,

but when i change screensize this happens

[url]http://img96.imageshack.us/img96/5171/unity2.jpg[/url]

it gets all thin (reacts same way in a build and) i want a fixed size, but the placement will have to be the upper right corner always, so 800x600 and 1920x1080 will have same size of minimap (like the way GUI reacts to screen size change)

thanks alot in advance you will really save my butt if you can get me out of this mess!

-Martin

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

3 Replies

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

Answer by Mike 3 · May 18, 2010 at 06:41 PM

You'll need a script to work out how much of the normalized screen you want it to take up

example:

private var lastPos : Vector2 = Vector2.zero; var absolouteWidth = 100.0; //in pixels var absolouteHeight = 100.0; var minimapCam : Camera;

function Update() { if (minimapCam == null) return;

var currentPos = Vector2(Screen.width, Screen.height); if ((lastPos - currentPos).magnitude > 2) { lastPos = currentPos;

 //you can modify this to put it somewhere else if you like
 minimapCam.pixelRect = new Rect(Screen.width - absolouteWidth, Screen.height - absolouteHeight, absolouteWidth, absolouteHeight);

}

}

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 Rekaens · May 18, 2010 at 08:09 PM 0
Share

ok mate this semi works xD i set the H and W to 200 each and it get the size it needs, only problem remains now, that it goes to the buttom of the screen ins$$anonymous$$d of top xD know a way to fix this? ty in advance and for your time

avatar image Mike 3 · May 18, 2010 at 08:16 PM 0
Share

must be 0 for bottom - editing the original

avatar image Rekaens · May 18, 2010 at 08:23 PM 0
Share

you got a "solved" mate :D thanks alot, just added "Screen.height - absolouteHeight" ins$$anonymous$$d of 0 and it worked thank you SO $$anonymous$$UCH!!

avatar image Mike 3 · May 18, 2010 at 08:53 PM 0
Share

Glad it works :)

avatar image
0

Answer by StephanK · May 18, 2010 at 06:41 PM

Yhe problem is, that the normalized viewport rectangle uses floats to determine its size. These floats are between 0 and 1 and can be read as percentage of the overall screen size. If you want a fixed width of a certain viewport you will have to determine the overall size of the screen (Screen.width, Screen.height) and calculate the factor (between 0 and 1) yourself (factor = fixedWidth / Screen.width) and then tell the viewport to use the calculated size.

Comment
Add comment · 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
0

Answer by Wraifen_09 · Oct 05, 2018 at 01:28 AM

 {
 
 
 
 
     
    public float absolouteWidth = 100; //in pixels
    public float absolouteHeight = 100;
 
     public GameObject Minicam;
     
 
 
      void Update()
     {
         if (Minicam == null) return;
 
         var lastPos = Vector2.zero;
         var currentPos = new Vector2 (Screen.width, Screen.height);
         if ((lastPos - currentPos).magnitude > 2)
         {
             lastPos = currentPos;
 
 
             //you can modify this to put it somewhere else if you like
             gameObject.GetComponent<Camera>().pixelRect = new Rect(Screen.width - absolouteWidth, Screen.height - absolouteHeight, absolouteWidth, absolouteHeight);
 
         }
 
 
     }


the new 2018 way, works a treat

Comment
Add comment · 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

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

1 Person is following this question.

avatar image

Related Questions

Resizing minimap camera fails on first function call, but not following calls 2 Answers

Is it possible to make a camera update only once every X seconds ? 2 Answers

How do I attach a Camera to a GUI (for a Mini map) 4 Answers

MiniMap with player and object icons 1 Answer

Fixing a Camera viewport rect to a certain size? (So it doesn't change with the size of the gamewindow) 1 Answer


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