← Todas las publicaciones
post21 de abril de 2026
Estructura de Clases en C# para Unity
#csharp#unity#architecture

csharp
using UnityEngine;
public class PlayerController : MonoBehaviour
{
// 1. Serialized fields (Inspector-visible)
[SerializeField] private float moveSpeed = 5f;
[SerializeField] private float jumpForce = 8f;
// 2. Private state
private Rigidbody _rb;
private bool _isGrounded;
// 3. Unity lifecycle
private void Awake() { _rb = GetComponent<Rigidbody>(); }
private void Update() { HandleInput(); }
private void FixedUpdate() { ApplyMovement(); }
// 4. Private helpers
private void HandleInput() { /* ... */ }
private void ApplyMovement() { /* ... */ }
}