Skip to main content

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

NameTypeDescription
namestringname of the object to be created

AddSceneObject

public void AddSceneObject(GameObject go)

Moves a GameObject to the preview scene view

Parameters

NameTypeDescription
goGameObjectGameObject 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

NameTypeDescription
widthintWidth of the output texture
heightintHeight 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

NameTypeDescription
widthintWidth of the output texture
heightintHeight of the output texture
settingsUltimateIconPreviewSettingsSetting of how the scene and objects should be rendered