Question by
importguru88 · Aug 08, 2016 at 09:38 PM ·
scripting problemscript errornamespaceglobal
MyClockScript.cs(6,14): error CS0101: The namespace `global::' already contains a definition for `MyClockScript'
I don't see the error anywhere and it's on two other scripts :
Here is the script :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class MyClockScript : MonoBehaviour
{
public int Minutes = 0;
public int Seconds = 0;
private Text m_text;
public float m_leftTime;
private float msecs;
private int savedSeconds;
public void Awake()
{
m_text = GetComponent<Text>();
msecs = 0.0f;
// the following allows you to either set Minutes && Seconds in the inspector
// or allows you to set m_leftTime in the inspector as the starting countdown for the clock
// Minutes && Seconds overrules m_leftTime
if ((Minutes == 0) && (Seconds == 0) && (m_leftTime != 0.0f))
{
// initialize Minutes & Seconds based on m_leftTime being set in the inspector
Minutes = Mathf.FloorToInt(m_leftTime / 60f);
Seconds = Mathf.FloorToInt(m_leftTime % 60f);
}
else if ((Minutes != 0) || (Seconds != 0))
{
// initialize m_leftTime based on Minutes or Seconds being set in the inspector
m_leftTime = (Minutes * 60) + Seconds;
}
savedSeconds = Seconds;
}
public void Update()
{
// count down in seconds
msecs += Time.deltaTime;
if(msecs >= 1.0f)
{
msecs -= 1.0f;
Seconds--;
if(Seconds < 0)
{
Seconds = 59;
Minutes--;
}
m_leftTime = (Minutes * 60) + Seconds;
}
if (Seconds != savedSeconds)
{
// Show current clock
m_text.text = string.Format("Time : {0}:{1:D2}", Minutes, Seconds);
savedSeconds = Seconds;
}
}
}
Comment
Answer by Rob2309 · Aug 09, 2016 at 12:40 AM
It seems that you have got several classes with the name MyClockScript, which is not allowed in C#
Your answer
Follow this Question
Related Questions
Several errors in my acceleration script trying to update variables from other scripts 0 Answers
error CS0103: The name `canvasGroup' does not exist in the current context 3 Answers
JavaScript Problem - BCE0043 - Unexpected Token Help 0 Answers
Hai guys i need help why my scripts not running "i will make button next3dobject and prev3dobject" 1 Answer
2 error messages i can't seem to fix (CS0101 and CS0111) 1 Answer