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 MARKUS · Nov 09, 2011 at 12:59 AM · waterunderwater

createing a underwater java script ArgumentException: get_fog.

i am getiing two error the first one is

ArgumentException: get_fog can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. underwater..ctor () (at Assets/Standard Assets/Water (Basic)/underwater.js:15)

the second one is

UnityEngine.RenderSettings:get_fog() underwater:.ctor() (at Assets\Standard Assets\Water (Basic)\underwater.js:15)

the script i have done so far is

function Update () { }//This script enables underwater effects. Attach to main camera.

//Define variables

var underwaterLevel = 102.8067;

// Enable fog RenderSettings.fog = true;

//The scene's default fog settings private var defaultFog; private var defaultFogColor : Color; private var defaultFogDensity : float; private var defaultSkybox : Material; var noSkybox : Material;

function Start () {

 defaultFog = RenderSettings.fog;
 defaultFogColor = RenderSettings.fogColor;
 defaultFogDensity = RenderSettings.fogDensity;
 defaultSkybox = RenderSettings.skybox;

//Set the background color camera.backgroundColor = Color (0, 0.4, 0.7, 1); }

if (transform.position.y < underwaterLevel) {

RenderSettings.fog = true;

RenderSettings.fogColor = Color (0, 0.4, 0.7, 0.6);

RenderSettings.fogDensity = 0.04;

RenderSettings.skybox = noSkybox;

}

else {

RenderSettings.fog = defaultFog;

RenderSettings.fogColor = defaultFogColor;

RenderSettings.fogDensity = defaultFogDensity;

RenderSettings.skybox = defaultSkybox;

}

ANY HELP TO GET RID OF THESE ERRORS WILL BE VERY APPRIECATED

THANKS VERY MUCH IF YOU NEED TO ASK ANY QUESTIONS JUST ASK AHEAD

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
0

Answer by aldonaletto · Nov 09, 2011 at 01:09 AM

You scrambled the code lines. The correct order should be:

//This script enables underwater effects. Attach to main camera.

//Define variables

var underwaterLevel = 102.8067;

//The scene's default fog settings private var defaultFog; private var defaultFogColor : Color; private var defaultFogDensity : float; private var defaultSkybox : Material; var noSkybox : Material;

function Start () { defaultFog = RenderSettings.fog; defaultFogColor = RenderSettings.fogColor; defaultFogDensity = RenderSettings.fogDensity; defaultSkybox = RenderSettings.skybox; //Set the background color camera.backgroundColor = Color (0, 0.4, 0.7, 1); }

function Update () { if (transform.position.y < underwaterLevel) { // Enable fog RenderSettings.fog = true; RenderSettings.fogColor = Color (0, 0.4, 0.7, 0.6); RenderSettings.fogDensity = 0.04; RenderSettings.skybox = noSkybox; } else { RenderSettings.fog = defaultFog; RenderSettings.fogColor = defaultFogColor; RenderSettings.fogDensity = defaultFogDensity; RenderSettings.skybox = defaultSkybox; } }

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

underwater fog script 1 Answer

need water 1 Answer

Underwater effect question 2 Answers

Underwater Effect 1 Answer

underwater shader 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