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
-2
Question by Cascadex · Oct 26, 2014 at 04:03 PM ·

Error script

Alright so i question and error is Assets/Scripts/PC.cs(234,13):error cs0101: The namespace 'global;;' already contains a definition for 'Equipmentslot'

Heres the script i have and the above is the error i recieve when trying to go into playmode.I believe its on line 234,13 characters over.If anyone could please help me im new to scripting so this is out of my hands for now.Ive been stuck with this error for almost a day now i would greatly appreciate it if someone could direct me into the right direction.

Thankyou,

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 [AddComponentMenu("Hack And Slash Tutorial/Player/PC Stats")]
 public class PC : BaseCharacter {
     private List<Item> inventory = new List<Item>();
     public List<Item> Inventory {
         get { return inventory; }
         set { inventory = value; }
     }
     
     private Item[] _equipment = new Item[ (int)EquipmentSlot.COUNT ];
 
     
     public bool initialized = false;
 
     private static PC instance = null;
     public static PC Instance {
         get {
             if ( instance == null ) {
                 Debug.Log( "***PC - Instance***" );
                 GameObject go = Instantiate( Resources.Load(
                                              GameSetting2.MALE_MODEL_PATH + GameSetting2.maleModels[ GameSetting2.LoadCharacterModelIndex() ] ),
                                                 GameSetting2.LoadPlayerPosition(),
                                              Quaternion.identity ) as GameObject;
                 
                 PC temp = go.GetComponent<PC>();
                 
                 if( temp == null )
                     Debug.LogError( "Player Prefab does not contain an PC script. Please add and configure." );
                 
                 instance = go.GetComponent<PC>();
                 
                 go.name = "PC";
                 go.tag = "Player";
             }
             
             return instance;
         }
     }
     
     public void Initialize() {
         Debug.Log( "***PC - Initialize***" );
         if( !initialized )
             LoadCharacter();
     }
     
     #region Unity functions
     public new void Awake() {
         Debug.Log( "***PC - Awake***" );
 
         base.Awake();
 
         instance = this;
     }
     
 //    public override void Awake() {
 //        base.Awake();
 //        
 //        /**************************
 //        Check out tutorial #140 and #141 to see how we got this weaponMount
 //        **************************/
 //        Transform weaponMount = transform.Find("base/spine/spine_up/right_arm/right_foret_arm/right_hand/weaponSlot");
 //        
 //        if(weaponMount == null) {
 //            Debug.LogWarning("We could not find the weapon mount");
 //            return;
 //        }
 //        
 //        int count = weaponMount.GetChildCount();
 //        
 //        _weaponMesh = new GameObject[count];
 //        
 //        for(int cnt = 0; cnt < count; cnt++) {
 //            _weaponMesh[cnt] = weaponMount.GetChild(cnt).gameObject;
 //        }
 //
 //        HideWeaponMeshes();
 //    }
 //    
     //we do not want to be sending messages out each frame. We will be moving this out when we get back in to combat
     void Update() {
         Messenger<int, int>.Broadcast("player health update", 80, 100, MessengerMode.DONT_REQUIRE_LISTENER);
     }
     #endregion
 
 
     public Item EquipedWeapon {
         get { return _equipment[(int)EquipmentSlot.MainHand]; }
         set {
             _equipment[(int)EquipmentSlot.MainHand] = value;
             
             if( weaponMount.transform.childCount > 0 )
                 Destroy( weaponMount.transform.GetChild( 0 ).gameObject );
                       
             if( _equipment[ (int)EquipmentSlot.MainHand ] != null) {
                 GameObject mesh = Instantiate( Resources.Load( GameSetting2.MELEE_WEAPON_MESH_PATH + _equipment[(int)EquipmentSlot.MainHand].Name ), weaponMount.transform.position, weaponMount.transform.rotation ) as GameObject;
                 mesh.transform.parent = weaponMount.transform;
             }
         }
     }
     
 
     public Item EquipedShield {
         get { return _equipment[(int)EquipmentSlot.OffHand]; }
         set {
             _equipment[(int)EquipmentSlot.OffHand] = value;
             
             if( offHandMount.transform.childCount > 0 )
                 Destroy( offHandMount.transform.GetChild( 0 ).gameObject );
                       
             if( _equipment[(int)EquipmentSlot.OffHand] != null) {
                 GameObject mesh = Instantiate( Resources.Load( GameSetting2.SHIELD_MESH_PATH + _equipment[(int)EquipmentSlot.OffHand].Name ), offHandMount.transform.position, offHandMount.transform.rotation ) as GameObject;
                 mesh.transform.parent = offHandMount.transform;
             }
         }
     }
 
     
     public Item EquipedHeadGear {
         get { return _equipment[(int)EquipmentSlot.Head]; }
         set {
             _equipment[(int)EquipmentSlot.Head] = value;
             
             if( helmetMount.transform.childCount > 0 )
                 Destroy( helmetMount.transform.GetChild( 0 ).gameObject );
                       
             if( _equipment[(int)EquipmentSlot.Head] != null) {
                 GameObject mesh = Instantiate( Resources.Load( GameSetting2.HAT_MESH_PATH + _equipment[(int)EquipmentSlot.Head].Name ), helmetMount.transform.position, helmetMount.transform.rotation ) as GameObject;
                 mesh.transform.parent = helmetMount.transform;
                 
                 //scale
                 mesh.transform.localScale = hairMount.transform.GetChild(0).localScale;
                 
                 //hide player hair
                 hairMount.transform.GetChild(0).gameObject.active = false;
             }
         }
     }
     
     
     public void LoadCharacter() {
         GameSetting2.LoadAttributes();
         ClearModifiers();
         GameSetting2.LoadVitals();
         GameSetting2.LoadSkills();
         
         LoadHair();
         LoadSkinColor();
         
         LoadScale();
 
         initialized = true;
     }
     
     public void LoadScale() {
         Vector2 scale = GameSetting2.LoadCharacterScale();
         
         transform.localScale = new Vector3(
                                            transform.localScale.x * scale.x,
                                            transform.localScale.y * scale.y,
                                            transform.localScale.z * scale.x
                                            );
     }
     
     public void LoadHair() {
         LoadHairMesh();
         LoadHairColor();
     }
     
     public void LoadSkinColor() {
         characterMaterialMesh.renderer.materials[ (int)CharacterMaterialIndex.Face ].mainTexture = Resources.Load( GameSetting2.HEAD_TEXTURE_PATH + "head_" + GameSetting2.LoadHeadIndex() + "_" + GameSetting2.LoadSkinColor() + ".human") as Texture;
     }
 
     public void LoadHairMesh() {
         if( hairMount.transform.childCount > 0 )
             Object.Destroy( hairMount.transform.GetChild(0).gameObject );
 
         GameObject hairStyle;
         
         int hairMeshIndex = GameSetting2.LoadHairMesh();
 
         int hairSet = hairMeshIndex / 5 + 1;
         int hairIndex = hairMeshIndex % 5 + 1;
         
         hairStyle = Object.Instantiate( Resources.Load(
                                                        GameSetting2.HUMAN_MALE_HAIR_MESH_PATH + "Hair" + " " + hairSet + "_" + hairIndex ),
                                                           hairMount.transform.position,
                                                        hairMount.transform.rotation
                                                       ) as GameObject;
 
         hairStyle.transform.parent = PC.Instance.hairMount.transform;
         
         LoadHairColor();        
 
         MeshOffset mo = hairStyle.GetComponent<MeshOffset>();
         if( mo == null )
             return;
         
         hairStyle.transform.localPosition = mo.positionOffset;
         hairStyle.transform.localRotation = Quaternion.Euler( mo.rotationOffset );
         hairStyle.transform.localScale = mo.scaleOffset;
     }
     
     public void LoadHairColor() {
         Texture temp = Resources.Load( GameSetting2.HUMAN_MALE_HAIR_COLOR_PATH + ((HairColorNames)GameSetting2.LoadHairColor()).ToString()) as Texture;
         
         hairMount.transform.GetChild(0).renderer.material.mainTexture = temp;
     }
     
     public void LoadHelmet() {
     }
 
     public void LoadShoulderPads() {
     }
 
     public void LoadTorsoArmor() {
     }
     
     public void LoadGloves() {
     }
 
     public void LoadLegArmor() {
     }
 
     public void LoadBoots() {
     }
 
     public void LoadBackItem() {
     }
 }
 
 public enum EquipmentSlot {
     Head,
     Shoulders,
     Torso,
     Legs,
     Hands,
     Feet,
     Back,
     OffHand,
     MainHand,
     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

2 Replies

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

Answer by Itaros · Oct 26, 2014 at 04:39 PM

Your project instance already has "EquipmentSlot" definition somewhere. Isn't it obvious?

Comment
Add comment · Show 11 · 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 Cascadex · Oct 26, 2014 at 04:52 PM 0
Share

Where would this other "EquipmentSlot" definition be?And yes it did state it so it should be obvious to a beginner programmer but im not even a beginner yet i purchased these scripts and i believe i placed them all in the correct area what i would like to know is what do i need to do to the script to get it working if thats possible.

Thankyou,

avatar image Itaros · Oct 26, 2014 at 05:08 PM 0
Share

There is really no option without coding skills. You should try to develop your own systems before using bought ones. They will require accommodations to be performed anyway to interop

avatar image Cascadex · Oct 26, 2014 at 05:11 PM 0
Share

Wow so i wasted my time/money all because of 1 script that has 1 error?Is this what your telling me.If so thankyou for your quick responses and time ill figure it out on my own.

avatar image MarksTeq · Oct 26, 2014 at 06:02 PM 1
Share

The thing is, we don't know what your other scripts are... So we can't direct you to where it is being defined. You have to search through all your scripts until you find:

  public enum EquipmentSlot {
 Head,
 Shoulders,
 Torso,
 Legs,
 Hands,
 Feet,
 Back,
 OffHand,
 $$anonymous$$ainHand,
 COUNT
 }

or just remove it from this script

The error is saying: This part of your script is in another script. An enum is a sort of a named list. So when you create another enum with the same name as another one (as you are doing here, according to your error) it won't know which list to access, so it won't allow you to create one with the same name.

avatar image Kiwasi · Oct 26, 2014 at 09:39 PM 1
Share

If you paid for it go back to the publisher for support.

$$anonymous$$ono develop has a find references feature that will help you search.

Show more comments
avatar image
0

Answer by Cascadex · Oct 28, 2014 at 12:30 AM

It appears to me what i did was I removed the part of the code that was giving me the error where someone else stated by doing this resulted in a errorless script simply remove these few bottom lines (233-245) it seems the answer wasnt directed towards me in a way i could understand until i went in and had a look myself i do feel Marksteq has answered it in a informative way and he diserves all the credit thankyou.

  public enum EquipmentSlot {
      Head,
      Shoulders,
      Torso,
      Legs,
      Hands,
      Feet,
      Back,
      OffHand,
      MainHand,
      COUNT
  }
  
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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Calling A Function When A Variable Changes? Help 1 Answer

is there a way to replace script-made object to a custom one? 1 Answer

Photon Errors? 1 Answer

How to make buildings and characters in unity? 1 Answer

BCE0044 error 2 Answers


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