Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity render to texture2d

public static void ExportTexture2D(int w, int h) {
  Texture2D outputTexture = new Texture2D(w, h);
  Rect rect = new Rect(0, 0, outputTexture.width, outputTexture.height);
  
  RenderTexture rt = RenderTexture.GetTemporary(texture.width, texture.height);
  RenderTexture.active = rt;
  
  outputTexture.ReadPixels(rect, 0, 0);
  outputTexture.Apply(false); // do not apply mipmaps
  outputTexture.Compress(true); // compress with high quality
  
  RenderTexture.active = null;
  RenderTexture.ReleaseTemporary(rt);
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to get an arrays length in c# 
Csharp :: c# string to float 
Csharp :: unity guid to object 
Csharp :: c# tostring decimal 2 places 
Csharp :: convert uint to int C# 
Csharp :: group by unique c# 
Csharp :: should i learn c # 
Csharp :: parametrizedthreadstart C# 
Csharp :: carousel asp.net mvc beginner 
Csharp :: c# check if array contains value 
Csharp :: destroy gameobject with tag unity 
Csharp :: C# trim trailing zero 
Csharp :: unity get prefabs from folder 
Csharp :: remove item from list in for loop c# 
Csharp :: unity how to create a prefab 
Csharp :: c# datetime remove days 
Csharp :: c# singleton 
Csharp :: sieve of eratosthenes 
Csharp :: c# if isset 
Csharp :: calculator in c# 
Csharp :: remove duplicates in the list using linq 
Csharp :: c# generic return type in interface 
Csharp :: c# access substring 
Csharp :: double parse csharp removes decimal 
Csharp :: read json from assets c# 
Csharp :: asp c# page scroll position change after postback 
Csharp :: How to create a Blazor server-side application in command prompt 
Csharp :: concatanate two lists in c# 
Csharp :: multi case in c# 
Csharp :: c# loop through queue 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =