public static CombBulletScreenDisplayer Create(BulletScreenDisplayerModel displayerInfo) { CombBulletScreenDisplayer instance = displayerInfo.Owner.gameObject.AddComponent <CombBulletScreenDisplayer>(); instance._info = displayerInfo; return(instance); }
[SerializeField] private float _bodyImageheight; //图片body的长度... //TODO:video, add later... //TODO:video需要居中显示.... /// <summary> /// Create the specified displayer, textContent, showBox and direction. /// 创建多媒体弹幕.... /// </summary> /// <param name="displayer">Displayer.</param> /// <param name="textContent">Text content.</param> /// <param name="showBox">If set to <c>true</c> show box.</param> /// <param name="direction">Direction.</param> public static CombScreenTextElement Create(CombBulletScreenDisplayer displayer, string name, string htmlText, bool showBox = false, ScrollDirection direction = ScrollDirection.RightToLeft, Sprite head = null, Sprite photo = null) { CombScreenTextElement instance = null; if (displayer == null) { Debug.Log("CombScreenTextElement.Create(), displayer can not be null !"); return(null); } GameObject go = Instantiate(displayer.CombTextElementPrefab) as GameObject; go.transform.SetParent(displayer.GetTempRoot()); go.transform.localPosition = Vector3.up * 1000F; go.transform.localScale = Vector3.one; //add text... //RectTransform rect = go.GetComponent<RectTransform> (); //rect.rect.height = 100; //rect.rect.width = 100; instance = go.AddComponent <CombScreenTextElement>(); instance._displayer = displayer; instance._nameText = name; instance._htmlContent = htmlText; instance._showBox = showBox; instance._scrollDirection = direction; //set photo and image photo... instance._head = head; instance._image = photo; return(instance); }