Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Feris7564XD · Jan 21, 2018 at 09:00 AM · error message

Help! error CS0101 : The namespace 'global::' already contains a definition for 'StatyPostaci;

 using UnityEngine;
 using System.Collections;
 
 
 public class StatyPostaci : MonoBehaviour {
 
 
     private float MaxZycie = 100;
     public float AktualneZycie = 100;
     private float MaxNawodnienie = 100;
     public float AktualneNawodnienie = 100;
     private float MaxGlod = 100;
     public float AktualnyGlod = 100;
 
     public Texture2D ZycieTextura;
     public Texture2D NawodnienieTextura;
     public Texture2D GlodTextura;
 
     private float barWidth;
     private float barHeight;
 
     public float timerGlodu = 40;
     public float timerNawodnienia = 10;
     public float timerZycia = 5;
 
 
     void Awake() {
 
         barHeight = Screen.height * 0.02f;
         barWidth = barHeight * 10.0f;
 
     }
 
     void OnGUI() {
 
         GUI.DrawTexture (new Rect (Screen.width - barWidth - 10,
                                  Screen.height - barHeight - 10,
                                  AktualneZycie * barWidth / MaxZycie,
                                  barHeight), ZycieTextura);
         GUI.DrawTexture (new Rect (Screen.width - barWidth - 10,
                                    Screen.height - barHeight * 2 - 10,
                                    AktualneNawodnienie * barWidth / MaxNawodnienie,
                                    barHeight), NawodnienieTextura);
         GUI.DrawTexture (new Rect (Screen.width - barWidth - 10,
                                    Screen.height - barHeight * 3 - 10,
                                    AktualnyGlod * barWidth / MaxGlod,
                                    barHeight), GlodTextura);
 
 
 
     }
 
 
     void Start () {
     
     }
 
 
 
     void Update () {
     
         if (AktualneZycie <= 0) {
 
             AktualneZycie = 0;
         }
         if (AktualnyGlod <= 0) {
             
             AktualnyGlod = 0;
         }
         if (AktualneNawodnienie <= 0) {
             
             AktualneNawodnienie = 0;
         }
         if (AktualneNawodnienie >=100) {
             
             AktualneNawodnienie = 100;
         }
         if (AktualneZycie >=100) {
             
             AktualneZycie = 100;
         }
         if (AktualnyGlod >=100) {
             
             AktualnyGlod = 100;
         }
         timerGlodu -= Time.deltaTime;
         timerNawodnienia -= Time.deltaTime;
         if (timerGlodu <= 0) {
             AktualnyGlod -= 20;
 
             timerGlodu = 40;
         }
         if (timerNawodnienia <= 0) {
             AktualneNawodnienie -= 5;
             
             timerNawodnienia = 10;
         }
 
         if (AktualnyGlod <= 1) {
             timerZycia -= Time.deltaTime;
             if(timerZycia <=0){
                 AktualneZycie -= 5;
                 timerZycia = 5;
             }
         }
 
 
     }
 }
 

Line 5

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

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

Answer by KittenSnipes · Jan 21, 2018 at 10:15 AM

@Feris7564XD

What I did to fix this was delete the script, copy the code, close unity, reopen it, reload the project, remake the exact script and then paste my code. There could be better ways but it is what I always do when I get that error.

Comment
Add comment · Show 3 · 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 Feris7564XD · Jan 21, 2018 at 10:33 AM 0
Share

Thanks :D You nice

avatar image KittenSnipes Feris7564XD · Jan 21, 2018 at 10:34 AM 0
Share

@Feris7564XD

No problem glad I could help :D

avatar image PizzaPie · Jan 21, 2018 at 10:59 AM 0
Share

The error means that you have two classes with the same name on the same namespace that being global, as it is unspecified. To fix it either change the name of either one or move either or both inside a different namespace. As why this fix works its probably if you create and delete a class with same name multiple times probably it fails to reload/recreate properly the assembly, in which occasion just reloading the assemblies should fix the issue.

Cheers!

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

76 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 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 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 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

My Unity is buggy after 5.6.0 update 1 Answer

Cannot paint textures onto terrain, errors are raised 0 Answers

Games runs perfectly on editor but error on build 1 Answer

"Could Not Produce Class with ID 1108" error 0 Answers

If you solve my this problem I`ll give you 100 points. My problem is --Cannot download entry--. 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