#Debug.Log not Working

1 messages · Page 1 of 1 (latest)

kind canyon
#

@narrow siren

narrow siren
#

If that debug isnt running, first assumption is that you dont have the script on an active game object

kind canyon
#

For god's sake

#

I literally do not think I changed anything and it worked

#

I tried re-editing and saving and reloading that code 3 times 😂

#

Oh well, at least it's working. I guess this thread turned out to be super useful haha

#

But interestingly it's printing twice

narrow siren
#

probably just have it on 2 gameobjects

kind canyon
#

No, it's just this one

narrow siren
#

Start only runs once, search your scene with t:DecodeButton to see if anything else has it

kind canyon
#

How do I search my scene? That's cool

#

Nvm

#

Found it

narrow siren
#

once per script, either theres 2 scripts or you have 2 debug logs

kind canyon
#

Just one

#

And VS22 says that Debug.Log only appears once in all the scripts

#

Wait

#

Did I instantiate the script twice?

narrow siren
# kind canyon

hm that looks like 2 right there, though honestly im not sure what that search is from lol i just meant the hierarchy here.

kind canyon
#

Haha yeah, but doing even this results in nothing showing up

narrow siren
#

u gotta search the full name, t:ScriptName will search for any objects that have the component

kind canyon
#

I tried that

#

Nothing came up

#

I did it with the .cs and without

narrow siren
#

that would mean u dont have the script attached to a game object at all

#

are u adding it to an object through some other code?

kind canyon
#

This isn't a gameobject

#

But would it still call Start()?

narrow siren
#

that is a gameobject, the entire thing is

kind canyon
#

Oh right

#

Well in that case I do

#

So why would the search not return anything?

narrow siren
#

actually just do this instead on start, which will print for things instantiated later
Debug.Log($"DecodeButton on {name}");

kind canyon
#

And what will name be?

narrow siren
#

name is already a field which will print the name of the gameobject

kind canyon
#

That worked

#

It was because I did t:

#

Without that it worked fine

#

Ok I fixed it

narrow siren
kind canyon
#

And the Log only prints once now

#

I guess it was just a typo then

#

My bad aha

narrow siren
#

np

#

also for the simulator, maybe look more into the settings or put the app on your phone to see if it can handle it. Im not entirely sure that you have to use an external file. I doubt the simulator really matches what real phones have

kind canyon
#

Quick question, if I were to store that massive array in a file, would it be a JSON file?

kind canyon
#

But I have not reached the stage of getting it onto my phone

#

And that seems like a very complicated process

narrow siren
#

you could, json is just a format. If this is the only thing you're gonna be storing then id just put it in a txt and loop over each line lol

kind canyon
#

But if I need to I will. However I'll hardly be using that array so I've no problem storing it externally

kind canyon
narrow siren
#

It can exist in your files yea, but you'll still need to google how to read files for android. The thing I linked u before is simply just a way of getting a filepath

#

you wont be able to read the file the normal c# way, i believe because its not just sitting there as a .txt file. not sure how unity really builds the app but its packed in there somewhere

kind canyon
#
private void TxtToList(List<string> list, string path)
{
StreamReader reader = new StreamReader(path, Encoding.UTF8);
while (reader.Peek() >= 0)
{
list.Add(reader.ReadLine());
}

reader.Close();
}
narrow siren
#

that is the normal c# way, which shouldnt work for android

kind canyon
#

This works in Unity but not in Android because the file is packed inside the APK, but surely that won't matter as the file isn't needed for installation/APK unpacking?

narrow siren
#

when u build the project, it wont work

#

if you're running all of this from your pc (for like a school demo) then it shouldnt matter what you do

kind canyon
#

I intend on getting it working on my phone

#

So I will figure it out

#

unitywebrequest looks completely unrelated

#

All about HTTP comms

narrow siren
#

also if memory was an issue before just having it in an array, you might not want to add them to a list either since itll be stored

#

unity web request doesnt have to be for online files

kind canyon
#

Correct me if I'm wrong, but I can just store each word temporarily while I loop over the external file and then replace that variable's values with the next word? Definitely slower but that means I'm storing no more than a single word

kind canyon
narrow siren
#

yea thats better, the example u posted above adds them all to a list

narrow siren
kind canyon
#

Ohhh the same way that files viewed in browsers have this: file:///D:/VATSIM/London%20TMA.pdf

#

First PDF I could find 😄

narrow siren
#

oh yea I forgot thats what it shows in browsers too

kind canyon
#

This seems promising

#

But I am going to sleep now, 4am is good enough for me 😂

kind canyon
narrow siren
#

Oh one last thing, the unity profiler also tells you about memory. You should probably use that to see how much the strings were really allocating.