Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

AQUAS Water/River Set - Water & Rivers for Mobile, VR, Web, Desktop

Discussion in 'Assets and Asset Store' started by dogmachris, Jan 8, 2016.

  1. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Hi Chris,

    I have an issue with Caustics being badly or not at all rendered
    For the background: I'm using Aquas with Enviro (Integration with the script they provide, shader updated as required) and Megasplat (I disabled Tess / Parallax in case that would be the issue but it's not)

    Here is a video of the issue:


    Basically the Caustics are no where to be seen except if I find an angle somehow to get it right and then they are flickering

    I tried also to disable Enviro completely, change the shader back without the Enviro integration
    Also disabled my terrain and added one completely flat without megasplat shader and I can't see the caustics at all

    I suspect I'm missing a setting somewhere that creates this issue..

    As seen in my video, in Scene mode the Caustics appears

    I'm on Unity 2017.4.2f2 with Forward rendering setup.
     
  2. TakeRefugeGames

    TakeRefugeGames

    Joined:
    Dec 9, 2017
    Posts:
    11
    Cheers, Very Much!
     
  3. erenaydin

    erenaydin

    Joined:
    Mar 1, 2011
    Posts:
    384
    Finally Unity 2018.1 out It's not working properly, I hope you check those small shader errors soon.
     
    jasonwaltersxyz likes this.
  4. CodeyLC

    CodeyLC

    Joined:
    May 5, 2018
    Posts:
    2
    This worked for me in Unity 2018.2.0b1. Found the AQUA_AddDefine.cs file in Assets > Editor, replaced all of the code with the provided below, removed the V1 Post Processor Definition from Edit > Project Settings > Scripting Define Symbols*.

    So far it runs without generating errors and alerts.

    Thank you!



     
    erenaydin likes this.
  5. erenaydin

    erenaydin

    Joined:
    Mar 1, 2011
    Posts:
    384
    You didn't get any shader errors? Hmm, I guess i need to re-check
     
    StormchaserZA likes this.
  6. CodeyLC

    CodeyLC

    Joined:
    May 5, 2018
    Posts:
    2
    I haven't noticed any yet, but neither have I gotten far enough in building to notice.
     
  7. NeonTheCoder

    NeonTheCoder

    Joined:
    Feb 1, 2014
    Posts:
    40
    So Just wondering will you add support for the scriptable render pipeline? For the 2018.1 update or a later one?
     
  8. jasonwaltersxyz

    jasonwaltersxyz

    Joined:
    Jul 16, 2014
    Posts:
    24
    All I did was remove Post Processing V1 from the `Scripting Define Symbols`. And to resolve the pink shader error with caustics, I followed the author's tip (posted last Friday) and disabled the `PrimaryCausticsProject` & `SecondaryCausticsProjector` child objects of `AQUAS Waterplane`.
     
  9. dogmachris

    dogmachris

    Joined:
    Sep 15, 2014
    Posts:
    1,375
    @erenaydin @Rastapastor @Worban @hopeful

    I have just submitted an update for the most critical issues (pink patches and post processing errors). With a bit of luck it should be live within a day or two. Basically what it does is, it fixes the issue where AQUAS is unable to update the scripting define symbols, by adding an additional compiler condition, so that the error messages can't pop up, before AQUAS has updated the define symbols. That should solve the issue for almost all configurations.

    As for the pink rendering:
    In Unity 2018 AQUAS will automatically disable caustics when entering game mode. It is optional to keep them enabled though. This is a temporary solution until the shader has been reworked (which I am already at).

    Other warnings and error messages:
    Upon initial import one might get a list of warnings and potential errors from shaders other than the caustics. They will disappear when the shaders are reworked, however they are nothing beyond tedious - from what I have seen so far, they are harmless, you should be fine just clearing the console once.
     
  10. Pescu

    Pescu

    Joined:
    Jun 7, 2014
    Posts:
    17
    Hello with the fast setup i get the border of the water violet, seems that PrimaryCausticsProjector and secondary are both violet. I'm using unity 2018.1.
    When i imported the AQUAS assets i also get those errors.
    "Shader error in 'AQUAS/Camera Effects/Wet Lens': syntax error: unexpected token ';' at line 220 (on d3d11)
    Shader error in 'AQUAS/Desktop and Web/Double-Sided/Double-Textured': syntax error: unexpected token ';' at line 460 (on d3d11)
    Shader error in 'AQUAS/Desktop and Web/Double-Sided/River': syntax error: unexpected token ';' at line 577 (on d3d11)
    Shader error in 'AQUAS/Caustics': syntax error: unexpected token ';' at line 142 (on d3d11)"

    https://imgur.com/ci7amGx
     
  11. Alienmadness

    Alienmadness

    Joined:
    Sep 6, 2012
    Posts:
    109
    Same here.
     
  12. PRNuser

    PRNuser

    Joined:
    May 28, 2013
    Posts:
    4
    Can I use ”UnderWaterCameraEffects” on mobile.
     
  13. StormchaserZA

    StormchaserZA

    Joined:
    Nov 13, 2016
    Posts:
    30
    Hey Chris,

    Firstly THANK YOU for your hard work in getting this puppy 2018 ready. I do however have a little issue if you don't mind looking:

    Assets/AQUAS/Scripts/AQUAS_Gaia.cs(373,86): error CS1061: Type `AQUAS_Parameters.UnderWaterParameters' does not contain a definition for `defaultProfile' and no extension method `defaultProfile' of type `AQUAS_Parameters.UnderWaterParameters' could be found. Are you missing an assembly reference?
     
  14. Pescu

    Pescu

    Joined:
    Jun 7, 2014
    Posts:
    17
    Hey Chris,
    thanks for the update, with the version 1.5.1 no more errors on import, and works fine.
     
  15. wolfnet18

    wolfnet18

    Joined:
    Jul 31, 2014
    Posts:
    15
    I need assistance. I'm not getting any error messages but i'm also not getting this to work properly. If I follow the tutorial, and add the underwater effects to my character that has a camera attached to him, the underwater doesn't work correctly. If i add the underwater effects directly to the camera, underwater works fine but then the entire screen is just pink above water.
     
  16. dogmachris

    dogmachris

    Joined:
    Sep 15, 2014
    Posts:
    1,375
    Have you tried disabling the caustic projectors?
     
  17. dogmachris

    dogmachris

    Joined:
    Sep 15, 2014
    Posts:
    1,375
    Glad it seems to work on your side - for now. It is only a temporary fix that removes the critical issues to allow developers to go on developing. I am currently reworking the shaders to have the issues permanently fixed.
     
  18. dogmachris

    dogmachris

    Joined:
    Sep 15, 2014
    Posts:
    1,375
    Bummer - forgot to change that too. You might just remove the "UNITY_POST_PROCESSING_STACK_V2" from the scripting define symbols and see if that works.
     
    StormchaserZA likes this.
  19. dogmachris

    dogmachris

    Joined:
    Sep 15, 2014
    Posts:
    1,375
    Yes you can - but I would not recommend it - image effects are generally a bit too much for mobile hardware.
     
  20. dogmachris

    dogmachris

    Joined:
    Sep 15, 2014
    Posts:
    1,375
    AQUAS 1.5.1 went live just yesterday - that should help - for now - does it?
     
  21. Alienmadness

    Alienmadness

    Joined:
    Sep 6, 2012
    Posts:
    109
    yes it worked, i had an error but i remarked this out:

    //#if UNITY_POST_PROCESSING_STACK_V2


    // underwaterObj.GetComponent<AQUAS_LensEffects>().underWaterParameters.underwaterProfile = (PostProcessProfile)AssetDatabase.LoadAssetAtPath("Assets/AQUAS/Post Processing/AQUAS_Underwater_v2.asset", typeof(PostProcessProfile));

    // underwaterObj.GetComponent<AQUAS_LensEffects>().underWaterParameters.defaultProfile = (PostProcessProfile)AssetDatabase.LoadAssetAtPath("Assets/AQUAS/Post Processing/DefaultPostProcessing_v2.asset", typeof(PostProcessProfile));

    //#endif
     
  22. luis29vm

    luis29vm

    Joined:
    Oct 25, 2016
    Posts:
    164
    Hi, I just purchase your Aquas Asset and I get in clean project and in my main project same error:

    NullReferenceException: Object reference not set to an instance of an object
    AQUAS.AQUAS_RemoveDefine.OnWillDeleteAsset (System.String assetPath, RemoveAssetOptions rao) (at Assets/Editor/AQUAS_RemoveDefine.cs:17)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    UnityEditor.AssetModificationProcessorInternal.OnWillDeleteAsset (System.String assetPath, RemoveAssetOptions options) (at /Users/builduser/buildslave/unity/build/Editor/Mono/AssetModificationProcessor.cs:226)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  23. PRNuser

    PRNuser

    Joined:
    May 28, 2013
    Posts:
    4
    Thank you!
     
  24. Alienmadness

    Alienmadness

    Joined:
    Sep 6, 2012
    Posts:
    109
    Assets/AQUAS/Scripts/AQUAS_LensEffects.cs(93,22): error CS0102: The type `AQUAS_LensEffects' already contains a definition for `postProcessing'

    Assets/AQUAS/Scripts/AQUAS_Parameters.cs(32,35): error CS0102: The type `AQUAS_Parameters.UnderWaterParameters' already contains a definition for `underwaterProfile'

    Assets/AQUAS/Scripts/AQUAS_Parameters.cs(33,35): error CS0102: The type `AQUAS_Parameters.UnderWaterParameters' already contains a definition for `defaultProfile'

    i still get these on a 2018.1 project
     
  25. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    151
    Anyone know why do I get this error message?
    Code (CSharp):
    1. Destroying GameObjects immediately is not permitted during physics trigger/contact, animation event callbacks or OnValidate.
    2. You must use Destroy instead.
    3. UnityEngine.Object: DestroyImmediate(Object)
    4. AQUAS_Reflection:OnDisable() (at Assets/Shaders/AQUAS/Scripts/AQUAS_Reflection.cs:139)
    5. UnityEngine.GameObject:SetActive(Boolean)
    I need to deactivate level parts and water to avoid fps drops.
     
  26. AlienMe

    AlienMe

    Joined:
    Sep 16, 2014
    Posts:
    93
    Hi @dogmachris, having an issue, hope you can help.

    Using AQUAS version 1.5.1 Upgraded to Unity 2018.1, and now all AQUAS surfaces are pink. Got several shader compile errors, and the shaders are not available from the Shader Menu.

    I read earlier in this thread to ignore the compiler errors, but the pink water doesn't go away.

    Appreciate any help. Thanks!

    upload_2018-5-9_14-20-52.png

    upload_2018-5-9_14-19-5.png
     
    MAKE-A-GAME-COM likes this.
  27. wolfnet18

    wolfnet18

    Joined:
    Jul 31, 2014
    Posts:
    15

    Logged in today and this is what mine also looked like. This is the second time this has happened, and only happens after I save and exit the project.... The last time it happened a day ago i had to delete the water and even reimport Aquas to fix. Today that did not work and everything is still pink. I'm assuming Aquas does not like something with unity currently
     

    Attached Files:

  28. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Hi, Apologies if this as been asked or mentioned before but I cannot find anything about the issue.

    When I try to do a build the build fails because of a compiler error in the LensEffects.cs script:

    Here are all the errors, some may not apply to the same script error though.

    Assets/AQUAS/Scripts/AQUAS_LensEffects.cs(132,68): error CS0103: The name `AssetDatabase' does not exist in the current context

    Error building Player because scripts had compiler errors

    Build completed with a result of 'Failed'
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
    at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x0020e] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:181
    at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x00065] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:88
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    Any help solve this much appreciated.

    Thanks.
     
  29. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    not sure why its adding pink faces?
     
  30. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    151
    Stupid emoticons automatically appear when putting a : next to a D f.e.
     
    Hawk0077 likes this.
  31. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    lol, I tried to correct it but it re-added the emotes.
     
    Alvarezmd90 likes this.
  32. arsys

    arsys

    Joined:
    Aug 18, 2017
    Posts:
    4
    I had pink caustics in 2018 (if you go to Shaders menu a lot of them are NOT COMPILING):
    upload_2018-5-11_10-4-9.png

    I solved it yesterday by deleting and reimporting the package, but today it's the same story:

    upload_2018-5-11_10-5-10.png

    Lots of stuff not compiling from AQUAS and Enviro, also from CTS:

    upload_2018-5-11_10-10-34.png

    Hope you solve it as soon as possible... wisely we didn't move our main projects to 2018 yet, these are just tests to see the new PostProcessing
     
    Hawk0077 likes this.
  33. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Thanks for the hint. I was going to upgrade soon.
     
  34. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    So if I use multiple aquas my memory starts to take a hit. What is the best route to use this with world streamer? I also had to switch to an older version because the current version kept freezing my game
     
  35. SSL7

    SSL7

    Joined:
    Mar 23, 2016
    Posts:
    347
    Yeap have the same problem with 1.5.1 and unity 2018 (pink and errors all over the place)... hope for a fix :)
     
  36. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Hi,

    did something changed with the last update? At first it was freezing all the time (script compiling in loop) then I deleted Aquas completely and re-imported it fresh

    Now I get errors in my Aquas-Gaia script

    Unity 2017.4f2

    Image 161.jpg

    Ok found the error issue: in the script define symbols I was missing "AQUAS_PRESENT"

    Fine, but now I have the script compiling loop that freeze the editor every X seconds.

    This "AQUAS_PRESENT" was added with the last patch, and it's not working properly in my case :(
     
    Last edited: May 11, 2018
  37. dogmachris

    dogmachris

    Joined:
    Sep 15, 2014
    Posts:
    1,375
    @Necka_ @dlevel @arsys @AlienMe @Alienmadness @luis29vm

    I have just submitted AQUAS 1.5.2. It should get rid of all errors and warnings. The way AQUAS checks the version of the post processing stack installed has also been altered to avoid errors on startup. The same was also done for the Gaia integration (that I missed last time).

    With a bit of luck the new version might be online early next week.

    @Hawk0077
    I don't know how much else is affected by AQUAS's current status, but I have only now made a build with the 1.5.2 version and got no errors in Unity 5.6 and Unity 2018 so it should also work for all version in-between. Please try it with the new update as soon as it goes live and see if it does the trick.

    Please let me apologize again for the inconvenience folks and thank you very much for being so patient with me.

    As an additional info, here is where I am going to bring AQUAS next:
    The next step for AQUAS will be to rework the shaders to guarantee SRP compatibility. Along with these changes AQUAS will use world space UVs in the future to make it easier to create infinite water and bigger rivers. Single pass stereo support is also on the agenda for the next steps.
     
  38. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Hi,

    but now I'm stuck with the broken version and can't work for the rest of the week

    Can you send me a fix via PM please?*

    Edit: FYI the compiling loop seems to be in place only when Post Processing V2 is in the project
     
    Last edited: May 11, 2018
  39. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    No need to apologize Chris, Thanks for your efforts. Much appreciated.
     
  40. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    151
    And it throws errors when SetActive deactivates a Gameobject with reflection attached. It says: call destroy immediate instead of destroy and the other way around when I made the change. I have no idea how to fix that.
     
  41. arsys

    arsys

    Joined:
    Aug 18, 2017
    Posts:
    4
    Thanks a lot... I'll give it a try and post any news
     
  42. Devistute

    Devistute

    Joined:
    Aug 23, 2014
    Posts:
    32
    Yeah, gotta go without water for next week or so in my project too :)
    Importing Aquas to the project causes the compiler trying to compile.. forever. As mentioned above.
    Spent whole 3 hours wondering that what the frick is going on before trying to delete Aquas :D
    Almost got heart attack of thinking that the project got corrupted.

    If it is possible to get the fixed package via mail or so, that would be awesome.
     
  43. dogmachris

    dogmachris

    Joined:
    Sep 15, 2014
    Posts:
    1,375
    PM me your invoice number, it shouldn't be a problem.
     
  44. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    Helo after importing new version of aquas for 2018.1 I have exceptions in shaders.

    EDIT:
    I noticed that you are waiting for asset store aprrovla for 1.52 where that is fixed.

    But is there any way to get faster that version?
     
    Last edited: May 14, 2018
  45. dogmachris

    dogmachris

    Joined:
    Sep 15, 2014
    Posts:
    1,375
    The new version 1.5.2 is live!
     
    Last edited: May 14, 2018
    cxode likes this.
  46. AlienMe

    AlienMe

    Joined:
    Sep 16, 2014
    Posts:
    93
    @dogmachris, the new version fixed the shader errors. Thanks!
     
  47. lorddesu

    lorddesu

    Joined:
    Aug 20, 2014
    Posts:
    31
    Assets/AQUAS/Scripts/AQUAS_LensEffects.cs(93,22): error CS0102: The type `AQUAS_LensEffects' already contains a definition for `postProcessing'
    Assets/AQUAS/Scripts/AQUAS_Parameters.cs(32,35): error CS0102: The type `AQUAS_Parameters.UnderWaterParameters' already contains a definition for `underwaterProfile'
    Assets/AQUAS/Scripts/AQUAS_Parameters.cs(33,35): error CS0102: The type `AQUAS_Parameters.UnderWaterParameters' already contains a definition for `defaultProfile'

    Still get this lines with Unity 2018.1 + Aquas 1.5.2 from assetstore. Changing define symbols half works for me. I can play demo scene once after changing but then errors comeback.
     
  48. dogmachris

    dogmachris

    Joined:
    Sep 15, 2014
    Posts:
    1,375
    Do you have both versions of the post processing stack imported?
    If not, please look into your project folder (not the asset folder) and have a look at the "Packages" folder. Is anything in there that might be related to the post processing stack v2?
     
  49. wcoastsands

    wcoastsands

    Joined:
    Sep 30, 2011
    Posts:
    44
    This issue occurs in AQUAS v1.5.2 when Post-Processing Stack v1.0.4 AND Cinemachine v2.1.10 exist in the project.

    Please see in AQUAS_AddDefine.cs
    Code (CSharp):
    1.             // PostProcessingProfile.cs exists in v1 of the Post-Processing Stack.
    2.             string[] results = AssetDatabase.FindAssets("PostProcessingProfile");
    3.  
    4.             if (!symbols.Contains("UNITY_POST_PROCESSING_STACK_V1") && results.Length > 0)
    5.             {
    6.                 symbols += ";" + "UNITY_POST_PROCESSING_STACK_V1";
    7.                 PlayerSettings.SetScriptingDefineSymbolsForGroup(group, symbols);
    8.             }
    9.  
    10.             if (symbols.Contains("UNITY_POST_PROCESSING_STACK_V1") && results.Length == 0)
    11.             {
    12.                 symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
    13.  
    14.                 symbols = symbols.Replace("UNITY_POST_PROCESSING_STACK_V1;", "");
    15.                 symbols = symbols.Replace("UNITY_POST_PROCESSING_STACK_V1", "");
    16.                 PlayerSettings.SetScriptingDefineSymbolsForGroup(group, symbols);
    17.             }
    18.  
    19.             // BUG: PostProcessingLayer.png exists in Cinemachine.
    20.             results = AssetDatabase.FindAssets("PostProcessLayer");
    21.  
    22.             if (!symbols.Contains("UNITY_POST_PROCESSING_STACK_V2") && results.Length > 0)
    23.             {
    24.                 symbols += ";" + "UNITY_POST_PROCESSING_STACK_V2";
    25.                 PlayerSettings.SetScriptingDefineSymbolsForGroup(group, symbols);
    26.             }
    27.  
    28.  
    29.             if (symbols.Contains("UNITY_POST_PROCESSING_STACK_V2") && results.Length == 0)
    30.             {
    31.                 symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
    32.  
    33.                 symbols = symbols.Replace("UNITY_POST_PROCESSING_STACK_V2;", "");
    34.                 symbols = symbols.Replace("UNITY_POST_PROCESSING_STACK_V2", "");
    35.                 PlayerSettings.SetScriptingDefineSymbolsForGroup(group, symbols);
    36.             }
    37.  
     
    hopeful likes this.
  50. wcoastsands

    wcoastsands

    Joined:
    Sep 30, 2011
    Posts:
    44
    Here's a potential fix.

    EDIT1: Refactored the following code. There's a catch, though. The script will not execute while there are errors in the assembly. Manually deleting the scripting define symbols in Player settings for AQUAS and the Post Processing Stack allows the script to run.

    EDIT2: I updated the following code again. Instead of removing the AQUAS symbol when the post processing majorVersion is less than 0, the script now removes both post processing symbols.

    EDIT3: Check for post processing symbols before removing and marking dirty. Only set symbols if changes where made to prevent a race condition.

    EDIT4: Removed redundancy.

    Update the AQUAS_AddDefine.cs as follows:
    Code (CSharp):
    1. using System;
    2. using System.Linq;
    3. using UnityEditor;
    4.  
    5. namespace AQUAS
    6. {
    7.     public static class AQUAS_AddDefine
    8.     {
    9.         static readonly string k_PostProcessingNamespaceV1 = "UnityEngine.PostProcessing";
    10.         static readonly string k_PostProcessingNamespaceV2 = "UnityEngine.Rendering.PostProcessing";
    11.  
    12.         static readonly string k_PostProcessingBehaviourName = "PostProcessingBehaviour";
    13.         static readonly string k_PostProcessingLayerName = "PostProcessingLayer";
    14.         static readonly string k_PostProcessingVolumeName = "PostProcessingVolume";
    15.  
    16.         static readonly string k_Symbol_PostProcessingV1 = "UNITY_POST_PROCESSING_STACK_V1";
    17.         static readonly string k_Symbol_PostProcessingV2 = "UNITY_POST_PROCESSING_STACK_V2";
    18.         static readonly string k_Symbol_AQUAS = "AQUAS_PRESENT";
    19.  
    20.         [InitializeOnLoadMethod]
    21.         static void Initialize ()
    22.         {
    23.             // Bug: FindAsset can not reliably determine the existence of a class.
    24.             // Fix: Use reflection to determine the existence of classes,
    25.             //      and guess the major version.
    26.             var majorVersion = GetPostProcessingMajorVersion();
    27.  
    28.             var group = EditorUserBuildSettings.selectedBuildTargetGroup;
    29.             var symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
    30.             var dirty = false;
    31.  
    32.             if (!symbols.Contains(k_Symbol_AQUAS))
    33.             {
    34.                 symbols = symbols.AddSymbol(k_Symbol_AQUAS);
    35.                 dirty = true;
    36.             }
    37.  
    38.             if (!symbols.Contains(k_Symbol_PostProcessingV1) && majorVersion == 1)
    39.             {
    40.                 symbols = symbols.AddSymbol(k_Symbol_PostProcessingV1);
    41.                 dirty = true;
    42.             }
    43.             else if (symbols.Contains(k_Symbol_PostProcessingV1) && majorVersion != 1)
    44.             {
    45.                 symbols = symbols.RemoveSymbol(k_Symbol_PostProcessingV1);
    46.                 dirty = true;
    47.             }
    48.  
    49.             if (!symbols.Contains(k_Symbol_PostProcessingV2) && majorVersion == 2)
    50.             {
    51.                 symbols = symbols.AddSymbol(k_Symbol_PostProcessingV2);
    52.                 dirty = true;
    53.             }
    54.             else if (symbols.Contains(k_Symbol_PostProcessingV2) && majorVersion != 2)
    55.             {
    56.                 symbols = symbols.RemoveSymbol(k_Symbol_PostProcessingV2);
    57.                 dirty = true;
    58.             }
    59.  
    60.             if (dirty) PlayerSettings.SetScriptingDefineSymbolsForGroup(group, symbols);
    61.         }
    62.  
    63.         static string AddSymbol (this string s, string symbol)
    64.         {
    65.             return string.Concat(s, ";", symbol);
    66.         }
    67.  
    68.         static string RemoveSymbol (this string s, string symbol)
    69.         {
    70.             return s.Replace(symbol, "").Replace(";;", ";").Trim(';');
    71.         }
    72.  
    73.         static int GetPostProcessingMajorVersion ()
    74.         {
    75.             if (HasPostProcessingLayer() && HasPostProcessingVolume())
    76.             {
    77.                 return 2;
    78.             }
    79.             else if (HasPostProcessingBehaviour())
    80.             {
    81.                 return 1;
    82.             }
    83.  
    84.             return -1;
    85.         }
    86.  
    87.         static bool HasPostProcessingBehaviour ()
    88.         {
    89.             return TypeExists(k_PostProcessingNamespaceV1, k_PostProcessingBehaviourName);
    90.         }
    91.  
    92.         static bool HasPostProcessingLayer ()
    93.         {
    94.             return TypeExists(k_PostProcessingNamespaceV2, k_PostProcessingLayerName);
    95.         }
    96.  
    97.         static bool HasPostProcessingVolume ()
    98.         {
    99.             return TypeExists(k_PostProcessingNamespaceV2, k_PostProcessingVolumeName);
    100.         }
    101.  
    102.         static bool TypeExists (string namespaceName, string className)
    103.         {
    104.             var fullName = string.Format("{0}.{1}", namespaceName, className);
    105.             var t = (from assembly in AppDomain.CurrentDomain.GetAssemblies()
    106.                      from type in assembly.GetTypes()
    107.                      where type.FullName == fullName
    108.                      select type).FirstOrDefault();
    109.  
    110.             return t != null;
    111.         }
    112.     }
    113. }
    114.  
     
    Last edited: May 16, 2018
    MinimumEntropy and cxode like this.