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 /
This question was closed May 07, 2018 at 08:19 AM by Myth for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Myth · Aug 20, 2014 at 12:17 AM · c#list

Unable to fill list.

So I have this piece of code that needs to have a list of all child objects that have a weaponSet script on them. I add the objects in the inspector and they update the list, but when i run the game, the output is that there is nothing in the list... Any suggestions or improvements?

using UnityEngine; using System.Collections; using System.Collections.Generic;

 public class StrikeCraftFlightInput : MonoBehaviour {
 
     // *** other components *** //
     StrikeCraftFlightPhysics myPhysics;
     public List<WeaponSet> myWeapons = new List<WeaponSet>();
 
     // *** control settings *** //
     private int selectedPrimary = 0;
     private int selectedSeccondry = 1;
     public bool weaponsEnabled = true;
 
     // *** player preferances *** //
     private bool useInverted = false;
     private bool useCruiseControl = false;
     private float mouseSensitivity = 1.0f;
 
 
 
     public bool movement = true;
 
     Vector3 mDelta;
     int mSteeringTouch = -1;
     float mNextPrimary = 0f;
     float mNextSecondary = 0f;
 
 
     // Use this for initialization
     void Start () 
     {
         // *** finding components section *** //
         // find the strikecraft physics script
         myPhysics = GetComponent<StrikeCraftFlightPhysics>();
 
         // *** applying info section *** //
         // error trap if no weapons found
         if(myWeapons.Count < 1)
         {
             weaponsEnabled = false;
             Debug.Log("No weapons were found on " + name);
             Debug.Log(myWeapons.Count);
         }
     
     }
 }
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

  • Sort: 
avatar image
0
Best Answer

Answer by Myth · Aug 20, 2014 at 12:33 AM

So I had it right, the thing had somehow cached the wrong script or something similar... Note to self, reset objects and restart computer... :(

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

Follow this Question

Answers Answers and Comments

21 People are following this question.

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

Related Questions

Distribute terrain in zones 3 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

C# Displaying a List in Series 2 Answers

Scripting and Coding Dictionary 0 Answers

Multiple Cars not working 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