• 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 DuxClarus · Aug 16, 2012 at 12:29 AM · editorbuildgameobjectsstandalone

Standalone build doesn't create gameobjects properly

Hello all,

I'm working on a 2x space game project. In the unity editor when we load the galaxy scene the sample spheres that are there are removed and converted into sun objects with planets. In the standalone build the sample spheres are not removed and no suns or planets are created. Here is a video of my problem hopefully this better explains the behavior: http://www.youtube.com/watch?v=UdyF9yTUyIc&feature=plcp

Some strange behavior: In some builds that we create the game works fine the first time we run it and any time after that it doesn't work

Note: We just use the sample spheres for the suns location so we can create galaxies with the look we want.

This is how we generate the galaxy in code:

 galaxyGameObject = Instantiate(galaxyPrefab) as GameObject;
 galaxyGameObject.transform.position = GameObject.Find("SampleSuns").transform.position;
 Galaxy galaxy = galaxyGameObject.GetComponent("Galaxy") as Galaxy;
         
 GameObject[] sampleSpheres = GameObject.FindGameObjectsWithTag ("Sun");
 for (int index=0;index < 100; index ++)
 {
     GameObject newSunGameObject = Instantiate(sunPrefab) as GameObject;
     newSunGameObject.transform.position = sampleSpheres[index].transform.position;
     newSunGameObject.transform.parent = galaxyGameObject.transform;
     Destroy(sampleSpheres[index]);

     Sun newSun = newSunGameObject.GetComponent("Sun") as Sun;
     newSun.SunType = CalculateSunOdds(giantSunOdds,commonSunOdds,dwarfSunOdds);
     newSun.ReSize();
     newSun.PopulateSignatureList();
     galaxy.Suns.Add(newSun);    
 }
 Destroy(GameObject.Find("SampleSuns"));
 galaxy.printDebugInformation();

Thank you for any help!!!

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 DuxClarus · Aug 15, 2012 at 10:46 PM 0
Share

I don't know why there are two code blocks, apparently I formatted it incorrectly. >.< I tried fixing it but I failed. :(

avatar image Kryptos · Aug 16, 2012 at 01:22 PM 0
Share

Fixed it. This was because you had some tab characters.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Kryptos · Aug 16, 2012 at 01:26 PM

Check for errors (IndexOutOfBound). This line will cause error if there are less than 100 spheres in the scene.

 for (int index=0;index < 100; index ++)

Fix it with:

 for (int index = 0; index < sampleSpheres.Length; index++)


Won't it be easier to have a dedicated script on each sphere sample that instantiate the sun prefab when the game start.

Something like:

 void Awake()
 {
     Instantiate(sunprefab, transform.position, transform.rotation);
     Destroy(gameObject);
 }
Comment
Add comment · Show 1 · 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 DuxClarus · Aug 16, 2012 at 06:17 PM 0
Share

$$anonymous$$hmmm that's an interesting take on making the sample spheres suns. Obviously that technique never past through our brains when coding this. But with our final presentation tomorrow I don't think we have the time to change this and test it with the rest of the stuff we have to do. Regardless we figured out the problem. It was with our xml reading. After looking at the log file in the build we found out we were getting an IsolatedStorageException because it wasn't finding/reading the xml files we use to populate the planets with data. The solution was simple... include the xml files in the build. >.> Thanks for the help $$anonymous$$ryptos and maybe after this presentation our $$anonymous$$m can look into making the sample spheres suns via their own script.

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

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

Scene changes not being reflected in standalone build 2 Answers

Build unity application using a unity application. 1 Answer

Choppiness in Unity Editor but not on Build. 1 Answer

Distribute terrain in zones 3 Answers

Build Standalone (.exe) with google cardboard VR. 1 Answer

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