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 /
  • Help Room /
avatar image
0
Question by johnnyBoy1986 · Mar 04, 2017 at 11:55 PM · timescripting beginnerexportingtime.time

Weird result using Time.time

Hi,

I'm trying to export some time data into a text file but I'm getting some weird results. The way I'm going about is by calling InvokeRepeating() on a function that I made called RecTime() shown below.

 void RecTime()
     {
         time.Add(Time.time); //Time.fixedTime
     }


Where the variable time is a private variable with the following type List, that I initialize in the Start() function using "new List". I've got a GUI button set up that calls CancelInvoke() to end the repeating calls as well exporting the data stored in variable time into a text file.

 void Start () {
         time = new List<float>();
 
         rb = GetComponent<Rigidbody>();
         InvokeRepeating("RecTime", tSample, interval);
     
 }




My issue is that instead of seeing different values for time I get the following line repeated System.Collections.Generic.List`1[System.Single].


Does anyone know what could be going wrong? The documentation for Time.time says that "The time at the beginning of this frame (Read Only). This is the time in seconds since the start of the game." So I'm assuming that because of InvokeRepeating() I'm calling Time.time in different frames and so I should be getting different time values stored in the List I made and those values should be exported to a file. But that's just not the case.


If I'm misunderstanding something about Time.time or if anyone sees a problem with the code or logic that I've posted please let me know, I really do appreciate it. Thanks in advance!


P.S. I also tried using Time.fixedTime but that gave the same result, if that makes a difference.

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 Commoble · Mar 05, 2017 at 04:57 AM

You're using Time.time properly, but you're probably exporting your data to the text file wrongly. Make sure you're exporting the actual float values inside the list, not the list object itself.

Comment
Add comment · Show 1 · 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 johnnyBoy1986 · Mar 05, 2017 at 07:41 AM 0
Share

Oh ok, yeah I was using some modified old code that wrote a List of Vector3's to a file and I didn't update it properly to meet my needs here. Thanks a lot for the help, I honestly appreciate it!

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

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

Real time at the beginning of the frame 1 Answer

How to Get Cumulative Gameplay Time 0 Answers

Change scene after event (time or clicking on object) 0 Answers

Pausing a Mathf.PingPong at the ends 0 Answers

UI animation when enter trigger, then destroy self after (X) time 0 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