I started Unity C# training today, but I have a problem. I created an empty object named _scripts and created a C# file named "Encoding" and put it into it. Even though I write the codes and run the program, I can’t get any output. As an editor, I added the codes and images below with visual studio 2019 selected.
Code:
// kodlari calismasi icin gerekli komutlar
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Kodlama : MonoBehaviour
{
int sayiDegerleri = 5;
bool oyunBasladi = false;
void Start() // program calistiginda sadece 1 kere calistirilir
{
if (sayiDegerleri == 5) // sayi degeri 5 ise
Debug.Log("Değeriniz 5"); // 5 ise cikti
else if (sayiDegerleri == 4) // eger yukaridaki degil buysa
Debug.Log("Değeriniz 4"); // 4 ise cikti
else // eger ikisi de degilse
Debug.Log("Değeriniz 4 veya 5 Değil"); // cikti
}
void Update() // 30 framelik bir programda saniyede 30 kere calistirilir
{
}
}
I want Unity to detect when I save my C# code. If they perceive it, I will continue my education and learn.
3
Answers
Make sure your class name in visual studio match script file
name in project tab
Then try this:
Hmm..
Could we check the "_scripts" Object in Hierarchy have C# script named "Kodlama.cs" that we just wrote?
if then, the problem would be the change of Kodlama.cs that we wrote wouldn’t apply in the runtime
according to the Screenshot that you uploaded,
"Kodlama.cs" has a script that it just generated in initialization, not the code we modified.
If you check these parts carefully and rectify the problem,
you would get the result that you wanted.
I hope that this answer would help you solve the problem,
and have a peaceful day.
You are in Play mode!
Per default Unity doesn’t recompile scripts while you are in Play mode.
Exit play mode and Unity will recompile.