Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
3
Question by BHS · Mar 30, 2015 at 03:53 PM · unity 5scripting problemlightingskyboxrendersettings

Add Light Source to Sun in Environmental Lighting with Unity 5 by Script?

I've checked all the API with Unity 5, and unless I'm missing something, I can't seem to find out how to add a light source to the Skybox Sun under the Lighting part of Unity.

Is there another way to go about this? How could I achieve this if there is no way to access it?

I would like to choose, by script and on start, what light source to add according to the light source added in the editor.

RenderSettings doesn't contain any sun related words. I have tried everything, unless it's accessed somewhere else.

If it's not possible, why would Unity not make this visible? It seems like something someone might want to have access to.

Any info would be greatly appreciated.

Comment
Add comment · Show 7
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 alan-lawrance · Apr 22, 2015 at 04:50 AM 0
Share

Not only is it not possible to set through scripting, the Sun isn't even saved when you save the scene.

avatar image MarkHenderson · Apr 29, 2015 at 09:47 PM 1
Share

Note: I did a bit of testing on the saving issue: a directional light in a prefab instance will not save, but a directional light NOT in a prefab instance will save properly.

Just submitted a bug report regarding this to Unity.

avatar image rageingnonsense · Apr 29, 2015 at 10:55 PM 0
Share

The sun in the default skybox is controlled by the direction of the directional light in the scene. You can see this in the editor by manually rotating the directional light.

I have a feeling I am misunderstanding the question though.

avatar image MarkHenderson · Apr 30, 2015 at 12:42 AM 0
Share

If the sun isn't set manually, it auto maps to the brightest directional light. If you have a day/night cycle with an additional directional light for the moon, then as soon as your moon is brighter than your sun the sky suddenly changes to day.

For basically any day/night sky system, we need to be able to set the sun from script. Blindly relying on the brightest directional light to be the sun only works during daytime.

avatar image BHS · May 09, 2015 at 01:25 AM 0
Share

Any update on this?

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by NathanWarden · Jul 11, 2016 at 10:43 PM

This is what I did since it automaps to the brightest light so that it wouldn't break my day/night cycle.

1) Parented another directional light under my sun light and called it "DummyEnvironmentLight". 2) Zeroed out Position and Rotation values so it will always be oriented exactly the same as my sun light. 3) Cranked up the intensity to 8. 4) Set the culling mask to Nothing.

Unity picks it up as the sun even though it will never affect anything. It also works in a prefab.

Hope this helps somebody :)

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 Stormy102 · Aug 28, 2016 at 09:19 PM

Guys if you vote here we might be able to get this in 5.4.x! https://feedback.unity3d.com/suggestions/option-to-set-sun-light-via-script

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

26 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

Related Questions

Unity terrain lights up at night 1 Answer

Skybox lighting not working and causing weird issues 0 Answers

new project aren't set up right 1 Answer

Change Ambient Color in Unity 5 via script? 1 Answer

Input System gets inputs only once then stops. 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