#Null Reference
1 messages · Page 1 of 1 (latest)
cool
So depending on how much code it is pbb in a gdl paste
its a whole script lol
but if you think only the main part then i can try to put that
public void OnPointerDownEvent()
{
Debug.Log("did you see me 5");
buildFishUIController.ShowFishInformation(clownFishSO);
}
public void AddEvent(GameObject Go)
{
EventTrigger trigger = Go.GetComponent<EventTrigger>();
Debug.Log("did you see me 1");
EventTrigger.Entry entry = new EventTrigger.Entry();
Debug.Log("did you see me 2");
entry.eventID = EventTriggerType.PointerDown;
Debug.Log("did you see me 3");
entry.callback.AddListener((data) => { OnPointerDownEvent(); });
Debug.Log("did you see me 4");
trigger.triggers.Add(entry);
}
did you want to see the code for the buildFishUIController.ShowFishInformation?
That is not the whole script since it would be in a class
The whole script
Quite literally ctrl+A ctrl+C ctrl+V it
Please do throw it in a paste site though
There are pastes sites given in the #854851968446365696
Yup you just threw an empty paste site at me lol
dont i just paste it and then save it then send u the link?
oh thats werid
It's literally that simple
I don't know what you're doing
If you press the save button the URL will change
You can copy that URL and paste it here
otherwise just use GDLpaste
i think it might be too long, because when i just type a few lines it works
that one works
Could you tell me what you want your code to do exactly?
By the way, you shouldn't need .ToString() in an interpolated string
basicallly go to the store, then when a user buys the fish, it instantiate the fish and then the code that I was working on, i want the event trigger to give the fish the UI that display the stats
Do you use buttons?
didnt know that, will try to fix some of them later
For buying
yeah
Did you use a tutorial for this?
yes i did
Mind sharing it?
but it only gives the basics
Which is?
it stopped and I added on
The event thingy, is that your doing or the tutorial
Alrighty
the event is to give the instantiate fish a dashboard so when a user clicks on it, it displays the stats of the fish. I am trying to assign the fish this ability right off the back, after a user purchase the fish
i can do that part, just not sure if it will work on mobile?
didnt get a chance to test it yet, but I can try later
oh no worries, i can work with that
So I'm fully in the dark of that
all good
But I know this works for normal mouse click
yeah i agree, i tested before
So do you want to do it this way or not?
atm, it doesnt matter if you think about it
so the button isnt an issue, the issue is that I am not able to give the event trigger all the info it needs
Well there's a nullref
i tested it manually like i said ealier, it works on non instantiate fish
yeah, its null because it needs the script attach to it so that it can display the stats UI, but since it has none attached, it displays a nullref
Yes
yeah the clicking works 100% im positive
no i dont lol sadly
I'd breakpoint stuff first so you can see exactly where it goes wrong
That might help
Breakpoints are very useful
You've to press this button btw to attach VS to Unity
It's not a Unity specific guide, but the rest still holds up
ohhh nice
The first part is mostly important, you don't really need conditional breakpoints and such
They can be of use is specific cases though, that's for sure
i will read into it
but this is the code that Unity has on their eventtrigger: using UnityEngine;
using UnityEngine.EventSystems;
public class EventTriggerDelegateExample : MonoBehaviour
{
void Start()
{
EventTrigger trigger = GetComponent<EventTrigger>();
EventTrigger.Entry entry = new EventTrigger.Entry();
entry.eventID = EventTriggerType.PointerDown;
entry.callback.AddListener((data) => { OnPointerDownDelegate((PointerEventData)data); });
trigger.triggers.Add(entry);
}
public void OnPointerDownDelegate(PointerEventData data)
{
Debug.Log("OnPointerDownDelegate called.");
}
}
for the part that says: entry.callback.AddListener((data) => { OnPointerDownDelegate((PointerEventData)data); }); ....I am not sure what "data" can be use for...I've watched a few YouTube videos and they just sort of ignore it and not use it...can they rename it to something else as well
data
Is probably the args it passes
thats what I was thinking too, but this part throws me off: OnPointerDownDelegate((PointerEventData)data)
that data at the end
It's a cast maybe from what I can see
I don't really use these calls much, I just use buttons with onClick and a lot of Actions
Nope
ok lol
it's like doing
float myFloat = 5.5
int myInt;
myInt = (int)myFloat
Casts it to another type
Or in this case, struct
myInt would get the value of 5 btw
ah I see why you would say its a cast, make sense
in this case, I dont think onClick would be any help lol since it is asking for the same format:
it works using the gameobjects that are in the heiracrchy, but for instantiate objects from my prefabs, it wont allow the GameController to be in there because supposebly it is already in runtime and it cannot put itself on the instantiate object
Yes, but you're not considering that I actually know how onClick works XD
The rest I've no idea
You just seemingly have to get the right components I think
But it's a bit hard to say what is exactly null and if there are multiple things null etc
Hence I suggested the breakpoints, did you manage to get it working?
okay yeah i tested it, it doesnt pause anywhere
Please set your IDE to dark theme
Is it attached?
And did you get a pop up in Unity of "Do you want to turn on debug mode?"
i think i did
we have to click attached every time?
i clicked ok and then attached at the bottom, then the debugger shows that it is on
then i press play on unity
i didnt get this option
okay I dont think i have VS Code
wait is it visual Studeio Code Editor?
it shows its installed
You don't need to?
You're just using VS right?
Is VS configured
what do you mena by configured
if it is just the attached to unity, i did that
im using Visual Studio 2019
No why
Then your IDE isn't configured
Which also means breakpoints do in fact not work
Because you didn't configure your IDE
Also having a configured IDE is essential
So much so, that this is a rule
I gotta go home now though, I can continue to help you later, but it'll take like 2 hours before I'm home
Just make sure your Visual Studio is configured though
You can also use Rider, but I'd recommend VS, it's preference though
i been using VS so i am use to it and pref it
i read that Rider is paid
I am following the list
i been wanting this configurations as well, i see youtubers had it and did some searching online but there was just too many information that i got lost
but the read me helps, hopefully i can get it working
you recommend VS 2019 or go for the latest one 2022?
nice Monobehaviour is green now
it is working on
the breakpoint
it is possible to do word by word? I am currently only doing line by line and it runs through the whole line and then it stops and produce the error
What do you mean?
Oh
No
It breaks a line
You can add multiple breakpoints though
And you can over over your variables to see the value
gotcha then the error says it is aftermy last code
but i been messing with it and i saw that i didnt need to put a gameobject on it
it works with a script
but
the script doesnt allow the function o i might have to add a diff function
it allows the script while it is still in prefab
yeah the issue is still there
even after i put the script there
been troubleshooting it all day, still cannot figure out why
but heading to bed now, will ttyl
Thanks BTW, just wanted to let you know
Hey @glacial panther I found the solution! Thanks again for giving me your time to help me troubleshoot it, and providing me x and y information, im sure it was necessary in order for me to get to z. we can close out this thread
:D
Well now you know how to use breakpoints :)