- Home /
Extracting GameObject from scene package
I have a scene in Unity that is exported as a package using the following code:
string outputPath = sceneName + ".unity3d";
string result = BuildPipeline.BuildPlayer(new[] { inputPath }, outputPath,
BuildTarget.StandaloneWindows,
BuildOptions.BuildAdditionalStreamedScenes);
When I load the package during runtime, I use a WWW like this:
var www = new WWW(packageUrl);
var ab = www.assetBundle;
Application.LoadLevel(sceneName);
I want to retrieve the terrain from the scene. In Unity, the terrain is just called "island_terrain" and is part of the scene which is packaged above. How would I go about getting the terrain GameObject/Component?
I was eventually able to get it to work by doing
GameObject.FindObjectOfType(typeof(Terrain));
but I still feel this is suboptimal.
Answer by Paulius-Liekis · Aug 29, 2012 at 02:42 PM
GameObject.Find("/island_terrain");
Heh, turns out this wasn't working for me because my GetComponent call had a lowercase t in Terrain, so it was returning null. It works now. Thanks!
Your answer
Follow this Question
Related Questions
package manager error install 0 Answers
Terrain screen turns black when taking the brush to terrain 1 Answer
[SOLVED] My terrain... it's gone, and I'm in panic mode 1 Answer
Disable LODs for the Scene Viewport 0 Answers
camera and terrain won't show 0 Answers