答案 0 :(得分:0)
要在检查器中显示属性/变量,它们必须为public
,如果它们不是它们不会出现。
您还可以通过将private fields
归为[SerializedField]
来查看[Serializable]
。
要在检查器中查看自定义类,您应将其标记为[HideInInspector]
。
要隐藏检查员的公共变量,请使用[System.NonSerialized]
或public class SomePerson : MonoBehaviour
{
//This field gets serialized because it is public.
public string name = "John";
//This field does not get serialized because it is private.
private int age = 40;
//This field gets serialized even though it is private
//because it has the SerializeField attribute applied.
[SerializeField]
private bool hasHealthPotion = true;
// This will be displayed in inspector because the class has Serialized attribute.
public SomeCustomClass somCustomClassInstance;
// This will not be shown in inspector even if it is public.
[HideInInspector]
public bool hiddenBool;
// Same with this one.
[System.NonSerialized]
public int nonSerializedVariable = 5;
}
[System.Serializable]
public class SomeCustomClass
{
public string someProperty;
}
属性。
以下是一个示例:
<script>
$(function () {
$('input[type=radio]').on('click', function () {
var value = $(this).attr('value');
console.log(value);
if ($(this).is(':checked')) {
// alert("it's checked");
console.log("it's checked");
}
});
});
</script>