• 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 Mattisdada · Aug 27, 2012 at 08:20 AM · managerglobal

Is their a gameworld manager inside Unity?

Is their a gameworld manager inside Unity?

What im wanting to have is a global object that manages the game itself, but the game manager itself does nothing directly inside the game. It just keeps track of where objects are, create objects on timers, etc, etc.

So for example:

 gameworldManager.enemys[5].health

Would return the 4th created enemy.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by softrare · Aug 27, 2012 at 10:08 AM

You have to write something like this yourself.

Create a new C# script and call it GameWorldManager. Then give it a new attribute called enemies of type List. Make the class and the attribute static.

This is how your class should initially look like:

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 public static class GameWorldManager {
 
     public static List<GameObject> enemies = new List<GameObject>();
     
 
 }

You don't need to instatiate your GameWorldManager as it is a static class from which there is always exactly 1 instance. Because it does not derive from MonoBehaviour you can not (or lets better say: need not) attach it to a GameObject.

Now you can add, remove or access enemies from everywhere inside your project i.e. by saying

 GameObject enemy6 = GameWorldManager.enemies[5];

(Note that the 5th enemy is actually referenced by enemies[4] because the first one is stored in position 0)

Hope this helps you further.

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 Mattisdada · Aug 27, 2012 at 10:13 AM 0
Share

There isn't anything inbuilt? This im surprised by... Ok thanks!

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Creating a global function, callable from anywhere 1 Answer

do static variables slow down framerates in iphone 2 Answers

Set script global variable value priority over editor values 1 Answer

how can I create a variable to refer to any gameObject script with pragma strict 1 Answer

Update Function Won't Do If Statements 1 Answer


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