Hiển thị Inspector dựa vào biến Public của Script

Dong Ho · about 1 min read

Hiển thị Inspector dựa vào biến Public của Script

  • Biến Public hoặc có đánh dấu [SerializeField] (những private) sẽ được hiển thị ở Inspector
  • Kiểu List sẽ hiển thị một section Collapse
      public List<GameObject> m_VisualWheels;
    
  • Kiểu khởi tạo luôn một “struct” và “struct” đó phải là “[System.Serializable]” thì sẽ hiển thị là một section Collapse
      [System.Serializable]
      public struct Stats
      {
          [Header("Movement Settings")]
          [Min(0.001f), Tooltip("Top speed attainable when moving forward.")]
          public float TopSpeed;
    
          [Tooltip("How quickly the kart reaches top speed.")]
          public float Acceleration;
            
          [Range(0.2f, 1)]
          public float AccelerationCurve;
    
          //...
      }
    
      public ArcadeKart.Stats baseStats = new ArcadeKart.Stats // <--- Section Collapse
      {
          TopSpeed            = 10f,
          Acceleration        = 5f,
          AccelerationCurve   = 4f
          // ...
      };
    
  • Kiểu LayerMask sẽ hiển thị một option-select các Layers
      [Tooltip("Which layers the wheels will detect.")]
      public LayerMask GroundLayers = Physics.DefaultRaycastLayers;
    
Outline

history cached

play_arrow arrow_right_alt

update skip_next

create close

settings arrow_downward

×

Memo

...
×

Under Maintenance