将 string 表示为 int 以实现高效查找和比较。这可用于常用的 PropertyName。
在内部仅存储 int 来表示 string。PropertyName 可以从 string 进行创建,但是无法转换回 string。相同 string 始终产生表示该 string 的相同 int。因而,当您只需进行比较时,这在内存和速度方面都是非常高效的 string 表示。
PropertyName 可序列化。
实现 ToString() 的目的只是为了进行调试,它在 Editor 中返回“theName:3737”,在播放器中返回“Unknown:3737”。
PropertyName | 使用 string 初始化 PropertyName。 |
Equals | 确定此实例和指定对象(也必须是 PropertyName 对象)是否具有相同值。 |
GetHashCode | 返回此 PropertyName 的哈希代码。 |
ToString | 仅用于调试。在 Editor 中返回表示字符串的 string 值。 在播放器中返回“UnityEngine.PropertyName”。 |
IsNullOrEmpty | 指示指定 PropertyName 是否为空 string。 |
operator != | 确定两个指定 PropertyName 是否具有不同 string 值。 |
operator == | 确定两个指定 PropertyName 是否具有相同 string 值。因为使用相同 string 值初始化的两个 PropertyName 始终具有相同索引,所以我们只需执行两个 int 的比较即可查明 string 值是否相等。 |
PropertyName | 转换传入 PropertyName 的 string。另请参阅:PropertyName.ctor(System.String)。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.