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 TurbidWarrior · Mar 17, 2015 at 03:45 PM · camera2dbuildbugmode

Game Camera not scaling correctly when built.

Hello, as part of my game development college course i have to make a 2d game prototype, and i have encountered a few problems, but only 1 i need to fix urgently. The main problem is that when i build the game the menu works as desired, but upon clicking play and going to the game, the game camera is smaller and i can still see a bit of the menu on the right of my game, as shown in the picture. (http://i.imgur.com/z3Nc47E.png) i first took it off free aspect which helped it a bit but as you can see the problem is still pretty blatant and i'm out of ideas as to why its happening, both the menu and the camera for the game are the exact same size both image wise and camera scaling. the win/lose screens work perfectly it's just the game that shows this. any help would be appreciated greatly. thank you for your time.

Comment
Add comment · Show 3
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 AlwaysSunny · Mar 17, 2015 at 02:40 PM 0
Share

Gotta know more. What system are you using to draw your menu? Unity 4.6+'s UI, legacy GUI, something else? Why do you continue to draw your menu when it's no longer needed? Show us some relevant code and describe your situation in much greater detail. Best,

avatar image TurbidWarrior · Mar 17, 2015 at 03:58 PM 0
Share

Sorry man, im very new to this as this is first assignment where we have to basically learn it ourselves, my menu works as a separate scene that takes me to the game scene on button press using "Application.LoadLevel ("");", i am doing this using the uk system that was added in 4.6 though i'm on unity 5. below i will post a picture of each step and quote the relevant code used.

The $$anonymous$$enu (http://i.imgur.com/i0STULF.png) ->Click play -> The Game Opens (http://i.imgur.com/j2PLeU4.png)

the code used to navigate from menu to game:

*using UnityEngine; using System.Collections;

     public class $$anonymous$$ain$$anonymous$$enu : $$anonymous$$onoBehaviour {
     
         public Texture backgroundTexture;
         public GUIStyle Random1;
         public GUIStyle Random2;
         public float guiPlacementY;
         public float guiPlacementX;
         public float guiPlacementY2;
         public float guiPlacementX2;
         void OnGUI(){
             GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), backgroundTexture);
     
             //PLAY
             if (GUI.Button (new Rect(Screen.width * guiPlacementX, Screen.height * guiPlacementY, Screen.width * .5f, Screen.height * .2f),"", Random1)){
                 Application.LoadLevel ("ArrowDash");
             }
             //QUIT
             if (GUI.Button (new Rect(Screen.width * guiPlacementX2, Screen.height * guiPlacementY2, Screen.width * .45f, Screen.height * .2f),"", Random2)){
             Application.Quit();
             }
         }
     }*

$$anonymous$$ost of that is to get button positions done well. As you can see here (http://i.imgur.com/ZN4t5FC.png) if i place the menu image i made behind the game camera/HUD they are the same size, so it seems as if the game scene is being re sized across the x axis to allow for that gap on the right that shows the menu behind it.

$$anonymous$$enu Camera Settings (http://i.imgur.com/NhFo5tP.png) Game Camera Settings (http://i.imgur.com/4EvXzOh.png)

if you need any more information please let me know i hope this covers the important parts as i'm at a loss as to what this is.

avatar image TurbidWarrior · Mar 17, 2015 at 05:29 PM 0
Share

i don't know the policy on bumping threads on here, but my deadline is this Thursday so please if anyone has a suggestion i'm all ears :s

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by emayberry · Mar 17, 2015 at 06:13 PM

First of all, if you're using the new 4.6 UI components then you shouldn't need to deal with the OnGUI() method. If I were you, I would create a script with methods for navigating between scenes and attach it to a GameObject in your initial scene (don't forget to mark the gameobject as DontDestroyOnLoad or it'll disappear between scenes). I would then create the UI buttons using the inspector and use the OnClick functions to call methods on the controller. There are some good YouTube tutorials that I think suit your needs perfectly here:

Part 1 (Creating the menu) Part 2 (Changing scenes using OnClick)

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 captainkrisu · Mar 17, 2015 at 09:21 PM

You don't really need any scripting with the new UI system.

Have you tried changing Ui Scale Mode in Canvas, Canvas Scaler (Script).

And if you want to check how your menu scaling works, click "Maximize on play" in game view, or drag the game view out of unity editor, and scretch it as you want.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Camera too zoomed in in built game 1 Answer

Depth Fade Problem on distance in VR 0 Answers

Game preview incorrect! 0 Answers

Cinemachine weird lines of color when moving? 1 Answer

Distribute terrain in zones 3 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