using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MyCharater : MonoBehaviour
{
void Start()
{
int charaterLevel = 12;
int nextSkillLevel = GenerateCharater("Spike", charaterLevel);
Debug.Log(nextSkillLevel);
Debug.Log(GenerateCharater("Jet", charaterLevel));
}
public int GenerateCharater(string name, int level)
{
Debug.LogFormat("Charater: {0} - level: {1}", name, level);
return level + 5;
}
}
The above code runs normally.
But when I changed the order of the two lines of code in the GenerateCharater method, unity reported an alert and displayed "Unreachable code detected" in line 18, and the Debug.Log in line 18 could not be displayed normally in unity.
Please tell me why.