GUISkin.FindStyle 查找样式

function FindStyle (styleName : string) : GUIStyle

Description描述

Try to search for a GUIStyle. This functions returns NULL and does not give an error.

试图搜索一个GUIStyle。这个函数返回NULL,不给错误信息。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public string aStyleName = "A Style I have";
	void OnGUI() {
		if (GUI.skin.FindStyle(aStyleName) == null)
			Debug.LogWarning("No style named \"" + aStyleName + "\" could be found");

	}
}
// Checks if a style name exists
//检查是否存在一个样式名称

var aStyleName : String = "A Style I have";

function OnGUI() {
	if(GUI.skin.FindStyle(aStyleName) == null) {
		Debug.LogWarning("No style named \"" + aStyleName + "\" could be found");
	}
}
Page last updated: 2011-1-25