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 svaldenegro · May 05, 2015 at 08:37 PM · c#unity5issue

I can't acces to a class from other class

Hi I'm making modification to the rolller ball standart asset but is can find the other Class where i've saved my variables. In unity 5.

 //This is one class
 using UnityEngine;
 using System.Collections;
 
 public static class StaticVariablesGame
 {
     public static int PLAYER_LAYER_NUMBER = 8;
     public static int PLAYER_LAYER_MASK = (1 << PLAYER_LAYER_NUMBER);
 }

 // This is on other class. Ball.cs without namespace
 Collider[] colliders = Physics.OverlapSphere(transform.position, angleDetection, ~(StaticVariablesGame.PLAYER_LAYER_MASK)); // The name `StaticVariablesGame' does not exist in the current context


Comment
Add comment · Show 1
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 Ilgiz · May 05, 2015 at 09:23 PM 0
Share

restart Unity)

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · May 05, 2015 at 09:30 PM

If you don't use namespaces (and it doesn't look like you do) the only possible reason is that your static class is in the normal script-compilation-group and the script that tries to access it is in the first-compilation-group.

Things in the special folders (Standard Assets, Plugins, ...) are compiled before the normal scripts. They can't access anything outside the first compilation group because that is compiled afterwards. The scripts in the normal group (outside those special folders) are compiled after the first group and can access things declared in the first group as well as in the normal group.

So either move your static class into the Standard Assets folder or move the class that uses your static class out of those folders.

See those links for more details:

http://docs.unity3d.com/Manual/ScriptCompileOrderFolders.html
http://docs.unity3d.com/412/Documentation/ScriptReference/index.Script_compilation_28Advanced29.html

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 svaldenegro · May 06, 2015 at 01:30 AM 0
Share

But there's a way to change it? and why unity do that?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to set high score and have it displayed 1 Answer

This is only activating the hat locally or an all clients or no clients. 1 Answer

How to define a slider on script file? 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