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); }
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(); }
/// <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()); }
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(); } } }
/// <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); }
// 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); } } }
// 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); } } }
private string GetBarkerName() { return(OverrideActorName.GetActorName(GetBarker())); }