Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 nenkyyy · Feb 13, 2014 at 05:23 AM · gameobjectinstantiateprefabdestroyonmouseenter

How many time does a prefab takes to load??

Hello everyone,

so I'm trying to change a couple of prefabs when mouse over/out them, and, I'm using this:

 using UnityEngine;
 using System.Collections;
 public class zr_start : MonoBehaviour {
     public GameObject btn_startOver;
     void OnMouseEnter() {
         Instantiate(btn_startOver, new Vector3(0,0,0), Quaternion.identity);
         Destroy(this.gameObject);
     }
 }

and it do work but it have a 2 second delay to destroy the prefab and add the other one, it does not happen immediately, I was just wondering why that delay and if there's a way of get rid of that delay maybe???

any idea or help would be great!

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by whydoidoit · Feb 13, 2014 at 05:25 AM

Instantiation time depends on the complexity of your prefab.

The best plan is do not instantiate at run time make up a bunch of objects and enable/disable them when you want to create and destroy things - there are also several Assets on the store that will help you with this.

Comment
Add comment · Show 4 · 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 nenkyyy · Feb 13, 2014 at 05:43 AM 0
Share

I guess that make sense, since I'm using ragetools svg component... gonna try disable/enable then, thanks!!

avatar image whydoidoit · Feb 13, 2014 at 05:44 AM 0
Share

I've converted you "Answer" to a comment - on UA "Answer" means "Solution" and not "Reply" -> there's an "add new comment" button hidden on the right of the screen :)

Best of luck with it - if it works for you then tick the answer... Cheers :)

avatar image nenkyyy · Feb 13, 2014 at 05:50 AM 0
Share

lol, silly me, thanks again! XD

avatar image nenkyyy · Feb 13, 2014 at 07:45 AM 0
Share

It worked!!!

I place both objects at same position just changing one level in the Z axis and use this for both objects:

first object which is at Vector3(0,0,0);

 using UnityEngine;
 using System.Collections;
 public class zr_start : $$anonymous$$onoBehaviour {
     private GameObject obj;
     void Start() {
         obj = GameObject.Find("btn_startOver");
     }
     void On$$anonymous$$ouseEnter() {
         this.gameObject.SetActive(false);
         obj.gameObject.SetActive(true);
     }
 }

second object which is at Vector3(0,0,1);

 using UnityEngine;
 using System.Collections;
 public class zr_startOver : $$anonymous$$onoBehaviour {
     private GameObject obj;
     void Start() {
         obj = GameObject.Find("btn_start");
     }
     void On$$anonymous$$ouseExit() {
         this.gameObject.SetActive(false);
         obj.gameObject.SetActive(true);
     }
 }

It looks as smooth as I wanted :)

thanks!!

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

19 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

Related Questions

Instantiating prefabs: "The object of type GameObject has been destroyed". 1 Answer

Accessing children of an instance doesn't work every time 1 Answer

Trouble with destroying an instantiated prefab 2 Answers

Check if object is destroyed on level load, if so instantiate prefab? 1 Answer

Can't remove instantiated prefab 0 Answers


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