Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Time of Day - Dynamic Sky Dome

Discussion in 'Assets and Asset Store' started by andererandre, Mar 4, 2013.

  1. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    This is much more esoteric, but I've been looking at TOD_Time, and I don't suppose minutes are separately tracked anywhere? I'm using it as the main timer for my game, and it would be incredibly useful to be able to message another method every time the minute was incremented.
     
  2. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Since upgrading my unity 5 beta project to use the very latest version of Time Of Day, I seem to have a problem with moonlight. I dont think the colour of the actual directional light is being changed to the colour specified for moon light, it stays black. Worked ok on previous versions.
     
  3. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    TOD_Sky.Instance.Cycle.DateTime.X where X can be any of those: http://msdn.microsoft.com/en-us/library/system.datetime(v=vs.110).aspx

    I multiply the light color with the light intensity now since in Unity 5 the specular highlights don't fade out all that nicely for high reflectivity objects otherwise. This is due to the fact that a high reflectivity object writes incredibly high brightnesses to a pixel - which uses the light color for its calculation and appears to multiply the resulting color with the light intensity afterwards. If you imagine a brightness value of 1000 falling off over the course of a few seconds it becomes clear that this leads to a very harsh transition. Can you try increasing the moon light intensity and see if the color brightens up then?

    Teaser for the next update: I found and fixed a few issues with the moon position calculation and made the moon phase calculate automatically from the sun and moon position. I also changed the rendering order of sun and moon to allow for eclipses. Here's a screenshot of the eclipse of 1999-08-11:


    This also means sun/moon constellations like that one can happen now:
     
  4. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    Awesome, thank you! :)
     
  5. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Many thanks for the swift response. Yes, messing with the intensity fixed the problem.
     
  6. joeconstable97

    joeconstable97

    Joined:
    Jul 30, 2013
    Posts:
    49
    O: Yes! That would be awesome! :D
     
  7. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Is there a way to adjust the effect of TOD_Weather on light intensity?

    My problem is when it is stormy and overcast, it's too dark. The light intensity basically fades down to 0.

    I can see that you adjust light intensity in LightAtWeather.cs based upon weatherType. It appears all you are doing is fading the light intensity to zero over time.

    Do you have settings somewhere that I am missing that would allow me to set the effect of the weather types on light intensity? If not can you tell me what I can change to reduce the effect of weather types on light intensity.

    Thanks
    Allan
     
    Last edited: Dec 19, 2014
  8. SarperS

    SarperS

    Joined:
    Mar 10, 2009
    Posts:
    823
    How can I get more colorful dawn and dusk transitions? I would prefer my light to become more red/orange -ish.

    Also I've encountered a bug regarding clouds and sent you an email through your website.
     
  9. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    LightAtWeather only affects the light sources you assign the script to - the Time of Day prefab itself doesn't use it, it's only meant to be used on your own light sources. The sun light source intensity depends on the fogginess value. TOD_Weather sets fogginess to 1 for the storm weather type. This means all you're left with is ambient light in that scenario. If you feel like it's too dark you have to either increase the ambient light intensity in the inspector of TOD_Sky or modify the value in TOD_Weather.

    In the TOD_Sky inspector adjust Light.Coloring, Light.SkyColoring etc.
     
  10. lightassassin

    lightassassin

    Joined:
    Mar 29, 2013
    Posts:
    45
    Mmm... I would like to report what I think is a bug. However, I am unsure which asset to point my finger at accusingly and shouting "J'accuse!". So... you're first I guess =D

    Running 4.6.1f1 with both Time of Day and Marmoset Skyshop. They appear to run in unity in Unity (nasty pun), except that when I enable Auto-Update for Skyshops probes the clouds animation stops. This occurs both in Editor playmode and Standalone builds for PC/Mac and Linux (yay multitest).

    Recreation is easy, drop TOD prefab in scene, create Skyshop Manager and enable the Auto-apply in Game or Auto-apply in Editor settings and hit play. Disabling the options and hitting play again the clouds will animate once again. And for extra fun, while running in playmode if you change the Clouds quality to another setting and back again.... they work.

    So yeah, it breaks when auto-apply is on from skyshop. I have a family and friends playtest christmas eve so I haven't looked at the offending scripts (guessing TOD_Animation and SkyshopManager) so not even sure where to suggest to look sorry.

    For now, on awake I am just going to switch quality settings so that nobody notices :)
     
  11. SarperS

    SarperS

    Joined:
    Mar 10, 2009
    Posts:
    823
    Those values only effect the dome colors I guess, I want to change the light color which is cast onto my 3D world.
     
  12. mittense

    mittense

    Joined:
    Jul 25, 2013
    Posts:
    168
    Maybe I just have a case of the dumbs, but I can't seem to get the fog working under Unity 5. Is there a trick to this?

    Edit: Maybe it just doesn't work under deferred rendering?
     
    Last edited: Dec 22, 2014
  13. Morfeuskiev

    Morfeuskiev

    Joined:
    Oct 10, 2013
    Posts:
    122
    Hi. Two question:
    1) Why you use folder with name Assets? It has sometime conflict with two folders with the same name (Project folder Assets and your folder Assets). For example when i add my old project in Unity with Time of Day.
    2) Your Sunshaft method has name TOD_Rays, but c# script has name TOD_Sunshaft. It is not work. When i rename c# script to TOD_Rays - it work.

    In near past you talked about upgrade visual quality for Cloud. Do you have any information about this?

    Thank you! With Best regards, Leonid.
     
  14. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    You have to add the sky dome layer to the "ignored layers" of skyshop: http://i.imgur.com/94TTxhg.png

    On a related note, I recommend using Unity 5 image-based lighting for a completely native workflow that fully supports dynamic lighting conditions. Skyshop is not meant to be used with dynamic lighting, so you'll always run into issues with a dynamic day / night cycle.

    Light.Coloring affects the light color towards sunset and sunrise, not the sky. You can also adjust the light base color with Sun.LightColor.

    Works fine here. Make sure to use b14 or later - I recommend b18.

    EDIT: I just realized that you're probably not aware of the fact that Unity 5 deferred lighting requires you to add the "Global Fog" image effect to your camera in order to see fog. It's no longer applied directly in the deferred pass.

    The "Assets" folder is a subfolder of the "Time of Day" folder - so there shouldn't be any issues with that.

    Please make sure to delete the old folder before upgrading to a new version - I changed the file name, but if you override the files Unity doesn't apply those changes.

    I'll most likely add horizon clouds with 2.4.
     
  15. lightassassin

    lightassassin

    Joined:
    Mar 29, 2013
    Posts:
    45
    Thanks plzdiekthxbye that fixed it. Yeah I'd like to be using U5 but RTP isn't updated to work with it yet and terrain lightmap baking has issues. I have even got my textures ready for U5 (I export all the texture maps so I am covered no matter what I use) just incase but Skyshop will have to do the job with 4.6.
     
  16. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    Hello. Recently started a project in Unity, was looking for some kind of realistic time simulation, and came across your program. The fact that it looks so fantastic, along with the fact that it still has strong support, made me decide to pick this up.

    Ran into an issue though, that isn't so much your fault but I guess the fault of the method I'm using to control the game. However, you may know of a solution since it involves your program (and I'll admit, I'm a dunce with it comes to this stuff).

    I tied the "Sky Dome" to the main camera like you said. However, the way my game character is set up, horizontal movement is tied to the character "model" (it's nothing more than an invisible mesh), and the game camera is a child of the character. As a result, when I move horizontally, the skybox moves too. As I said this isn't really a problem with the asset but more a problem with my method--but do you happen to have a solution for this? If so, thanks, if not I'll get it figured out.

    And one more thing, that DOES seem like an issue with the asset: when I move the center of my viewpoint outside of the game environment and up in the air, or over the edge of the map, I get a black hexagon in the center of the screen, with an occasional white hexagon over it flickering.

    I haven't had the chance to look through the thread yet, I intend to, but I wanted to ask about this in case it's either new or something you can explain quickly. Thanks for any help.
     
  17. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Not sure if I understand this correctly. The way the setup should be is that the sky dome is always centered relative to the camera - i.e. no matter what you do to the camera, the sky dome should never move relative to the camera. This is done by the TOD_Camera script.

    This seems like a far clip plane issue - try adjusting the far clip plane scale factor on TOD_Camera. If that's not it a screenshot would be great.
     
  18. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    Oddly, looks like the issue for this was that I didn't even have the TOD_Camera script on my camera. I didn't see instructions in the PDF to use it. Got it on the camera now and there is no black dot. Thanks.

    it's not moving relative to the camera. it's moving relative to the character. I have a camera as a child of the character. The character controls horizontal rotation (I mistakenly said movement, I meant rotation--moving the mouse to the left or right), and the camera controls vertical rotation.

    Now, when I move the camera up and down, it works fine. Does what it's supposed to. But when I move the "camera" (though in reality it's the character--there's a MouseLook on the character restricted to the X axis) left and right, the sky dome moves too.

    I tried to upload a video stored in both a zip and a 7z file type. The file is 2.81 MB, but when I try to upload it says the file is too large for the server. And FormatFactory produces terrible gifs...so I can't show you. I'll try uploading the files again later.

    But anyway. I'm getting around it by applying a script preventing rotation to the sky dome. It works for the most part, though horizontal movement still has a noticeable delay where it moves, then shifts back to normal. So It's kind of working, though I need a way to totally prevent rotation.
     
  19. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Did you make the sky dome a child object of either the camera or the character? Because it shouldn't be. All sky dome movement is supposed to come from TOD_Camera - i.e. the sky dome should never rotate.
     
  20. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    Hmm...yeah, I made it a child of the camera. I can't check right now as I'm working, but I thought the PDF manual said to do so.

    It seemed weird at the time, and I was thinking about asking about it (because it means the sky dome is centered on the character no matter where you go), but I didn't yet.

    So you're saying I should simply put the sky dome on the top layer--same as all other basic assets? And then use the TOD_Camera script on my character's camera? I just want to understand clearly what I should do to fix this.

    Edit: I'm an idiot. Major reading comprehension fail on my part. I reread the documentation and it says to do what you just said. For some reason I read it as placing the sky dome as a child of the camera. *smacks forehead*

    Thank you for your help.
     
    Last edited: Dec 27, 2014
  21. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    I have a question for you. another when i get off of my phone, which doesn't like long posts here it seems.

    For the moment, I'm using Unity's basic water. I want to change to something better in the future, that for instance actually has an "underwater" part to it. but i'm here for now. so, unity's water's color is based on the game horizon, and in the settings for the water you're supposed to
    pick the color based on that. i'm wondering if there's a place in your asset's settings that outputs the color, and if it does i could modify the water script to reference that for the color.
     
    Last edited: Dec 30, 2014
  22. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    There are multiple properties and methods that might be interesting for this:
    • RenderSettings.fogColor
    • RenderSettings.ambientLight
    • TOD_Sky.Instance.SampleSkyColor()
    • TOD_Sky.Instance.SampleHorizonColor()
     
  23. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    Great, thank you.

    As for my other issue, my problem was that at night my entire terrain is just black. However, I just realized, while messing around, that this is because the "Ambient Color" under the "Night" settings is black. it can be changed to something else.

    However, this is not realistic. Most nights offer some light, and the moon in particular reflects quite a bit of light.

    So I guess I'm asking is if I'm "stuck" with a completely black terrain? Or is there some other setting that can modify this (maybe adding a directional light to the Moon, but this wouldn't solve moon-less night problem)?
     
  24. vrpostcard

    vrpostcard

    Joined:
    Feb 24, 2013
    Posts:
    33
    Just want to say that I set up TOD in a test application for a visualisation system I am writing for work. I configured the environment to suit Sydney Australia and after setting the time and date to match the actual time, I looked outside my office window and saw that the actual sun and moon locations matched what was on the computer screen.

    TOD is an awesome application. Thanks.
     
  25. Goofy420

    Goofy420

    Joined:
    Apr 27, 2013
    Posts:
    248
    How can I get the weather to change with the date or time? I don't see any documentation on the class.

    atm resorted to a crappy hack but I could have sworn the asset did it through the month or moon phase.
    Code (CSharp):
    1. random -= Time.deltaTime;
    2.         if (random < 0) random = 30f;
    3.         if (random - skytime.skyTime > 1.0f && random - skytime.skyTime < 1.1f)
    4.         {
    5.             weather.Weather = Random.value < .5 ? TOD_WeatherType.Clear : TOD_WeatherType.Storm;
    6.         }
     
    Last edited: Dec 31, 2014
  26. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    I apologize for bothering you again, but:

    I'm trying to use the above to reference a certain time of day in Unity. Basically, the beginning of my if/then statement (C#) looks like this:

    Code (CSharp):
    1. internal TOD_Time Time;
    2.  
    3.     // Use this for initialization
    4.     void Start () {
    5.         Time      = GetComponent<TOD_Time>();
    6.     }
    7.  
    8.     // Update is called once per frame
    9.     void Update () {
    10.  
    11.         if (TOD_Time >= sky.Cycle.DateTime.
    12.  
    First off, is this how I would go about it? or is there another method to call a specific time?

    And if this IS the method--you mention that X can be anything at that link. However, everything at the link uses a different format, with DateTime(yyyy, m, d, h, m, s). There are none of the periods you use. So how would you convert the code to your method?
     
  27. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    The directional light switches to the moon position if the sun is not visible. You can adjust Moon.LightIntensity to ramp up your terrain brightness.

    Awesome - great to hear that the calculations work on the other side of the world as well! The sun and moon position should be accurate within 1-2 degrees, which was good enough for the couple of eclipse dates I tested to yield positions that made sense.

    What you probably meant were the example scripts that allow you to enabled and disable particles, lights, sounds and renderers at a certain weather. There's never been an example to randomize the weather settings or to adjust them when a specific date has been reached. This could be something I provide in a future update though - what exactly would you like a script like that to do? Just randomize the weather? Maybe according to the season / temperature?

    X can be Year, Month, Day, Hour, Minute, Second and Millisecond. It's all part of the C# DateTime struct I linked to. If I remember correctly what you were trying to do initially was access the current minute of the hour. TOD_Sky.Instance.Cycle.DateTime.Minute returns exactly that: http://msdn.microsoft.com/en-us/library/system.datetime.minute(v=vs.110).aspx

    TOD_Sky.Instance.Cycle.DateTime can also be compared to a different DateTime instance directly via the <, > and == operators. For more examples on how to use DateTime have a look at this article: http://www.dotnetperls.com/datetime

    That being said, the code you posted makes me think you don't know all that much about scripting in general. Please understand that this is not the right place for beginners to learn scripting - there are excellent tutorials available for that.
     
  28. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    Thank you very much for the help. i definitely don't know much about scripting--the first script i've ever written was in the last few days (i guess i've written code in mathmatica and sigmaplot but that's hardly applicable). steep learning curves don't concern me, however, and i've been looking at tutorials elsewhere as well. but if i ask things that are too basic and should be covered elsewhere (my question about DateTime was about the syntax of its usage, that might be applicable), please tell me so.
     
    Last edited: Dec 31, 2014
  29. EvilTak

    EvilTak

    Joined:
    Feb 4, 2014
    Posts:
    61
    @plzdiekthxbye Is it possible for you to provide either a webplayer or a demo video showcasing the cloud shadows? I have been looking for something like that in many such dynamic weather assets which advertise this feature, but the effect is not noticeable. Also, does the package have Realtime GI support in Unity 5? This package would be a great alternative to the standard procedural skybox!
     
  30. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    The forums don't allow video uploads, but I'll send you a download link of a video via PM. The new demo scene I've been working on isn't done yet, but it will showcase them as well.

    Yes, all the Unity 5 lighting features are supported.
     
  31. EvilTak

    EvilTak

    Joined:
    Feb 4, 2014
    Posts:
    61
    Thank you @plzdiekthxbye! Are there any plans for 3d or volumetric clouds in Time of Day, or is it going to be just 2d clouds for the sake of performance?
     
  32. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    The current plan is to add support for horizon clouds in 2.4 (which is the way GTA and Red Dead Redemption do their clouds - basically just blending different artist-created cloud textures on billboard-like quads and light them in a realistic way) since those are cheap to render and lead to very convincing results. They are also very artist-friendly and can therefore be adjusted to fit any art style from comic to realistic.

    I implemented ray marched volumetric clouds as a test a while ago but wasn't quite satisfied with them both visually (compared to for example GTA 5) and performance-wise. They are amazing for flight simulators, but they're certainly not the best fit for every type of game. I'm still planning to have another look at fully volumetric clouds in the future, but probably not in the 2.x cycle.
     
    Sir-Spunky likes this.
  33. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,632
    So we might get a way of coloring the Quantum Theory Metaclouds? I'd like that. Especially if we can get sunrise / sunset and night time coloring right.
     
  34. danger726

    danger726

    Joined:
    Aug 19, 2012
    Posts:
    180
    Hi, after upgrading to 2.3.4 I noticed that the "ProgressTime" variable has gone. Is there any other way to disable time progressing that I might have missed? If not, could it be reinstated?

    Thanks!
     
  35. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Disabling the TOD_Time script is the recommended way of doing this as of 2.3.4.
     
  36. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    401
    If you want very nice water, especially for Time of Day cycling, I would very highly recommend SUIMONO. I have been using this for a long time now. It has been going through 2.0 beta for some time but worked throughout the process and is very very good. See for yourself.

    www.assetstore.unity3d.com/en/#!/content/4387

    This water looks stunning with the light rendering of Time of Day.
     
  37. toreau

    toreau

    Joined:
    Feb 8, 2014
    Posts:
    204
    I just bought Time of Day, and I'm both impressed and happy with it so far. I'm having a few questions though, based on the multiplayer FPS I'm working on:

    The game is server-auth, which means that it should be impossible for the clients to cheat the TOD cycle, i.e. not be able to have daytime all the time on their side. Instead of creating a state on the server, which would have meant send over TOD-data all the time (unless I've missed something), I push the TOD-data to each client every Xth second and update these client variables with the corresponding server variables;
    • Cycle.Ticks
    • Moon.Phase
    • Components.Animation.CloudUV
    While this works just fine, I'm wondering if it's optimal?

    The other thing I'm wondering about is why it's realistic that every player has its own "sky dome"? This means that every player - no matter where on the 6x6 square km map they are, have exactly the same sun, moon, clouds etc. relative to them. What if I for example want to add fog to a player's "view" when he/she enters a specific part of the map? How would I go about achieving that?

    Thanks in advance for your reply, and keep up the good work!
     
  38. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    In the latest version Moon.Phase is calculated from the date - so syncing that is no longer required.

    I wouldn't maintain multiple sky domes for every player. Can't you sync the time and clouds from a single server sky dome to all clients? Clouds are automatically offset according to the sky dome world position if Animation.WorldSpaceCloudUV is enabled. That means Animation.CloudUV can be looked at as the cloud state at world origin. Time is presumably also the same for all players.

    Regarding other manipulations: it's probably best to manage that in a separate script altogether. If the fog depends on the world position, syncing the world position alone will be enough and simply calculate the fog from that on the client. If you do want to calculate something like fog density for every single player on your server I'd still do it completely independent from Time of Day. Something I should mention is that Time of Day does not adjust any fog parameters other than the color (if enabled) - so fog is kind of a completely separate thing anyhow and probably shouldn't be mangled together with the time or cloud state sync.
     
  39. toreau

    toreau

    Joined:
    Feb 8, 2014
    Posts:
    204
    ...and the latest version is the one that is out on the Asset Store now, right? If so, thanks; that saves me 8 bits on each update. :)

    I think you misunderstood me: each player has only one sky dome, of course. The server also has one, and that is the one everyone is sync'ed from. Now that I know of the Animation.WorldSpaceCloudUV setting, that part isn't a problem, luckily.

    Also, the stuff about the fog clears things up for me.

    Thanks!
     
  40. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    I just submitted 2.3.5 for review by the Asset Store team. It's a fix-only release and if everything goes according to plan it will be the last release of the Time of Day 2.x cycle.

    I spent most of my holidays working on Time of Day 3.0.0 and I'm excited to announce that it's close to being done. I started the internal testing phase today and expect to release it to the public towards the end of January.

    3.0.0 will bring major changes to Time of Day. First of all I switched to a new and improved atmospheric scattering model that includes multiple scattering and planet shadowing. A new per-pixel sky quality mode (per-vertex will still be supported) lets the sky dome calculate some parts of the atmospheric scattering for every pixel instead of every vertex, allowing for much higher sky contrasts without seeing the individual triangles of the sky dome. I also implemented efficient dynamically batched and smoothly lit horizon clouds that will contribute to the overall vastly enhanced cloud visuals. Further improvements include sky-only tonemapping for Unity Indie users, which will greatly help the visual quality of projects that cannot use full HDR rendering, and uncountable code changes and refactors to ensure high paced and efficient development on Time of Day for years to come.

    Time of Day 3.0.0 will support the latest versions of Unity 4 and Unity 5. Dropping support for Unity 3 meant that I could get rid of outdated code and improve various aspects of both the internals and editor and UI integration.
     
    Sir-Spunky, elbows, OnePxl and 2 others like this.
  41. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    401
    Thank you very much for this excellent system.

    This may be a little late in the process but I have a persistent time system linked in nicely to Time of Day if you would like. For the database I use Easy Save 2 but any database can be linked/coded in by the developer (tested with MySQL, SQLite, iBoxDB, and Easy Save 2 <= fastest and easiest). The code is free for anyone wanting this. Since Time of Day is kind of a 'Time Keeper' it would be nice if this/these features were included.

    Your forum so let me know if you are interested or if I may post the code here for others to use.

    Cheers
    Olander
     
    hopeful and OnePxl like this.
  42. danger726

    danger726

    Joined:
    Aug 19, 2012
    Posts:
    180
    Aha, got ya, thanks!
     
  43. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    Github?
     
  44. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    What's the interaction of your persistent time system and Time of Day like? Is it just reading and writing Cycle.DateTime?

    I think it's a good idea to upload it to GitHub. I haven't quite decided if I want to include something like that out of the box (especially if it's nicely separated and can easily be distributed to those who are interested) as most users probably won't need it. Building up a community around Time of Day with some open source extensions also seems like a good plan for the future.
     
    elbows likes this.
  45. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    401
    Well then. I shall simply post it here for any whom wish it. This is simply not large enough for a GitHub. This is simply a wonderful donation to an already wonderful system.

    Since my gFunction.cs script is quite large I shall only keep what is necessary for the persistence and other handy functions. These DB functions will obviously function for much more than just time since the functions are quite flexible for anything really.

    My scripts, as always, are quite tidy and very easy to read. You should have no troubles.

    Again...I wholly recommend for Unity Easy Save 2 since it is very reliable and fast. Also for a modest $20 US
    (tested with MySQL, SQLite, iBoxDB, and Easy Save 2 <= fastest and easiest)
    www.assetstore.unity3d.com/en/#!/content/768

    Note: I have not updated to the latest Time of Day. My version is 2.3.1 .... I will be updating to the very latest once it is updated on the Asset Store. TOD_Time may be slightly different....but it should be a simple matter to make the necessary minor changes (Step 5 below).

    Steps to make any type of consistent persistence to function in Unity. This is very simple.
    1) _GameData <= this is an empty scene object that houses any functions or data that 'things' will need access to. This also means synchronizing data between scenes or between sessions and multi-player as well.
    - gFunctions.cs & gTime.cs are components to this object.

    2) Download the script called => gFunctions.cs and drag it into Unity. Then drag this onto _GameData
    **Configuring Time and Date is very simple. Near the top of this script are all the configurations. Please note I have the month set to 28 days. You can easily compress or extend time as you desire as well as change the time on the fly. There are also easy to change language options. I have provided Sindarin (Grey Elven) and English. Time is also set to Strings as well to make using in GUIs very simple.

    3) Download the script called => gTime.cs and drag it into Unity. Then drag this onto _GameData
    **This is where Time is calculated, syncronized, and updated to Time of Day (TOD_Time.cs)

    4) Now Open TOD_Time.cs go down to line 177ish change that to this:
    **The void Start() section is added

    Code (CSharp):
    1. protected void Awake()
    2.     {
    3.         sky = GetComponent<TOD_Sky>();
    4.  
    5.         ApplyTimeCurve();
    6.     }
    7.      
    8.     void Start ()
    9.     {
    10.         //Get Time Script in _GameData
    11.         gFunctions = GameObject.Find ("_GameData").GetComponent<gFunctions>();
    12.     }  
    13.  
    14.     protected void OnEnable()
    15.     {
    16.         skyTime = sky.Cycle.Hour;
    17.     }
    5) Still in TOD_Time go to the Update area and make the following changes to it:

    Code (CSharp):
    1. protected void Update()
    2.     {
    3.         //From gFunctions.cs Persistent Time Controller
    4.         DayLengthInMinutes = gFunctions.fDayLengthMinutes;
    5.         ProgressTime = gFunctions.bTimeProgress;      
    6.      
    7.         float oneDay  = DayLengthInMinutes * 60;
    8.         float oneHour = oneDay / 24;
    9.                                  
    10.         sky.Cycle.Hour = gFunctions.fHourCurrent;
    11.         sky.Cycle.Day = gFunctions.nDayCurrent;
    12.         sky.Cycle.Month = gFunctions.nMonthCurrent;
    13.         sky.Cycle.Year = gFunctions.nYearCurrent;
    14.  
    15.         if (ProgressTime)
    16.         {
    17.             //AddTime(Time.deltaTime / oneHour, true);
    18.         }
    19.         else
    20.         {
    21.             CheckTimeRange();
    22.         }
    23.  
    24.         if (ProgressMoonPhase)
    25.         {
    26.             AddMoon(Time.deltaTime / (30*oneDay) * 2);
    27.         }
    28.         else
    29.         {
    30.             CheckMoonRange();
    31.         }
    32.     }
    And that is it. Time is now working perfectly and controlling the Sun/Moon with persistence.

    Cheers and Regards,
    Olander
     

    Attached Files:

  46. kashiftasneem

    kashiftasneem

    Joined:
    Aug 24, 2012
    Posts:
    15
    Hello, I am running on iOS. Shaders are not compiling, I am getting the following logs in Xcode:

     
  47. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    I cannot reproduce this with the latest Unity 4 on my iPhone 5. Can you post more information about your project?
    - Which version of Unity are you using?
    - Which version of iOS are you building for?
    - Which iOS device are you trying to run on?
    - Does it work in a new project with just the sky dome and a camera?
     
  48. kashiftasneem

    kashiftasneem

    Joined:
    Aug 24, 2012
    Posts:
    15
    Thank you for replying, it worked on a new project so I deleted its contents from my old project and reimported it and everything is fine now :)
     
  49. AADProductions

    AADProductions

    Joined:
    Aug 16, 2012
    Posts:
    30
    Hello - I'm using TOD 2.0.5 in Unity 4.6.1p3. Really great product and I've had no issues at all except one - someone playing on Linux recently sent me this:


    The specs they provided were:
    Steam OS (Linux)
    AMD FX 8350
    Nvidia GTX 780
    16 GB RAM

    I'm wondering if you have any theories off the top of your head. I can't seem to reproduce this issue on Windows. Thanks.
     
  50. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Oh wow, that's a new one. We have quite a few Linux users in our game as well - and while everything else tends to break for some of them, we haven't gotten any reports about Time of Day I know of. Can you create a new project with just Time of Day in it, compile a Linux standalone build and send it to him as a test? I was planning to setup a Steam OS intall myself in the near future, but it would be great to verify that the issue isn't related to some other part of your project first.

    Just to be safe - you probably meant to write TOD 2.3.5 not 2.0.5, correct?