• 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 IanS · Sep 29, 2011 at 09:38 AM · instantiateobjectsmultipleonceat

Instantiate 3 guiTextures at the same

Hey guys.

So i'm kind of a beginner to unity, but not two new to game programming, but i've ran into an interesting little bug and i just need some figuring out what is going wrong. I believe i need to create a new prefab for the problem but anywho.

I'm building a simple slot machine game, all the icons are guiTextures, when it reaches a certain point the icon calls the next object in line and Instantiate's it. The problem i'm having is during the Instantiation (or however you spell that). I'm getting the error "MissingFieldException: Field 'UnityEngine.GameObject.' not found."

The objects are being moved on a courtine. Here is the calling script

for(ic in GameObject.FindGameObjectsWithTag("icon"))
    {
        if((ic.transform.position.z == 1))
        {
            if(ic.guiTexture.pixelInset.y >= 100)
            {
                ic.guiTexture.pixelInset.y -= .5;
                cur_pos += 1;
            }
            else
            {
                var slot = 0;
                if(ic.guiTexture.pixelInset.x == 200)
                    slot = 0;
                else if(ic.guiTexture.pixelInset.x == 450)
                    slot = 1;
                else if(ic.guiTexture.pixelInset.x == 700)
                    slot = 2;
                var oneOther = false;
                var nextNum = parseInt(block.itemLoc[slot][ic.guiTexture.name.Substring(0, ic.guiTexture.name.IndexOf("Clone") - 1)]) + 6;
                if(nextNum == 24)
                {
                    nextNum = 2;
                }
                else if(nextNum > 24)
                {
                    oneOther = true;
                    nextNum = nextNum - 22;
                }
                var nextName = itemHash[slot][nextNum];
                var loc = block.IconsContainer[nextName];
                if((GameObject.Find((block.itemHash[slot][nextNum] + "(Clone)")) == null))
                {
                    block.addIcon(nextNum, nextName, ic.guiTexture.pixelInset.x);
                    GameObject.Destroy(ic);            
                }
                else
                {
                    if((GameObject.Find((block.itemHash[slot][nextNum] + "(Clone)")).guiTexture.pixelInset.x != ic.guiTexture.pixelInset.x) && 
                       (ic.guiTexture.name == block.itemLoc[slot][ic.guiTexture.name.Substring(0, ic.guiTexture.name.IndexOf("Clone") - 1)]))
                    {
                        block.addIcon(nextNum,nextName,ic.guiTexture.pixelInset.x);
                    }
                    GameObject.Destroy(ic);
                }
            }
        }
    }

And here is the actual creation script.

static function addIcon(key:int, index: String, slot:int)
{
    var iconAdder:GameObject = new GameObject();
    if(slot > 200)
        print("Creating object " + index + " at slot " + slot);
    objs = GameObject.FindGameObjectsWithTag("icon");
    var createKey = 0;
    if(slot == 200)
        createKey = 0;
    else if((slot == 450) || (slot > 200 && slot < 460))
        createKey = 1;
    else if(slot == 700)
        createKey = 2;
    createdIcons[createKey][key] = iconAdder.Instantiate(iconAdder.Find(index), Vector3(0,0,1), Quaternion.identity);
    createdIcons[createKey][key].guiTexture.pixelInset.y = 900;
    createdIcons[createKey][key].guiTexture.pixelInset.x = slot;
    GameObject.Destroy(iconAdder);
}

This is also my first form post so critique is welcome! Thanks for any help in advance, thanks!

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 IanS · Sep 30, 2011 at 03:30 AM

Never mind everyone i figured it out! =)

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

How to instantiate everything inside an Array? 1 Answer

Rotating Multiple Objects at once (OnCollision) 1 Answer

instantiate object only once in current position and than again in another 0 Answers

Instantiate an array of prefabs? 0 Answers

Is it possible to have multiple scenes saved in memory? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges