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

Converting Texture to Cube Map? C#

Discussion in 'Scripting' started by Sir_Kondziu, Dec 20, 2013.

  1. Sir_Kondziu

    Sir_Kondziu

    Joined:
    Feb 22, 2013
    Posts:
    3
    Hello,
    I am trying to load a texture from a folder outside of the project (which works) and apply it to a material that is attached to skybox, which takes cubemap (RenderFX/Skybox Cubed Material Type). Here is my code that doesn't work

    Code (csharp):
    1.            
    2. string url =  "file://" + Application.dataPath.ToString() + "/Textures_Here/" + SkyboxName.ToString();
    3.  
    4. TexturLoading = new WWW (url);
    5. WaitForTexture();
    6. SkyboxMat.SetTexture("_Cube", TexturLoading.texture);
    7.  
    If I would make the material type "Diffuse" and in SetTexture I would set "_MainTex", it would work but it would set whole texture to each side. So I need cubemap.

    Anyone know way around it? Can I somehow convert the loaded texture to a cubemap?

    Thank you
    - Konrad
     
    Last edited: Dec 20, 2013
  2. JuanAntonio

    JuanAntonio

    Joined:
    Jan 4, 2013
    Posts:
    7
    You must use SkyboxMat.SetTexture("_Tex", TextureLoading.texture);