Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
  • Help Room /
avatar image
0
Question by SoulGameStudio · Jan 18, 2016 at 04:31 PM · scene-switchingscenesarchitecturestructure

Using scene on big projects ?

Hi, I'm a "veteran" Flash dev working on the sequel of Swords & Souls. (here's the game if you have the time => http://goo.gl/NHIq8h)

But I'm new to Unity and I'm struggling about how to structure the project regarding Scenes.

  • I have no actual "level design" since all levels are data based content which are loaded on the go.

  • I have lot of different Screens (map, fight, characters sheet, inventory, town, each building in that town, different mini games, etc.)

  • I also have a lot of common data (mostly player related) which must be kept across all the game session.

  • In Flash, I had a blank screen, and everything happened in the code, not on the scene, so I'd like to keep that workflow as much as Unity allows it.

Any insight/feedback of your experience about structuring scenes on a big projects would be welcome!

Thanks for your time

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by pixelpowa · Jan 18, 2016 at 06:38 PM

"I had a blank screen, and everything happened in the code, not on the scene, so I'd like to keep that workflow as much as Unity allows it."

This is totally possible with Unity, but it requires some work.

First, you'll need an empty scene with a Camera in it. Then you'll need to attach a C# script to the camera, and that's basically your entry point for the rest of your code. You can update your generic game objects in the Camera's Update() method. For example, lets say you have a class called Baddie:

 class Baddie
 {
     float x = 0;
     float y = 0;
     public void Update()
     {
         // baddie AI code
     }
 }

You'd call the Baddie's Update() method in the Camera's Update() method.

Rendering is a lot trickier, and I don't have very good example code at the moment. There are probably multiple (better) approaches, but this is how I did it:

Basically, if you want to render textures manually, you'll need to create a Mesh object that contains the vertices and UVs of the textures you want to draw. Then, in the Camera's OnPostRender() method, you can call Graphics.DrawMeshNow(). IIRC, you'll also need a SpriteRenderer attached to the Camera and call SetPass before DrawMeshNow. The SpriteRenderer will also need to have the relevant Texture object set as its mainTexture. Basically, this is how it might look:

 void OnPostRender()
 {
   spriteRenderer.material.mainTexture = myBaddieTexture;
   spriteRenderer.material.SetPass(0);
 
   // update your mesh's vertices and UV coordinates.
 
   Graphics.DrawMeshNow(mesh, Vector3.zero, Quaternion.identity);
 }

You can also improve performance by exporting all of your graphics onto the same texture and including all of your sprite coordinates in the same Mesh. (I'm using TexturePacker to help with this.) Depending on your game's art, this may or may not be feasible, but the less drawing calls you make the better.

Hope this helps point you in the right direction. I used this approach to port my game from XNA/Monogame to Unity, and I had to do very little rewriting at all.

Comment
Add comment · 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
0

Answer by SoulGameStudio · Jan 18, 2016 at 08:06 PM

Thank you very much for your detailed answer. I should have been more accurate => I'm not a 100% code purist, I have no worries pre-defining lots of Prefabs and other needed assets. So I don't think I'd have troubles with rendering since I use Prefabs for all my in game content (projectile, enemy, hero, etc.) stored in the Resource file, so I can add them to the scene properly whenever I need.

What I wonder tho is, let's say I choose not to use multiple Scenes, does it mean I should use giant Prefabs containing each Screens (town, interiors, map, etc.)? And load/unload them as the player navigate? Same question for HUD. Stuff like that. Mostly I wonder if scenes are "must-have" in big projects like that.

Comment
Add comment · Show 2 · 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 pixelpowa · Jan 18, 2016 at 09:12 PM 0
Share

@SoulGameStudio Ah I see. I have limited experience using Unity's scene editor, but I think that's a fine approach. You might even be able to nest them inside empty GameObjects and then enable/disable each menu's parent GameObject as you need to, which might make the transitions faster. Here's a tutorial vid on this concept.

Again, though, I'm far from an expert on Unity. I only stumbled on this topic because I was researching ways to handle large 3D levels in Unity, haha.

avatar image SoulGameStudio pixelpowa · Jan 18, 2016 at 10:22 PM 0
Share

Okay! Thanks for your insight and for the tuto, watching now. The idea is quite tempting actually.

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

When I load a scene a second time, some objects don't show up 0 Answers

¿Does AudioListener.volume save for all scenes? 0 Answers

Changing player position when changing scene 1 Answer

What is the best for performance? 0 Answers

How do I change scene with by a score lesser time based / problem scene wont switch to the right scene 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges