• 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 Pysassin · Dec 28, 2012 at 09:31 PM · instantiatemultipledrawing

Instaniate calls not drawing properly

I am making a chess game and use a plane that hovers over spots that are available to move. I do this by instaniating the plane and then deleting it when the piece is deselected or another piece is selected. Thus far it has given the desired effect. However is I use the command three times in a row(at different locations) the planes will not apear til i click the mouse anywhere on screen. This only happens when I try to draw more then one at a time. Is there anyway to circumvent this?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Owen-Reynolds · Dec 29, 2012 at 01:01 AM

It's probably specific to your code. For example, there's nothing special Unity does on a screen click, so there must be something in your code that displays on a click. Likewise, maybe you are reusing a variable for 2+ planes, which causes problems.

Test it with 2 items, try in different spots. Check if 2+ are getting deleted when they should. Then, with them broken, look in the Inspector. Are they not showing because they are inactive? Or positioned off the screen? Then track down just why that part of your code isn't properly firing. Possible toss in some prints.

Comment
Add comment · Show 3 · 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 Pysassin · Dec 29, 2012 at 05:51 PM 0
Share
 function LateUpdate () {
     if(Input.Get$$anonymous$$ouseButtonDown(0)){
             if(pieceStart.isSelected == gameObject){
                 if(GameObject.FindGameObjectWithTag("Plane")){
                 for(var isValidPlane : GameObject in GameObject.FindGameObjectsWithTag("Plane")){
                         GameObject.Destroy(isValidPlane);
                         }
                 for(var counter : int = 0; counter<4; counter++){
                 Instantiate(validPlane, validPosition[counter], Quaternion.identity);
                 }
                 }
                 else{
                     for(var counter2 : int = 0; counter<4; counter++){
                     Instantiate(validPlane, validPosition[counter2], Quaternion.identity);
                     }
                     }
             }
         }
 }
 
avatar image Pysassin · Dec 29, 2012 at 05:53 PM 0
Share

This is the function that calls the Instantiates. isSelected is a GameObject that refers to the piece that is currently selected to move. The first half deletes all the overlays on the screen (because they could be from a different piece) and then redraws them. If there are no planes it can't delete anything then draws the new overlays. Only the first overlay ever draws though unless I click again or switch from Game view to scene view.

avatar image Owen-Reynolds · Dec 30, 2012 at 07:35 AM 0
Share

3rd (last) loop is mixing counter and counter2. Looks like it might run 4 times with counter2=0.

avatar image
0

Answer by Pysassin · Dec 30, 2012 at 12:28 AM

Your right I had it nestled in a mouse check that was too slow to handle the draws. Moved it out and no issues. Thanks a lot.

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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

9 People are following this question.

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

Related Questions

How to use many particle systems, just varying in size and emitter dimensions 0 Answers

Instantiating A Grass Prefab Multiple Times 1 Answer

Multiple object prefab instantiates too far down 0 Answers

How to instantiate everything inside an Array? 1 Answer

Instantiate 3 guiTextures at the same 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