Forum rules - please read before posting.

Get Time played

Hello, I was wondering if AC by script, has somewhere the option to get the time played.
Thanks!

Comments

  • A custom script can be used to update a Global Integer variable by one every second:

    using UnityEngine;
    using AC;
    using System.Collections;
    
    public class TimePlayedRecorder : MonoBehaviour
    {
    
        public string variableName;
        private GVar variable;
    
        private void Start ()
        {
            DontDestroyOnLoad (gameObject);
            variable = GlobalVariables.GetVariable (variableName);
            StartCoroutine (UpdateTimer ());
        }
    
        private IEnumerator UpdateTimer ()
        {
            while (true)
            {
                yield return new WaitForSeconds (1f);
                variable.IntegerValue += 1;
            }
        }
    
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.