Forum rules - please read before posting.

Changing a camera's skybox material using ActionList?

edited October 2015 in Technical Q&A
I've been through the tutorials on a creating a custom ActionList, but I'm unable to create a script that successfully changes a skybox's material. Has anyone managed this?




Comments

  • Oh, and here's the code I used. C# newbie :(

  • edited October 2015
    Close.  You've declared "newSkybox" as a GameObject, whereas it should be a Material.  You'll have to update this definition in ShowGUI(), too.

    Finally, in Run() you're not checking for the Skybox component in obToAffect.  But you could instead declare obToAffect as a Skybox, so that it's not necessary.
  • Thanks Chris!
  • edited October 2015
    Success. Here's the final ActionList code I ended up with:


    I also had to add a script to MainCamera so that the skybox material would be copied over to the GameCamera (per another thread in the Forum):


    Appears to work!
  • Hi,

    I need to change the Skybox material in an Action Script as this older topic does, but I have tried the linked code and found I cant get it to work. The Custom Action of Change Skybox appears in the Unity editor, and I have attached the added script above and attached to the MainCamera, but nothing happens.

    What might I be doing wrong? Perhaps Unity has updated to the point this code no longer works, I am using Unity 5.6. I half remember Skybox's materials used to be set on Camera but are now in the Lighting Tab - Could that be part of my issue?

    Thanks
  • I half remember Skybox's materials used to be set on Camera but are now in the Lighting Tab - Could that be part of my issue?

    I'd say so.  This thread seems to show the new way to change a skybox at runtime.

    This new way should do without the need for any script on the MainCamera - just a custom Action.  For a tutorial on writing custom Actions, see here.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.