Version: 2021.3

ObjectNames.NicifyVariableName

切换到手册
public static string NicifyVariableName (string name);

描述

为变量创建可显示的名称。

此函数将在大写字母之前插入空格,并删除名称之前的可选 m__k(后跟大写字母)。

using UnityEngine;
using UnityEditor;

public class Example : MonoBehaviour { private void Start() { // prints "My Variable" print(ObjectNames.NicifyVariableName("MyVariable")); // prints "The Other Variable" print(ObjectNames.NicifyVariableName("m_TheOtherVariable")); // prints "Some Constant" print(ObjectNames.NicifyVariableName("kSomeConstant")); } }