Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by NielsVS · Aug 21, 2012 at 03:15 PM · managercapturing

automatic gamemanager script

I have made a capturing script with a boolean which changes to true when you capture a location, I want to make a manager that searches on the start for all gameobjects in the scene and makes a script on runtime with booleans for every instance that then can be used for anything like a percentage bar. I have the script for the capturing already finished, but I don't know how to start the manager... can someone help me with this?

Comment
Add comment · Show 2
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 Khada · Aug 21, 2012 at 03:49 PM 1
Share

Can you be a little clearer on what you're trying to do? I think I get the idea but I'm not going to write a script just to find out I'm wrong.

avatar image NielsVS · Aug 21, 2012 at 05:19 PM 0
Share

I am trying to make a manager that lists all the gameobjects that use the same script (or tag) which make them a capture point, this happens on startup of the level. it then makes a boolean for every "node". so I can do everything I want with those booleans, like a percentage bar, a warning system or a puzzle system.

1 Reply

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

Answer by Khada · Aug 22, 2012 at 09:39 AM

This script does what you want. Note that you should change all the 'GameObject' types to whatever your 'capture point' script/object type is.

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 
 public class Node
 {
     public Node(GameObject node, bool active)
     {
         kNode = node;
         bActive = active;
     }
     
     public GameObject kNode = null;
     public bool bActive = false;
 }
 
 public class Manager : MonoBehaviour 
 {
     private List<Node> lNodes = new List<Node>();
 
     // Use this for initialization
     void Start () 
     {
         object[] aNodes = GameObject.FindObjectsOfType(typeof(GameObject));
         
         for(int i = 0; i < aNodes.Length; ++i)
         {
               Node kNewNode = new Node((GameObject)aNodes[i], false);
               lNodes.Add(kNewNode);
         }
     }
     
     // Update is called once per frame
     void Update () 
     {
         //example of iterating through all node and doing something
         for(int i = 0; i < lNodes.Count; ++i)
         {
              if(lNodes[i].bActive)
              {
                    lNodes[i].kNode.active = true;
              }
         }
     }
 }
Comment
Add comment · Show 5 · 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 NielsVS · Aug 22, 2012 at 10:51 AM 0
Share

Thanks $$anonymous$$hada, I am going to try this out and try to get it to work with a percentage bar.

avatar image Khada · Aug 22, 2012 at 11:25 AM 0
Share

Sure, let me know how it goes. Be sure to mark the question as answered if that does it. (Questions can be marked as answered by clicking the checkmark below the up/down vote buttons on any answer.)

avatar image Khada · Aug 23, 2012 at 10:01 AM 0
Share

Did that end up working for you?

avatar image NielsVS · Aug 23, 2012 at 10:07 AM 0
Share

yes it works for the most part, I only have really limited experience with C#. Thanks

avatar image Khada · Aug 23, 2012 at 10:11 AM 0
Share

No worries :)

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

8 People are following this question.

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

Related Questions

expressions in statements must only be executed for their side effects 1 Answer

BeginScrollView question on auto increasing 1 Answer

Remove and Add a Script via a Code 1 Answer

How Do I Fix Unexpected Char 0x201C? (Code Below) 1 Answer

object rotating around parent 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