Version: 5.6
public static Object LoadRequired (string path);

描述

加载所需的内置资源。

此函数将在 Assets/Editor Default Resources/ 文件夹中查找 所需资源。下面的示例显示了 iPhone 纹理的加载过程, 用于为立方体添加纹理。

using UnityEngine;
using UnityEditor;

public class LoadRequiredExample { [MenuItem("Examples/LoadRequired Editor Example")] static void loadRequiredExample() { Texture tex = (Texture)EditorGUIUtility.LoadRequired("BuildSettings.iPhone");

Renderer r = GameObject.Find("Cube").GetComponent<Renderer>(); r.sharedMaterial.mainTexture = tex; } }