- Home /
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!
Your answer
Follow this Question
Related Questions
How to instantiate everything inside an Array? 1 Answer
Rotating Multiple Objects at once (OnCollision) 1 Answer
Multiple object prefab instantiates too far down 0 Answers
instantiate object only once in current position and than again in another 0 Answers
Is it possible to have multiple scenes saved in memory? 1 Answer