コード例 #1
0
 /// <summary>
 /// Sends the OnRecordPersistentData message to all game objects in the scene to give them
 /// an opportunity to record their state in the Lua environment. Runs in batches specified
 /// by  the value of asyncGameObjectBatchSize.
 /// </summary>
 public static void RecordAsync()
 {
     if (DialogueDebug.logInfo)
     {
         Debug.Log(string.Format("{0}: Recording persistent data to Lua environment in batches of {1} GameObjects.", new System.Object[] { DialogueDebug.Prefix, asyncGameObjectBatchSize }));
     }
     DialogueManager.instance.StartCoroutine(Tools.SendMessageToEveryoneAsync("OnRecordPersistentData", asyncGameObjectBatchSize));
 }
コード例 #2
0
        private static IEnumerator GetSaveDataAsyncCoroutine(AsyncSaveOperation asyncOp)
        {
            if (DialogueDebug.logInfo)
            {
                Debug.Log(string.Format("{0}: Saving data asynchronously...", new System.Object[] { DialogueDebug.Prefix, asyncGameObjectBatchSize }));
            }

            switch (recordPersistentDataOn)
            {
            case RecordPersistentDataOn.AllGameObjects:
                yield return(DialogueManager.instance.StartCoroutine(Tools.SendMessageToEveryoneAsync("OnRecordPersistentData", asyncGameObjectBatchSize)));

                break;

            case RecordPersistentDataOn.OnlyRegisteredGameObjects:
                int count = 0;
                foreach (var go in listeners)
                {
                    if (go != null)
                    {
                        go.SendMessage("OnRecordPersistentData", SendMessageOptions.DontRequireReceiver);
                        count++;
                        if (count > asyncGameObjectBatchSize)
                        {
                            count = 0;
                            yield return(null);
                        }
                    }
                }
                break;

            default:
                break;
            }
            StringBuilder sb = new StringBuilder(); //---Was: new StringBuilder(stringDataStartCapacity, stringDataMaxCapacity);

            AppendVariableData(sb);
            yield return(null);

            AppendItemData(sb);
            yield return(null);

            AppendLocationData(sb);
            yield return(null);

            if (includeActorData)
            {
                AppendActorData(sb);
            }
            yield return(null);

            yield return(DialogueManager.instance.StartCoroutine(AppendConversationDataAsync(sb)));

            yield return(null);

            if (includeRelationshipAndStatusData)
            {
                AppendRelationshipAndStatusTables(sb);
            }
            if (GetCustomSaveData != null)
            {
                sb.Append(GetCustomSaveData());
            }
            string saveData = sb.ToString();

            if (DialogueDebug.logInfo)
            {
                Debug.Log(string.Format("{0}: Saved data asynchronously: {1}", new System.Object[] { DialogueDebug.Prefix, saveData }));
            }
            asyncOp.content = saveData;
            asyncOp.isDone  = true;
        }