Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Unity EditorWindow scripting

Discussion in 'Scripting' started by bratan20000, Jun 18, 2022.

  1. bratan20000

    bratan20000

    Joined:
    Oct 28, 2021
    Posts:
    12
    HI, guys!
    So, I want to create some sort of Scene in the Editor Window. I need to easier creating decorations for some rooms. So, how it must be looked. You have button "Generate Room" it generate room W x H size. Then you can drop prefabs in this "Scene" in the Editor Window and create this specific patterns of decoration.
    So, I tried inherits from SceneView and create new Scene using : EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
    but when i did this, my main scene overlaps by this new scene.
    Maybe, using Scene here not the best method.
    Perhaps there is a better method to do this.
    Thanks!
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Hi.

    I don't know enough about using scenes in Editor scripts, but what you could do is use some serializable classes to store item data.

    Create a grid (I suppose it is a grid based room?) using buttons, images or whatever IMGUI UI elements are most suitable for this. Then have some list of icons or labels you click to select an item to paint, then paint those on grid in your EditorWindow (Use events to detect mouse clicks and drags etc)

    Every added item gets added to some array or list. Then you'll have to write some code to store your room layout when you end editing of your room layout.

    Finally, you probably want to read your room data into your game, and then you can get the corresponding prefabs for each tile based on your saved data.
     
    bratan20000 likes this.
  3. bratan20000

    bratan20000

    Joined:
    Oct 28, 2021
    Posts:
    12
    Yeah, it's look like great solution for this!

    Thank you very much pal :)