• 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 Mar 10, 2015 at 12:27 AM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by soft_sound · Aug 20, 2012 at 01:31 PM · referencecs0246

error CS0246 missing type or namespace...

Assets/Scripts/CaveIntroScr/CharacterClasses/BaseCharacterScr.cs(12,17): error CS0246: The type or namespace name `Vigor' could not be found. Are you missing a using directive or an assembly reference?

Assets/Scripts/CaveIntroScr/CharacterClasses/BaseCharacterScr.cs(13,17): error CS0246: The type or namespace name `Skill' could not be found. Are you missing a using directive or an assembly reference?


I'm quite annoyed with this error. I can't figure why it won't recognize my references. I'm sure the names are correct because I've copied and pasted the names. It recognizes one reference but doesn't like the other references. *All the scripts are in the same folder if that makes any difference. I'm new to C# so I could be doing this all wrong because I'm slightly tweaking a tutorial I'm following. Here is a snippet of what I'm doing. The bad formatting is from the code sample button. Any advice would be useful. Not sure if it matters, I'm using Unity 3.5.5f... and MD 2.8.2... Oh and ModifiedStatScr inherits from BaseStatScr just like in my AttributeScr script, not sure if that matters either...

I hope this is just a typo and not some logic error...

Script 1 ---

 using UnityEngine;
 using System.Collections;
 using System; // added for enum class  
 
 public class BaseCharacterScr : MonoBehaviour {
     
     private string _name;
     private int _level;
     private uint _freeExp; // no neg #'s
     
     private Attribute[] _primaryAttribute;
     private Vigor[] _vigor;
     private Skill[] _skill;
 
     
     public void Awake(){
         _name = string.Empty;
         _level = 0;
         _freeExp =0;
         
         //_primaryAttribute = new Attribute[Enum.GetValues(typeof(AttributeName)).Length];
         //_vigor = new Vigor[Enum.GetValues(typeof(VigorName)).Length];
         //_skill = new Skill[Enum.GetValues(typeof(SkillName)).Length];
     }}    

Here is a script that works. ------

 public class AttributeScr : BaseStatScr{
     
     public void Attribute(){
         ExpToLevel = 50;
         LvlModifier = 1.05f;
     }    
 }
 
 public enum AttributeName {
     Spirit, //- courage/attack
     Reason, //- logic/skill
     Nimbleness, //- dextrity, doging and concealment
     Muse, //- range of possible types of skills 
     Heart, //- Strength/determination
     Vigor, //- health effects
     Decorum, //- social skills/grace
     Readiness, //- Speed, countering, defense
     Focus //- chances of crit hit and learning abilites faster
     
 }    

Here are scripts that aren't working. ------

 public class VigorScr : ModifiedStatScr{
     private int _curValue;
     
     public void Vigor(){
         _curValue = 0;
         ExpToLevel = 50;
         LvlModifier =1.1f;
     }
     
     public int CurValue{
         get{
             if (_curValue > AdjustedBaseValue)
                 _curValue = AdjustedBaseValue;
                 return _curValue; }
         set{ _curValue = value;}
     }    
 }
 
 public enum VigorName{
     
     Health,
     Energy,
     Hunger,
     Thirst
     
 }    

Next script ------------------------

 //tells what skills the character has
 public class SkillScr : ModifiedStatScr {
     
     private bool _known;
     
     public void Skill(){
         _known = false;
         ExpToLevel = 25;
         LvlModifier =1.1f;    
     }    
     
     public bool Known{
         get{ return _known;}
         set{ _known = value;}
             
     }    
 }
 
 public enum SkillName{
     Melee_Offence,
     Melee_Defense,
     Range_Offence
     
 }    
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 aimozs · Mar 10, 2015 at 12:20 AM 0
Share

Not related at all, but I was wondering on what kind of game you were working on?! is it based on world of darkness?! Please P$$anonymous$$ me through the forum; Thanks!

avatar image meat5000 ♦ · Mar 10, 2015 at 12:25 AM 0
Share

You can contact members through the forum using 'Conversations'

1 Reply

  • Sort: 
avatar image
4
Best Answer

Answer by Kryptos · Aug 20, 2012 at 01:55 PM

Your classes are named VigorScr and SkillScr but you are trying to use type Vigor and Skill. Solution: either rename your classes or change the type used.

Note that in C# the script name and the class name should always be the same. You cannot have a class named VigorScr in a script file Vigor.cs.

edit: your syntax for the class constructor is also wrong. See Using Constructors.

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 Khada · Aug 20, 2012 at 01:57 PM 0
Share

Wow, not only did I miss that, but someone has managed to pull that off lol ._.

avatar image soft_sound · Aug 20, 2012 at 07:27 PM 0
Share

Yes, I looked it over later this morning and yes I was supposed to have used constructors. Thanks for your answer.

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

12 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

Related Questions

Best way to check which terrain im over? 1 Answer

Referencing a script works... but not on iOS 0 Answers

NullReferenceException: Object reference not set to an instance of an object 1 Answer

Creating a pointer variable to a GameObject inside a class that does not extend MonoBehavior? [C#] 2 Answers

Setting up reference to an inactive GameObject through script 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