Quantcast
Channel: Questions in topic: "namespace"
Viewing all articles
Browse latest Browse all 398

MyClockScript.cs(6,14): error CS0101: The namespace `global::' already contains a definition for `MyClockScript'

$
0
0
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(); 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; } } }

Viewing all articles
Browse latest Browse all 398

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>