To use our new custom string method, we'll need to include it in whatever class we want to have access to it.
Open up GameBehavior and update the class with the following code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// 1
using CustomExtensions;
public class GameBehavior : MonoBehaviour, IManager
{
// ... No changes needed ...
void Start()
{
// ... No changes needed ...
}
public void Initialize()
{
_state = "Manager initialized..";
// 2
_state.FancyDebug();
Debug.Log(_state);
}
void OnGUI()
{
// ... No changes needed ...
}
}
Let's break down the code:
- First, it adds the CustomExtensions namespace with a using directive at the top of the file.
- Then, it calls FancyDebug on the _state string variable with dot notation inside Initialize() to print out the number...