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 /
avatar image
0
Question by CaveGames · Jun 08, 2017 at 07:36 PM · raycastmouseclickfullscreenfull screen

UnityEngine.Screen does not contain a definition for 'fullscreen'

It's been a whole two weeks now with my fullscreen bug, and it seems that no one cares anymore, and I can't seem to figure it out myself, now I have updated my code to better fit the toggle button, and I get a total of 13 errors in this order:

A 'using' directive can only be applied to namespaces but 'UnityEngine.Screen' denotes a type. Consider using a 'using static' instead "Line 4"

Feature 'using static' cannot be used because it is not part of the C# 4.0 language specification "Line 4"

Unexpected symbol 'public', expecting ',' or ';' "Line 5"

The contextual keyword 'var' may only appear within a local variable declaration "Line 15"

'UnityEngine.Screen' does not contain a definition for 'fullscreen' "Line 15"

'UnityEngine.Screen' does not contain a definition for 'fullscreen' "Line 16"

'UnityEngine.Screen' does not contain a definition for 'fullscreen' "Line 17"

The left hand side of an assignment must be a variable, a property or an indexer "Line 26"

The left hand side of an assignment must be a variable, a property or an indexer "Line 27"

The left hand side of an assignment must be a variable, a property or an indexer "Line 28"

'UnityEngine.Screen' does not contain a definition for 'fullscreen' "Line 31"

'UnityEngine.Screen' does not contain a definition for 'fullscreen' "Line 32"

'UnityEngine.Screen' does not contain a definition for 'fullscreen' "Line 33"

Errors are killing me slowly, but here is the code so you can possibly help:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class FullscreenToggle : MonoBehaviour
 {
     // Use this for initialization
     void Start()
     {
 
     }
 
     // Update is called once per frame
     void Update()
     {
         if (!Screen.fullscreen)
         {
             if (Input.GetMouseButtonDown(0))
             {
                 RaycastHit hit;
                 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                 if (Physics.Raycast(ray, out hit, 100.0f))
                 {
                     //Replace this with whatever logic you want to use to validate the objects you want to click on
                     if (hit.collider.gameObject.tag == "Toggle")
                     {
                         !Screen.fullScreen = Screen.fullScreen;
                     }
                 }
             }
         }
         if (Screen.fullscreen)
         {
             if (Input.GetMouseButtonDown(0))
             {
                 RaycastHit hit;
                 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                 if (Physics.Raycast(ray, out hit, 100.0f))
                 {
                     //Replace this with whatever logic you want to use to validate the objects you want to click on
                     if (hit.collider.gameObject.tag == "Toggle")
                     {
                         Screen.fullScreen = !Screen.fullScreen;
                     }
                 }
             }
         }
     }
 }

Not to be rude or anything, but someone please answer this question this time, this is my fourth time I've asked a question related to my games fullscreen bug and not a single person has replied. And at this point I'm done. >:-(

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Jawchewa · Jun 08, 2017 at 08:06 PM

I'm not sure about all the errors at the beginning with the using statements. I think that might be an issue with your Unity setup, but the code itself looks syntactically correct. Although, I think I can help you with your fullscreen issue.

On lines 16 and 32, the issue is that you are trying to access Screen.fullscreen. The problem is that the "s" in fullscreen has to be capitalized. Change it to Screen.fullScreen instead.

Your issue on line 27, is that you have the exclamation symbol in the wrong place. It should look more like this:

                      Screen.fullScreen = !Screen.fullScreen;

Hope this at least helps with part of your problem.

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 CaveGames · Jun 08, 2017 at 08:14 PM 0
Share

@Jawchewa thank you for fixing my fullscreen bug, it no longer says fix all errors before running. BUT! When i built the game, it still did not go fullscreen, no matter how many times I clicked, please help, if you can

avatar image Jawchewa CaveGames · Jun 08, 2017 at 08:30 PM 0
Share

I think the issue here is that it is hitting your first block of code, which sets fullscreen to true, and by the time it hits the second block of code that checks if it is already true, it is immediately setting it back to false. The easiest solution would be to simply replace the if (Screen.fullScreen) with an else statement, so that it doesn't immediately fire afterwards.

However, the way your code is set up now seems kind of redundant to me. The two parts inside of the main ifs seem like they are doing the exact same thing. If I were you, I would get rid of the second part entirely, by changing your update to something like this:

     void Update()
     {
         if (Input.Get$$anonymous$$ouseButtonDown(0))
         {
             RaycastHit hit;
             Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
             if (Physics.Raycast(ray, out hit, 100.0f))
             {
                 //Replace this with whatever logic you want to use to validate the objects you want to click on
                 if (hit.collider.gameObject.tag == "Toggle")
                 {
                     Screen.fullScreen = !Screen.fullScreen;
                 }
             }
         }
     }
avatar image CaveGames Jawchewa · Jun 08, 2017 at 09:39 PM 0
Share

@Jawchewa thank you for the fix, but it's still not working! I did everything you told me to except for the else statement due to getting rid of the second statement. Since that the code is all the same, I'll send you an image of the toggle, If there is anything wrong here, it would be great to know!

https://pasteboard.co/gdmHc2H9G.jpg

Show more comments
avatar image
0

Answer by CaveGames · Jun 09, 2017 at 12:33 AM

@Jawchewa thank you for helping me, it now turns on, but was is the command for turning it off? I chose to no longer have toggle and replace it with on/off, and the on works, but the off doesn't. If you have an answer, and it works, I will tell you.

Comment
Add comment · Show 2 · 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 Jawchewa · Jun 09, 2017 at 01:48 AM 0
Share

Well, with the toggle, it should just set it to whatever state it isn't currently in, so you would just have to click it twice to turn it on and off. I think it should be doing that already. If you want to split it into two parts, you will need to split it into two parts, so

                  Screen.fullScreen = true;

will set it to fullscreen, and

                  Screen.fullScreen = false;

should change it back to windowed.

avatar image CaveGames Jawchewa · Jun 09, 2017 at 12:28 PM 0
Share

@Jawchewa it still doesn't work! Granted, the on button works, and that is not a problem anymore, but the off doesn't! I have it all set up, in the way you wanted, but in separate scripts titled FullscreenOn and FullscreenOff, and they both have no errors, except that when I built the latest alpha, it would turn on but wouldn't turn back off!

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

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

Set Fullscreen With Raycast 0 Answers

User Layer that Ignores Raycast? 2 Answers

How do I use Input.GetButton, instead of OnMouse() 1 Answer

raycast mouse detects any object 1 Answer

Click or Drag but not both 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