だから、ここにコードがあることはできません。ここでユニティEditorGUI.PropertyFieldは完全に無効に配列またはList
// ReadOnlyAttribyte,cs
public class ReadOnlyAttribute : PropertyAttribute
{
}
// ReadOnlyDrawer.cs
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
public class ReadOnlyDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property,
GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, label, true);
}
public override void OnGUI(Rect position,
SerializedProperty property,
GUIContent label)
{
GUI.enabled = false;
EditorGUI.PropertyField(position, property, label, true);
GUI.enabled = true;
}
}
// test
[System.Serializable]
public class GridObjectData : ScriptableObject
{
[ReadOnly]
public int ID;
[ReadOnly]
public List<GridCell> Grid;
}
は、私たちは([読み取り専用]によって、すべてのマークを無効にすることができ、簡単なカスタム属性と属性の引き出しです)フィールドをGUIで無効にすることができます。リストの要素は無効になっていますが、リストのサイズはGUIではまだ有効です。どうすればそれを修正できますか?
ありがとうございます。
更新: それインスペクタでlooks
あなたの答えをありがとう!しかし、何ができるだろうか?何とかリスト全体を描くことを禁じることはできますか? – PaveL
Listまたは配列を使用していないが、それをラップする別のカスタムタイプを使用する以外は、何かできることに慣れていません。 –
ありがとうございました!私は正しい答えとしてそれを取るよ! – PaveL