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
0
Question by AlexWM05 · Dec 16, 2013 at 05:37 AM · c#timercountdown3d text

Making a Timer Out out of 3D Text using C#.

Hey! The title practically says it all. But I should offer a bit of detail.

I am setting up a timer that is displayed in 3D text, and most of the tidbits I have obtained in regards to timers have limited to having the numbers displayed in GUI. So what alterations should I make in order for a timer script to work for 3D text?

  • Two digits are enough. I need 90 seconds on the clock.

  • the first 30 seconds will be dedicated to demonstrating the gameplay. Then the real game will run for the next 60 seconds until it's over.

  • the timer should go off immediately when the scene runs.

  • Beyond the 3D text displaying the timer, there can be some other 3D texts displaying like booleans, like the word 'START' when the 30 seconds pass and 'stop' when the last 60 seconds are up.

Thank you all for your patience and your passion with the software!

Comment
Add comment · Show 1
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 AlexWM05 · Dec 16, 2013 at 06:14 AM 0
Share

I should have mentioned in my description that my $$anonymous$$m wants me to have this written in c# format, not in javascript.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by robertbu · Dec 16, 2013 at 05:41 AM

This reads like a recipe for someone to write a script for you. Here is a basic setup you can extend with your other features.

  • Do: Game Object > Create Other > 3D Text

  • Size and position the text in the window

  • Add the following script to the game object (labeled 'New Text' in the Hierarchy window):


    pragma strict

    var time = 90.0; private var tm : TextMesh;

    function Start () { tm = GetComponent(TextMesh); }

    function Update () { time -= Time.deltaTime; tm.text = Mathf.RoundToInt(time).ToString(); }

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 xt-xylophone · Dec 16, 2013 at 05:45 AM 0
Share

Also if you want your time formatted as something like 5:32

 int $$anonymous$$utes, seconds;
 $$anonymous$$utes = time/60;
 seconds = time%60;
 if(seconds < 10)
     tm.text =""+$$anonymous$$utes+":0"+seconds;
 else
     tm.text =""+$$anonymous$$utes+":"+seconds;
avatar image robertbu · Dec 16, 2013 at 06:19 AM 0
Share

$$anonymous$$nowing just a few basics will allow you to mostly if not completely translate a high percentage of scripts that come across this list. Here is a reference link:

http://answers.unity3d.com/questions/12911/what-are-the-syntax-differences-in-c-and-javascrip.html

And here is the C# translation of the script above:

 using UnityEngine;
 using System.Collections;
 
 public class Timer : $$anonymous$$onoBehaviour {
 
     public float time = 90.0f;
     Text$$anonymous$$esh tm;
     
     void Start () {
         tm = GetComponent<Text$$anonymous$$esh>();
     }
     
     void Update () {
         time -= Time.deltaTime;
         tm.text = $$anonymous$$athf.RoundToInt(time).ToString();
     }
 }


avatar image AlexWM05 · Dec 16, 2013 at 07:11 AM 0
Share

I'll definitely look into it. Thanks!

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

17 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

Related Questions

How can I display the GAME OVER word across the centre of the screen when the when my timer hits zero? 3 Answers

how to Subtract string from TimeSpan 0 Answers

How to reset timer? (C#) 3 Answers

Timer doesn't work properly 2 Answers

Create a countdown in C# (inside Coroutine) 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