- Home /
How to create a scene programaticly
Hello everyone, I want to create an editor extension that permit to create a scenes with a given name and duplicate them, is there any free method ( not using YAML format because it's for the pro version only ) thank you,
Answer by fafase · Jun 02, 2014 at 04:56 PM
YAML, XML, XAML, JSON or other are all the same thing, a text file just like a plain notepad file.
Only difference is that the extension is different so that it is recognized by software to contain special keyword or layout to speed up parsing.
Most engine or framework come up with their own extension and their own layout, for example Marmelade uses .mkb for prefab, but it is just a text file with special character to indicate beginning and end of file and so on.
Then you can come up with your own text file for your scene and your own method to read and parse your file. This below is a .fafase extension
{
scene : 01_
scenename : FirstScene_
object :
@
name : Player_
prefab : Player_
position : 00.00,00.00,00.00_
rotation : 00.00,00.00,00.00_
scale : 00.00,00.00,00.00_
}
Now you can come up with a parsing system that I will simplify greatly:
void CreateFromFafaseFile(string fafaseFile){
// Get scene number and scene name and compare to current scene
while(@ is found)
// start parsing info using _ as end of line
// Get the prefab and fetch it with Resources.Load and put it in prefab
// Get the name and store it in string name
// Get the position , rotation and scale and store in V3
// instantiate using parsed info
GameObject obj = (GameObject)Instantiate(prefab, position, rotation);
obj.transform.scale = scale;
obj.name = name;
//get to next @ character
}
Thank you, Actually i want to create a real scene and save it in the project hierarchy with code, and also i want to copy and past scenes. Do you now any short cut
I don't quite get the point of using Unity then. The purpose of an engine is that it does all of this for you, efficiently and easily. In your case you seem to want to overpass that. I would recommend to use OpenGL or DirectX then where you can start with nothing (actually a lot but nothing as engine) and you can do whatever you want then.
Your answer
Follow this Question
Related Questions
How can I save & load gameObjects? 1 Answer
Will Restoring my computer restore my scene? 0 Answers
Is there a way to save a scene without opening it ? 1 Answer
Coyote model missing in Locomotion System 2 Answers
Save and load 0 Answers