Variables
Lights
List<Light> lights
List of all lights in the scene.
The first light (element 0) is controlled by the application, rotation and intensity will be overridden if changed externally.
Camera
Camera camera
Camera which the preview is captured.
Methods
CreateSceneObject
public GameObject CreateSceneObject(string name)
Returns a new empty scene GameObject with the provided name
Returns
GameObject
Parameters
Name | Type | Description |
---|---|---|
name | string | name of the object to be created |
AddSceneObject
public void AddSceneObject(GameObject go)
Moves a GameObject to the preview scene view
Parameters
Name | Type | Description |
---|---|---|
go | GameObject | GameObject which is to be moved to the preview scene |
GetPreview
public Texture GetPreview(int width, int height)
Returns a RenderTexture of the preview scene camera, with the resolution of the width x height
of input
Returns
RenderTexture
Parameters
Name | Type | Description |
---|---|---|
width | int | Width of the output texture |
height | int | Height of the output texture |
GetPreview (static)
public static Texture GetPreviewTexture(int width, int height, UltimateIconPreviewSettings settings)
Returns a RenderTexture of a instanced scene, using the provided UltimateIconPreviewSettings, with the resolution of the width x height
of input
Example
var scenePrev = UltimateIconPreviewScene.GetPreviewTexture(256, 256, new UltimateIconPreviewSettings()
{
cameraFOV = 20,
cameraPosition = new Vector3(0, 0, -16),
gameObject = GameObject.CreatePrimitive(PrimitiveType.Cube),
cameraCullingMask = LayerMask.GetMask("TransparentFX")
});
// Pulling the render texture into a Texture2D (can be pulled into the file)
var sceneTex = new Texture2D(256, 256, TextureFormat.ARGB32, false, true);
RenderTexture.active = scenePrev as RenderTexture;
sceneTex.ReadPixels(new Rect(0, 0, 256, 256), 0, 0);
sceneTex.Apply();
//Applying texture to a render texture
Graphics.CopyTexture(sceneTex, renderTexture);
Returns
RenderTexture
Parameters
Name | Type | Description |
---|---|---|
width | int | Width of the output texture |
height | int | Height of the output texture |
settings | UltimateIconPreviewSettings | Setting of how the scene and objects should be rendered |