- Home /
Not getting a Debug.Log
I have a crafting script for some reason im not getting the Debug.Log("Ammount1"), Debug.Log("Add"), or Debug.Log("Add1"), but i am getting Debug.Log("Ammont").
I think it has something to do with the brackets that i placed but because im pretty new to Unity and Javascript, I dont really know what way they should go. I think it is the Brackets because im its not subtracting the Ammount variables. If you know what the problem is or what i need to do to keep it working but rearrange the brackets please leave a comment or an answer!
I have left the section of the script below. I am sorry im not very knowledgeable in coding and Thank you in advance!
function Craft2 ()
{
if(Crafting[2] == true)
{
Debug.Log("Ammount");
if(Ammount[0] >=2 && Ammount[1] >=1)
{
if(CraftingNumber >= NewTexture.Length)
{
Ammount[0]-=2;
Ammount[1]-=1;
Ammount[2]+=1;
Debug.Log("Ammount1");
if(NewTexture[CraftingNumber] != Blank )
{
CraftingNumber ++;
Debug.Log("Add");
}
if(NewTexture[CraftingNumber] == Blank )
{
NewTexture[CraftingNumber] == AllTextures[2];
Debug.Log("Add1");
}
}
if(CraftingNumber < NewTexture.Length)
{
CraftingNumber = 0;
Crafting[2] = false;
}
}
}
}
Answer by getyour411 · Apr 28, 2014 at 12:44 AM
Your debugs are essentially based on passing your if() conditions, so that's really the root cause and probably nothing to do with brackets/debug.log per se. The simplest way (without using steps in Mono) is just to put more debugs like after line 7 do debug.log ("passed ammount[0] and [1] check") and then again on the next if, and so on. I think you'll find your if() conditions aren't working as expected
Answer by Jeff-Kesselman · Apr 28, 2014 at 01:17 AM
Make sure logging messages are enabled on the console...
All enabled looks like this
All disabled looks like this
Its a bit hard to see in those screen shots, but enabled is grey, disabled is black. If unsure, then click on them and pif they get darker, click again.
They are enabled because i was getting the first few Debug.Log messages...I think its my if statement on line 16
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
It is not possible to invoke an expression of type 'UnityEngine.GameObject'? 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Error Unexpected token } 1 Answer