Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


OpenAsset

Opens the asset with the specified EntityId in its associated application, optionally at a line.
Read time 3 minutesLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor.CoreModule

OpenAsset(EntityId, int)

Opens the asset with the specified EntityId in its associated application, optionally at a line.
public static bool OpenAsset(EntityId entityId, int lineNumber)

Parameters

entityId

The EntityId of the asset to open.

lineNumber

The line to open a text editor at, if the application supports it. The default value is -1, which opens the file at the start.

Returns

Type

Description

boolTrue if the asset opened successfully. Otherwise, false.

Remarks

Unity opens the asset in an external editor, image application, or modeling tool, depending on the type of asset.

OpenAsset(int, int)

Opens the asset with the specified instance ID in its associated application.
Warning
Removed. Please use OpenAsset(EntityId, int) with the EntityId parameter type instead.
public static bool OpenAsset(int instanceID, int lineNumber)

Parameters

instanceID

The instance ID of the asset to open.

lineNumber

The line to open a text editor at, if the application supports it.

Returns

Type

Description

boolTrue if the asset opened successfully. Otherwise, false.

Remarks

This overload is obsolete. Use the overload that takes an EntityId instead.

OpenAsset(EntityId, int, int)

Opens the asset with the specified EntityId in its associated application, at a line and column.
public static bool OpenAsset(EntityId entityId, int lineNumber, int columnNumber)

Parameters

entityId

The EntityId of the asset to open.

lineNumber

The line to open a text editor at, if the application supports it.

columnNumber

The column to open a text editor at, if the application supports it.

Returns

Type

Description

boolTrue if the asset opened successfully. Otherwise, false.

Remarks

Unity opens the asset in an external editor, image application, or modeling tool, depending on the type of asset.

OpenAsset(int, int, int)

Opens the asset with the specified instance ID in its associated application.
Warning
Removed. Please use OpenAsset(EntityId, int, int) with the EntityId parameter type instead.
public static bool OpenAsset(int instanceID, int lineNumber, int columnNumber)

Parameters

instanceID

The instance ID of the asset to open.

lineNumber

The line to open a text editor at, if the application supports it.

columnNumber

The column to open a text editor at, if the application supports it.

Returns

Type

Description

boolTrue if the asset opened successfully. Otherwise, false.

Remarks

This overload is obsolete. Use the overload that takes an EntityId instead.

OpenAsset(Object, int)

Opens an asset object in its associated application, optionally at a line.
public static bool OpenAsset(Object target, int lineNumber)

Parameters

target

The asset object to open.

lineNumber

The line to open a text editor at, if the application supports it. The default value is -1, which opens the file at the start.

Returns

Type

Description

boolTrue if the asset opened successfully. Otherwise, false.

Remarks

Unity opens the asset in an external editor, image application, or modeling tool, depending on the type of asset.

Examples

using UnityEditor;using UnityEngine;public class AssetDatabaseExamples : MonoBehaviour{ [MenuItem("AssetDatabase/Manually Check Textures")] static void OpenAssetExample() { for (var i = 0; i < 10; i++) { var texturePath = AssetDatabase.LoadMainAssetAtPath($"Assets/Textures/GroundTexture{i}.jpg"); if(!EditorUtility.DisplayDialog($"Open next texture", $"Open GroundTexture{i}.jpg texture?", "Yes", "Cancel")) break; AssetDatabase.OpenAsset(texturePath); } }}

OpenAsset(Object, int, int)

Opens an asset object in its associated application, at a line and column.
public static bool OpenAsset(Object target, int lineNumber, int columnNumber)

Parameters

target

The asset object to open.

lineNumber

The line to open a text editor at, if the application supports it.

columnNumber

The column to open a text editor at, if the application supports it.

Returns

Type

Description

boolTrue if the asset opened successfully. Otherwise, false.

Remarks

Unity opens the asset in an external editor, image application, or modeling tool, depending on the type of asset.

OpenAsset(Object[])

Opens multiple assets with their associated applications.
public static bool OpenAsset(Object[] objects)

Parameters

objects

An array of asset objects to open.

Returns

Type

Description

boolReturns true if all assets opened successfully.

Remarks

Opens the assets in an external editor, texture application or modelling tool depending on what type of asset it is.