Пример #1
0
 protected void PrepareAddressable()
 {
     if (!isAwaitingAddressable && KickStarter.speechManager.referenceSpeechFiles == ReferenceSpeechFiles.ByAddressable && speechPlayableData.lineID >= 0)
     {
         SpeechLine speechLine = KickStarter.speechManager.GetLine(speechPlayableData.lineID);
         if (speechLine != null)
         {
             string filename = speechLine.GetFilename();
             Addressables.LoadAssetAsync <AudioClip>(filename).Completed += OnCompleteLoad;
             isAwaitingAddressable = true;
         }
     }
 }
Пример #2
0
            public string GetCellText(SpeechLine speechLine)
            {
                string cellText = " ";

                switch (columnType)
                {
                case ColumnType.DisplayText:
                    if (language > 0)
                    {
                        int translation = language - 1;
                        if (speechLine.translationText != null && speechLine.translationText.Count > translation)
                        {
                            cellText = speechLine.translationText[translation];
                        }
                    }
                    else
                    {
                        cellText = speechLine.text;
                    }
                    break;

                case ColumnType.Type:
                    cellText = speechLine.textType.ToString();
                    break;

                case ColumnType.AssociatedObject:
                    if (speechLine.isPlayer && string.IsNullOrEmpty(speechLine.owner) && speechLine.textType == AC_TextType.Speech)
                    {
                        cellText = "Player";
                    }
                    else
                    {
                        cellText = speechLine.owner;
                    }
                    break;

                case ColumnType.Scene:
                    cellText = speechLine.scene;
                    break;

                case ColumnType.Description:
                    cellText = speechLine.description;
                    break;

                case ColumnType.TagID:
                    cellText = speechLine.tagID.ToString();
                    break;

                case ColumnType.TagName:
                    SpeechTag speechTag = KickStarter.speechManager.GetSpeechTag(speechLine.tagID);
                    cellText = (speechTag != null) ? speechTag.label : "";
                    break;

                case ColumnType.SpeechOrder:
                    cellText = speechLine.OrderIdentifier;
                    if (cellText == "-0001")
                    {
                        cellText = string.Empty;
                    }
                    break;

                case ColumnType.AudioFilename:
                    if (speechLine.textType == AC_TextType.Speech)
                    {
                        if (speechLine.SeparatePlayerAudio())
                        {
                            string result = string.Empty;
                            for (int j = 0; j < KickStarter.settingsManager.players.Count; j++)
                            {
                                if (KickStarter.settingsManager.players[j].playerOb != null)
                                {
                                    string overrideName = KickStarter.settingsManager.players[j].playerOb.name;
                                    result += speechLine.GetFilename(overrideName) + ";";
                                }
                            }
                            cellText = result;
                        }
                        else
                        {
                            cellText = speechLine.GetFilename();
                        }
                    }
                    break;

                case ColumnType.AudioFilePresence:
                    if (speechLine.textType == AC_TextType.Speech)
                    {
                        bool hasAllAudio = speechLine.HasAllAudio();
                        if (hasAllAudio)
                        {
                            cellText = "Has all audio";
                        }
                        else
                        {
                            if (speechLine.HasAudio(0))
                            {
                                string missingLabel = "Missing ";
                                for (int i = 1; i < KickStarter.speechManager.languages.Count; i++)
                                {
                                    if (!speechLine.HasAudio(i))
                                    {
                                        missingLabel += KickStarter.speechManager.languages[i] + ", ";
                                    }
                                }
                                if (missingLabel.EndsWith(", "))
                                {
                                    missingLabel = missingLabel.Substring(0, missingLabel.Length - 2);
                                }
                                cellText = missingLabel;
                            }
                            else
                            {
                                cellText = "Missing main audio";
                            }
                        }
                    }
                    break;
                }


                if (string.IsNullOrEmpty(cellText))
                {
                    cellText = " ";
                }
                return(RemoveLineBreaks(cellText));
            }
Пример #3
0
        public override float Run()
        {
            if (KickStarter.dialog && KickStarter.stateHandler)
            {
                if (KickStarter.speechManager.referenceSpeechFiles == ReferenceSpeechFiles.ByAddressable && lineID >= 0)
                {
                                        #if AddressableIsPresent
                    if (!isRunning && !isAwaitingAddressable)
                    {
                        SpeechLine speechLine = KickStarter.speechManager.GetLine(lineID);
                        string     filename   = speechLine.GetFilename();
                        Addressables.LoadAssetAsync <AudioClip>(filename).Completed += OnCompleteLoad;
                        isAwaitingAddressable = true;
                        isRunning             = true;

                        return(defaultPauseTime);
                    }

                    if (isAwaitingAddressable)
                    {
                        return(defaultPauseTime);
                    }

                    if (isBackground)
                    {
                        isRunning = false;
                        return(0f);
                    }
                                        #else
                    LogWarning("Cannot use addressables system for speech audio because 'AddressableIsPresent' has not been added as a Scripting Define Symbol.  This can be added in Unity's Player settings.");
                                        #endif
                }

                if (!isRunning)
                {
                    stopAction = false;
                    isRunning  = true;
                    splitDelay = false;
                    splitIndex = 0;

                    StartSpeech();

                    if (isBackground)
                    {
                        if (KickStarter.speechManager.separateLines)
                        {
                            string[] textArray = messageText.Split(stringSeparators, System.StringSplitOptions.None);
                            if (textArray != null && textArray.Length > 1)
                            {
                                LogWarning("Cannot separate multiple speech lines when 'Is Background?' is checked - will only play '" + textArray[0] + "'");
                            }
                        }

                        isRunning = false;
                        return(0f);
                    }
                    return(defaultPauseTime);
                }
                else
                {
                    if (stopAction || (speech != null && speech.continueFromSpeech))
                    {
                        if (speech != null)
                        {
                            speech.continueFromSpeech = false;
                        }
                        isRunning = false;

                        return(0);
                    }

                    if (speech == null || !speech.isAlive)
                    {
                        if (KickStarter.speechManager.separateLines)
                        {
                            if (!splitDelay)
                            {
                                // Begin pause if more lines are present
                                splitIndex++;
                                string[] textArray = messageText.Split(stringSeparators, System.StringSplitOptions.None);

                                if (textArray.Length > splitIndex)
                                {
                                    if (KickStarter.speechManager.separateLinePause > 0f)
                                    {
                                        // Still got more to go
                                        splitDelay = true;
                                        return(KickStarter.speechManager.separateLinePause);
                                    }
                                    else
                                    {
                                        // Show next line
                                        splitDelay = false;
                                        StartSpeech();
                                        return(defaultPauseTime);
                                    }
                                }
                                // else finished
                            }
                            else
                            {
                                // Show next line
                                splitDelay = false;
                                StartSpeech();
                                return(defaultPauseTime);
                            }
                        }

                        float totalWaitTimeOffset = waitTimeOffset + KickStarter.speechManager.waitTimeOffset;
                        if (totalWaitTimeOffset <= 0f)
                        {
                            isRunning = false;
                            return(0f);
                        }
                        else
                        {
                            stopAction = true;
                            return(totalWaitTimeOffset);
                        }
                    }
                    else
                    {
                        return(defaultPauseTime);
                    }
                }
            }

            return(0f);
        }