Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
This question was closed Jun 23, 2016 at 09:49 PM by MarkedMaps.
avatar image
0
Question by MarkedMaps · Jun 15, 2016 at 08:37 PM · #pragma#pragma strict

Enter full screen on Computer without a new scene

alt text

Hi, I'm trying to make a computer that your able to click on and go full screen in, but you can click back out of to go back to the room, but also be able to click back in it, if anyone can help and actually success and test their script, It'd be greatly amazing! Thank you!

C# or just Java~

capture.png (291.5 kB)
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

  • Sort: 
avatar image
1
Best Answer

Answer by TBruce · Jun 15, 2016 at 10:47 PM

This will do the trick

 using UnityEngine;
 using System.Collections;
 
 public class ToggleObjectScale : MonoBehaviour
 {
     private bool objectMaximised = false;
     private Vector3 norlmalScale = Vector3.zero;
     private Vector3 maxScale = Vector3.zero;
 
     void Start()
     {
         norlmalScale = gameObject.transform.localScale;
         maxScale = new Vector3(Screen.width / norlmalScale.x, Screen.height / norlmalScale.y, norlmalScale.z);
     }
 
     void OnMouseDown()
     {
         if (objectMaximised)
         {
             gameObject.transform.localScale = norlmalScale;
         }
         else
         {
             gameObject.transform.localScale = maxScale;
         }
         objectMaximised = !objectMaximised;
     }
 }

You need to make sure that there is a collider on the GameObject.

The thing is it will max the complete object. You may want to create an object that just represents the screen and attach this script to it. That way it will only enlarge the screen itself.

I did a quick test using a Quad and a sample material. Worked fine.

This is another version which is a little better

 using UnityEngine;
 using System.Collections;
 
 public class ToggleObjectScale : MonoBehaviour
 {
     private bool objectMaximised = false;
     private Vector3 norlmalScale = Vector3.zero;
     public Vector3 maxScale = Vector3.zero;
 
     public float distance = -10;
     public float goDepth = 0.3f;
     private Vector3 v3ViewPort = Vector3.zero;
     private Vector3 v3BottomLeft = Vector3.zero;
     private Vector3 v3TopRight = Vector3.zero;
 
     void Start ()
     {
         norlmalScale = gameObject.transform.localScale;
 
         goDepth = Camera.main.nearClipPlane;
         distance = Camera.main.transform.position.z;
         v3ViewPort.Set(0, 0, distance);
         v3BottomLeft = Camera.main.ViewportToWorldPoint(v3ViewPort);
         v3ViewPort.Set(1, 1, distance);
         v3TopRight = Camera.main.ViewportToWorldPoint(v3ViewPort);
         maxScale = new Vector3(v3BottomLeft.x - v3TopRight.x, v3BottomLeft.y - v3TopRight.y, goDepth);
     }
 
     void OnMouseDown()
     {
         if (objectMaximised)
         {
             gameObject.transform.localScale = norlmalScale;
         }
         else
         {
             gameObject.transform.localScale = maxScale;
         }
         objectMaximised = !objectMaximised;
     }
 }
Comment
Add comment · Show 5 · 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 MarkedMaps · Jun 17, 2016 at 04:15 AM 0
Share

ialt text

Ah what to do here? The script seems to have no errors, and i placed it on a JavaScript and C#.

Nothing pops out on this, thanks!

capture.png (8.0 kB)
avatar image TBruce MarkedMaps · Jun 17, 2016 at 04:31 AM 1
Share

This is one of your scripts navigateenemy.

You need to make sure that the name of the class and the file match exactly (this includes case).

In other words, in the case of my example above, the name of my file is

 ToggleObjectScale.cs

which matches the class name exactly.

avatar image MarkedMaps TBruce · Jun 17, 2016 at 05:10 AM 0
Share

That is awesome! It does work, amaze~! Is there a way where if i click on it, it'll go to a different camera, and it'll be a click and point?

Basically, the screen just enlarges and my character can still look around and not be on the screen. Thanks~!

Show more comments

Follow this Question

Answers Answers and Comments

59 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 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 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

How To Show a Question UI Canvas After Collider ? 1 Answer

not run app again when read nfc tag 0 Answers

Help, Losing lives too easily 1 Answer

Unity Package Manager Error 0 Answers

AI walk around and flashlight stop 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