示例#1
0
        private Texture2D GetPortrait(Transform character, Actor actor)
        {
            Texture2D portrait = null;

            if (character != null)
            {
                OverrideActorName overrideActorName = character.GetComponentInChildren <OverrideActorName>();
                if (overrideActorName != null)
                {
                    portrait = GetPortraitByActorName(overrideActorName.GetOverrideName());
                }
                if (portrait == null)
                {
                    portrait = GetPortraitByActorName(character.name);
                }
            }
            if ((portrait == null) && (actor != null))
            {
                portrait = GetPortraitByActorName(actor.Name);
                if (portrait == null)
                {
                    portrait = actor.portrait;
                }
            }
            return(portrait);
        }
示例#2
0
        public static void DrawOverrideNameSubsection(GameObject character)
        {
            EditorGUILayout.LabelField("Override Actor Name", EditorStyles.boldLabel);
            OverrideActorName overrideActorName = character.GetComponent <OverrideActorName>();

            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox(string.Format("By default, the dialogue UI will use the name of the GameObject ({0}). You can override it below.", character.name), MessageType.Info);
            EditorGUILayout.BeginHorizontal();
            bool hasOverrideActorName = EditorGUILayout.Toggle((overrideActorName != null), GUILayout.Width(ToggleWidth));

            EditorGUILayout.LabelField("Override actor name", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            if (hasOverrideActorName)
            {
                if (overrideActorName == null)
                {
                    overrideActorName = character.AddComponent <OverrideActorName>();
                }
                overrideActorName.overrideName = EditorGUILayout.TextField("Actor Name", overrideActorName.overrideName);
            }
            else
            {
                DestroyImmediate(overrideActorName);
            }
            EditorWindowTools.EndIndentedSection();
            EditorWindowTools.DrawHorizontalLine();
        }
示例#3
0
        /// <summary>
        /// Gets the name of the actor, either from the GameObject or its OverrideActorComponent
        /// if present.
        /// </summary>
        /// <returns>The actor name.</returns>
        /// <param name="t">The actor's transform.</param>
        public static string GetActorName(Transform t)
        {
            OverrideActorName overrideActorName = t.GetComponentInChildren <OverrideActorName>();

            if (overrideActorName == null && t.parent != null)
            {
                overrideActorName = t.parent.GetComponent <OverrideActorName>();
            }
            return(((overrideActorName == null) || string.IsNullOrEmpty(overrideActorName.overrideName)) ? t.name : overrideActorName.GetOverrideName());
        }
示例#4
0
 public virtual void Start()
 {
     if (string.IsNullOrEmpty(overrideName))
     {
         OverrideActorName overrideActorName = GetComponentInChildren <OverrideActorName>();
         if (overrideActorName != null)
         {
             overrideName = overrideActorName.overrideName;
         }
     }
 }
 public void Start()
 {
     if (string.IsNullOrEmpty(overrideActorName))
     {
         OverrideActorName globalOverrideActorName = GetComponentInChildren <OverrideActorName>();
         if (globalOverrideActorName != null)
         {
             overrideActorName = globalOverrideActorName.GetOverrideName();
         }
     }
 }
示例#6
0
 /// <summary>
 /// Initializes a new CharacterInfo.
 /// </summary>
 /// <param name='actorID'>
 /// Actor ID.
 /// </param>
 /// <param name='actorName'>
 /// Name of the actor as defined in the dialogue database.
 /// </param>
 /// <param name='transform'>
 /// Transform.
 /// </param>
 /// <param name='characterType'>
 /// Character type.
 /// </param>
 /// <param name='portrait'>
 /// Portrait.
 /// </param>
 public CharacterInfo(int id, string nameInDatabase, Transform transform, CharacterType characterType, Texture2D portrait)
 {
     this.id             = id;
     this.nameInDatabase = nameInDatabase;
     this.characterType  = characterType;
     this.portrait       = portrait;
     this.transform      = transform;
     if ((transform == null) && !string.IsNullOrEmpty(nameInDatabase))
     {
         GameObject go = SequencerTools.FindSpecifier(nameInDatabase);
         if (go != null)
         {
             this.transform = go.transform;
         }
     }
     Name = (transform == null) ? nameInDatabase : OverrideActorName.GetActorName(transform);
 }
示例#7
0
        // NOTE: This function is called at runtime and edit time.  Keep that in mind when setting the values of properties.
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            GameObject trackBinding = playerData as GameObject;

            if (!trackBinding)
            {
                return;
            }

            int inputCount = playable.GetInputCount();

            for (int i = 0; i < inputCount; i++)
            {
                float inputWeight = playable.GetInputWeight(i);
                if (inputWeight > 0.001f && !played.Contains(i))
                {
                    played.Add(i);
                    ScriptPlayable <StartConversationBehaviour> inputPlayable = (ScriptPlayable <StartConversationBehaviour>)playable.GetInput(i);
                    StartConversationBehaviour input = inputPlayable.GetBehaviour();
                    if (Application.isPlaying)
                    {
                        if (input.entryID <= 0)
                        {
                            DialogueManager.StartConversation(input.conversation, trackBinding.transform, input.conversant);
                        }
                        else
                        {
                            DialogueManager.StartConversation(input.conversation, trackBinding.transform, input.conversant, input.entryID);
                        }
                    }
                    else
                    {
                        var message = OverrideActorName.GetActorName(trackBinding.transform) + " conversation: " + input.conversant;
                        PreviewUI.ShowMessage(message, 2, 0);
                    }
                }
                else if (inputWeight <= 0.001f && played.Contains(i))
                {
                    played.Remove(i);
                }
            }
        }
示例#8
0
        // NOTE: This function is called at runtime and edit time.  Keep that in mind when setting the values of properties.
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            GameObject trackBinding = playerData as GameObject;

            if (!trackBinding)
            {
                return;
            }

            int inputCount = playable.GetInputCount();

            for (int i = 0; i < inputCount; i++)
            {
                float inputWeight = playable.GetInputWeight(i);
                if (inputWeight > 0.001f && !played.Contains(i))
                {
                    played.Add(i);
                    ScriptPlayable <BarkBehaviour> inputPlayable = (ScriptPlayable <BarkBehaviour>)playable.GetInput(i);
                    BarkBehaviour input = inputPlayable.GetBehaviour();
                    if (Application.isPlaying)
                    {
                        if (input.useConversation)
                        {
                            DialogueManager.Bark(input.conversation, trackBinding.transform, input.listener);
                        }
                        else
                        {
                            DialogueManager.BarkString(input.text, trackBinding.transform, input.listener);
                        }
                    }
                    else
                    {
                        var message = OverrideActorName.GetActorName(trackBinding.transform) + " bark: " + input.GetEditorBarkText();
                        PreviewUI.ShowMessage(message, 2, 1);
                    }
                }
                else if (inputWeight <= 0.001f && played.Contains(i))
                {
                    played.Remove(i);
                }
            }
        }
示例#9
0
 private string GetBarkerName()
 {
     return(OverrideActorName.GetActorName(GetBarker()));
 }