playMaker

Author Topic: PREFABS BROKE MY UI (SOLVED)  (Read 1301 times)

Matthew Reilly

  • Playmaker Newbie
  • *
  • Posts: 20
PREFABS BROKE MY UI (SOLVED)
« on: June 20, 2019, 02:07:48 AM »
Hi,

I am trying to bring a project from single to multi-player, and my creation of prefab game objects seems to have thrown off my UI setup. All the on-click events are missing, and there are lots of them (I suppose because prefabcan't see UI in hierarchy?). Anyways, the game works fine at runtime for single player, but once I stop the game, many many errors pop up & I'm concerned this will ruin my build. Will it? Is there a relatively easy fix I'm missing? thanks for your help!
« Last Edit: June 21, 2019, 03:26:19 AM by Matthew Reilly »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: PREFABS BROKE MY UI (SORT OF)
« Reply #1 on: June 20, 2019, 11:21:39 AM »
Hi.
Prefabs in the Project window can not communicate directly to objects in the hierarchy.

if you want to port it the another scene you could try to create a empty object,
Then drop everything (including ui etc) inside that object.

then make a prefab.

Then place in new scene or project

Matthew Reilly

  • Playmaker Newbie
  • *
  • Posts: 20
Re: PREFABS BROKE MY UI (SORT OF)
« Reply #2 on: June 20, 2019, 01:51:16 PM »
Hello,

Yes, this communication issue between prefabs and hierarchy objects was a big unpleasant surprise. The solution you offered isn't entirely clear to me.

1. when you say "port it," do you mean import the prefab into a new scene? My goal is to clean up the previously functional, compact scene I already made.... Do I need to rebuild the entire scene?

2. then make a prefab — of my current UI setup? I made the Click Button into a prefab and that didn't help. what am I making a prefab of?

3. place ____ in a new project? (am I placing a new prefab of the entire scene in a new project?)

Perhaps the best best would be to break all the prefabs or revert to an earlier version (a backup) of the game. I had been very focused on keeping my game design compact (w/ basically players, triggered objects, hash tables connected to UI, and a speed system triggered by pills), and this route seems to suggest that I'll be starting from scratch in a new window... is that the case?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: PREFABS BROKE MY UI (SORT OF)
« Reply #3 on: June 20, 2019, 02:37:11 PM »
Hi.
Maybe i misunderstood.

There are several ways to communicate with prefabs.

if created @ run time , you can store the object in a variable when created, then use set fsm gameobject and store object from the hierarchy that you need to communicate with

if you drop items in hierarchy you can use variables as well, then you can drag in the object in that variable
and use that variable instead of game object directly on actions.

another way is to use 'find game object' but its not so recommended during game play, at the start of a game its fine.

But i can't really say what the best solution in your case is, i would need more detailed information :)

Matthew Reilly

  • Playmaker Newbie
  • *
  • Posts: 20
Re: PREFABS BROKE MY UI (SORT OF)
« Reply #4 on: June 20, 2019, 03:02:57 PM »
Storing player as a game object is what I was just looking into... Seems like the best bet. Do you think that the reason I'm able to play game fine but then get all the errors is because the prefab is conflicting with a pre-existing game object in hierarchy? I'm hesitant to delete the game object from the hierarchy, since I don't want to lose my prior work / character through a stupid move...

Matthew Reilly

  • Playmaker Newbie
  • *
  • Posts: 20
Re: PREFABS BROKE MY UI (SORT OF)
« Reply #5 on: June 20, 2019, 04:34:33 PM »
One more question (this is an easy one, but I'm very confused on Photon setup). I currently have four players made & working properly, but I am activating one of them at the start of the game (not creating an object). Should I try to get that player into a new game object called something like "Photon Player 1," or should I be adding states etc to the pre-existing characters? I'm following the playmaker setup pages online, but I'm unclear if the actions applied to "GameManager" and "Player" should be put onto new objects or onto my existing players (x4) and Intro UI Menu?

Matthew Reilly

  • Playmaker Newbie
  • *
  • Posts: 20
Re: PREFABS BROKE MY UI (SOLVED)
« Reply #6 on: June 21, 2019, 03:35:47 AM »
OK, I believe the 1,600 compiler errors are back to zero. Whew... I think. For future reference to any noob who runs into this problem of having prefabbed the wrong objects, there's a good video that (I believe) explains Djaydino's first point above:


I "completely unpacked" the trouble game objects, moved the trouble duplicates out of the assets library & to the desktop (just in case), and got the pretty much back to normal. I guess the prefabs that couldn't access hierarchy objects were throwing tons of errors despite the game still working at runtime. Someone please correct me if this explanation is wrong, but that fix seems to have salvaged what would otherwise have been a completely broken project.