code error
am learning c# from scratch using youtube videos, and wen i follow along the codes that are used are not working when i write them.
Answer by aditya · Oct 20, 2016 at 08:42 AM
Its not Debug.Lod it is Debug.Log ... pay attention to your autocompletion
Well that and it's using asterisk around the string ins$$anonymous$$d of double quotes and it's missing a semi-colon at the end
@Landen Sorry for writing that wrongly but here what am saying still its not printing. i am trying both: like e.g: Debug.Log (shooting......); and Debug.Log "shooting......"; and string myName "$$anonymous$$ono"; how i write these lines
using UnityEngine; using System.Collections;
public class TestScript : $$anonymous$$onoBehaviour {
// Use this for initialization
void Start () {
Debug.Log (*Start*);
}
// Update is called once per frame
void Update () {
}
}
also check this again
using UnityEngine; using System.Collections;
public class TestScript : $$anonymous$$onoBehaviour {
int a = 5;
float b = 5.5f;
string myName *$$anonymous$$ono*;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
You're script must be attached to a GameObject(even an empty gameobject) so it executes the code. Here is an example in a single image of attachment, the script and the output to the console window in the Unity Editor. If the Debug.Log is in the Update method it will execute as much as the Update method is invoked from Unity... Read that as a LOT.
Example Script:
using UnityEngine;
using System.Collections;
public class Test : $$anonymous$$onoBehaviour {
string testLogString = "Some test log string";
// Use this for initialization
void Start () {
Debug.Log(testLogString); // Will output to Console "Some test log string"
Shoot();
}
// Update is called once per frame
void Update () {
}
void Shoot ()
{
Debug.Log("Shooting..."); // will output to console "Shooting..."
}
}
Your answer
Follow this Question
Related Questions
Error when setting Rotation 2 Answers
UCE0001: ';' expected. Insert a semicolon at the end. 1 Answer
0xc000007b error on 64 bit machine? 1 Answer