Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Bluestone19 · Feb 20, 2019 at 12:02 AM · uiprefabrpgvisibilitybattle-system

Refresh gameObject to original prefab, but it isn't visible

Hello, so I'm making a RPG-type game where the "battle system" takes place within a UI prefab. However, it loads in data on Start(), which might change between uses within the same scene, so I wanted to have the UI spawn in a new instance of the prefab in its place and then delete itself. However, when I go to enter a "battle" a second time, it never shows up but it still seems to be functioning in some capacity (given activity in the log). When I instantiate the second UI, do I need to alter it in some way to allow it to be seen, or is there some better way to do this?

EDIT: Here's what the original UI does when it's time to close:

 g.battle = false;
 g.pList [0].battleBox = Instantiate(battlePrefab);
 g.pList [0].battleBox.SetActive (false);
 Destroy (gameObject);

"g" is just a class for global variables, and pList is the list of party members (with index 0 being the main character), so it's basically replacing the old one (Which used to be in battleBox) with the new instantiated one, then setting the new one to be inactive until it's needed, then destroying the old one.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jstopyraIGG · Feb 20, 2019 at 12:13 AM 0
Share

Do you delete your old UI before you spawn your new one? $$anonymous$$ake sure your new UI is within a Canvas, and that you have an EventSystem in the scene in order for the input to work on your UI.

avatar image RobAnthem · Feb 20, 2019 at 12:19 AM 0
Share

Please show some code, the likelyhood is that you are editing the prefab at runtime OR replacing the prefab reference with your new instance or disabling it, then spawning in an already disabled version of the prefab.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bluestone19 · Feb 23, 2019 at 05:21 PM

After doing a bunch of messing around with it, I've figured out that somehow the newly instantiated UI just doesn't exist at any point, as it doesn't show up in the hierarchy when I pause. Does deleting the object which instantiated it delete the new one? Or is deleting the only instance of the prefab in the scene somehow deleting the whole prefab (and thus all other instances, or stopping them from being instantiated)?

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jstopyraIGG · Feb 23, 2019 at 05:44 PM 0
Share

What are you instantiating? It sounds like you're instantiating an object from the scene hierarchy, which you should not do. You need to instantiate an object from your project folder.

avatar image Bluestone19 jstopyraIGG · Feb 23, 2019 at 05:54 PM 0
Share

So I have a prefab of the whole UI, but I want one instance of the prefab to exist from the start of the scene, and then for it to spawn in another one of the same prefab and then delete itself.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

186 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Classic turn-based RPG battle scene question 1 Answer

Passing through a GameObject/Function to a button's OnClick 1 Answer

UI doesn`t render if camera is moved by 1000 units 1 Answer

How to save a prefab when a button is pressed 1 Answer

How to determine how much of string fits in UI.Text element? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges