Home

Published

- 1 min read

Code Highlight

img of Code Highlight

Code Highlighting

Focused // [!code focus]

   public class CustomEvent : UnityEvent<T0> {}
public class CustomEvent : UnityEvent<T0, T1> {}
public class CustomEvent : UnityEvent<T0, T1, T2> {}  
public class CustomEvent : UnityEvent<T0, T1, T2, T3> {}

Highlighting: // [!code highlight], // [!code warning], // [!code error]

   // GameObjectEvent.cs
using System;
using UnityEngine; 
using UnityEngine.Events; 

[Serializable]
public class GameObjectEvent : UnityEvent<GameObject> { } 

Diff // [!code --] and // [!code ++]

   // Health.cs
using UnityEngine;

public class Health : MonoBehaviour
{
    [SerializeField] private int _health = 10; 
    [SerializeField] private int _currentHealth = 10; 

    public void SetHealth(int health)
    {
        _health = health; 
        _currentHealth = health; 
    }
}

And we can start line numbering from 1 or any other number by including style="--start: xx;" in our code block. TBD: https://github.com/shikijs/shiki/issues/3#issuecomment-881312748

   // DialogueUI.cs
public override void DialogueStarted ()
{
    // Enable the dialogue controls.
    if (dialogueContainer != null)
        dialogueContainer.SetActive(true);

    onDialogueStart?.Invoke();            
}