/// <summary> /// Starts the component by adding a bark label to the UIBarkRoot object, which should /// be found in an NGUI UI. /// </summary> public void Start() { if (UIBarkRoot.rootObject != null) { if ((template != null) && (template.GetComponent <UILabel>() != null)) { // Create a label using the template: GameObject labelObject = Instantiate(template.gameObject) as GameObject; labelObject.transform.parent = UIBarkRoot.rootObject.transform; label = labelObject.GetComponent <UILabel>(); } else { // Create a label using the specified properties: label = NGUITools.AddWidget <UILabel>(UIBarkRoot.rootObject); if ((font == null) && DialogueDebug.LogWarnings) { Debug.LogError(string.Format("{0}: No font assigned to NGUIBarkUI on {1}.", DialogueDebug.Prefix, name)); } label.bitmapFont = font; label.color = color; label.effectStyle = effect; label.overflowMethod = UILabel.Overflow.ResizeFreely; } // Set up the label but leave it invisible for now: label.gameObject.name = string.Format("Bark ({0})", name); if (followBarker) { followTarget = label.gameObject.GetComponent <NGUIFollowTarget>() ?? label.gameObject.AddComponent <NGUIFollowTarget>(); followTarget.target = (overrideBarkerTransform != null) ? overrideBarkerTransform : this.transform; } else { Destroy(label.gameObject.GetComponent <NGUIFollowTarget>()); } label.gameObject.SetActive(false); } else { if (DialogueDebug.LogErrors) { Debug.LogWarning(string.Format("{0}: No UIBarkRoot found in scene. Add one to your NGUI UI.", DialogueDebug.Prefix)); } } }
/// <summary> /// Starts the component by adding a bark label to the UIBarkRoot object, which should /// be found in an NGUI UI. /// </summary> public void Start() { if (UIBarkRoot.rootObject != null) { if ((template != null) && (template.GetComponent<UILabel>() != null)) { // Create a label using the template: GameObject labelObject = Instantiate(template.gameObject) as GameObject; labelObject.transform.parent = UIBarkRoot.rootObject.transform; label = labelObject.GetComponent<UILabel>(); } else { // Create a label using the specified properties: label = NGUITools.AddWidget<UILabel>(UIBarkRoot.rootObject); if ((font == null) && DialogueDebug.LogWarnings) Debug.LogError(string.Format("{0}: No font assigned to NGUIBarkUI on {1}.", DialogueDebug.Prefix, name)); label.bitmapFont = font; label.color = color; label.effectStyle = effect; label.overflowMethod = UILabel.Overflow.ResizeFreely; } // Set up the label but leave it invisible for now: label.gameObject.name = string.Format("Bark ({0})", name); if (followBarker) { followTarget = label.gameObject.GetComponent<NGUIFollowTarget>() ?? label.gameObject.AddComponent<NGUIFollowTarget>(); followTarget.target = (overrideBarkerTransform != null) ? overrideBarkerTransform : this.transform; } else { Destroy(label.gameObject.GetComponent<NGUIFollowTarget>()); } label.gameObject.SetActive(false); } else { if (DialogueDebug.LogErrors) Debug.LogWarning(string.Format("{0}: No UIBarkRoot found in scene. Add one to your NGUI UI.", DialogueDebug.Prefix)); } }