tech/metaverse

21/09/10 TextureImporter and cubemap

tech-lover 2021. 9. 10. 17:55

https://docs.unity3d.com/ScriptReference/TextureImporter.html

 

Unity - Scripting API: TextureImporter

Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close

docs.unity3d.com

https://forum.unity.com/threads/change-the-texture-shape-via-script.471261/

 

Change the texture shape via script ?

Hey there ! I'm making an Editor script in order to tranfsorm my textures into Cubemap materials, I'm ok with it excepted for the texture shape that...

forum.unity.com

```

  1. // Getting textures
  2. var textures = Selection.GetFiltered(typeof(Texture), SelectionMode.Assets).Cast<Texture>();
  3. foreach (var tex in textures)
  4. {
  5.         //  Texture path
  6.         string path = AssetDatabase.GetAssetPath(tex);
  7.              
  8.  
  9.         // If the texture dimensions is not "Cube", we convert it
  10.         TextureImporter importer = (TextureImporter)TextureImporter.GetAtPath(path);
  11.         if (tex.dimension != UnityEngine.Rendering.TextureDimension.Cube)
  12.         {
  13.             importer.textureShape = TextureImporterShape.TextureCube;
  14.             importer.SaveAndReimport();
  15.         }
  16. }
  17.  

```

 

https://docs.unity3d.com/Manual/class-Cubemap.html

 

Unity - Manual: Cubemaps

Cubemaps Switch to Scripting A Cubemap is a collection of six square textures that represent the reflections on an environment. The six squares form the faces of an imaginary cube that surrounds an object; each face represents the view along the directions

docs.unity3d.com

https://docs.unity3d.com/ScriptReference/Cubemap.html

 

Unity - Scripting API: Cubemap

Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close

docs.unity3d.com