/// <summary> /// /// </summary> protected void LoadContent() { ClearContent(); if (string.IsNullOrEmpty(_url)) { return; } _contentItem = UIPackage.GetItemByURL(_url); if (_contentItem != null) { _contentItem = _contentItem.getBranch(); _contentItem = _contentItem.getHighResolution(); _contentItem.Load(); if (_contentItem.type == PackageItemType.Spine) { #if FAIRYGUI_SPINE LoadSpine(); #endif } else if (_contentItem.type == PackageItemType.DragoneBones) { #if FAIRYGUI_DRAGONBONES LoadDragonBones(); #endif } } else { LoadExternal(); } }
public DisplayObject CreateObject(string src, ref int width, ref int height) { GLoader loader; if (pool.Count > 0) { loader = pool.Pop(); } else { loader = new GLoader(); loader.fill = FillType.ScaleFree; } loader.url = src; PackageItem pi = UIPackage.GetItemByURL(src); if (width != 0) { loader.width = width; } else { if (pi != null) { width = pi.width; } else { width = 20; } loader.width = width; } if (height != 0) { loader.height = height; } else { if (pi != null) { height = pi.height; } else { height = 20; } loader.height = height; } return(loader.displayObject); }
protected void LoadFromPackage(string itemURL) { _contentItem = UIPackage.GetItemByURL(itemURL); if (_contentItem != null) { _contentItem.Load(); if (_contentItem.type == PackageItemType.Image) { _image.texture = _contentItem.texture; _image.scale9Grid = _contentItem.scale9Grid; _image.scaleByTile = _contentItem.scaleByTile; _activeObject = _image; _contentSourceWidth = _contentItem.width; _contentSourceHeight = _contentItem.height; UpdateLayout(); } else if (_contentItem.type == PackageItemType.MovieClip) { if (_movieClip == null) { _movieClip = new MovieClip(); if (grayed) { _movieClip.SetGrayed(true); } _container.AddChild(_movieClip); } _contentSourceWidth = _contentItem.width; _contentSourceHeight = _contentItem.height; _movieClip.interval = _contentItem.interval; _movieClip.SetData(_contentItem.texture, _contentItem.frames); _movieClip.boundsRect = new Rect(0, 0, _contentSourceWidth, _contentSourceHeight); _movieClip.playing = _playing; _movieClip.currentFrame = _frame; _activeObject = _movieClip; UpdateLayout(); } else { SetErrorState(); } } else { SetErrorState(); } }
public static void SetPackageItemExtension(string url, JSObject jSObject) { if (url == null) { throw new Exception("Invaild url: " + url); } PackageItem pi = UIPackage.GetItemByURL(url); if (pi != null) { pi.jsObject = jSObject; } packageItemExtensionsPuerts[url] = jSObject; }
/// <summary> /// /// </summary> /// <param name="url"></param> /// <param name="creator"></param> public static void SetPackageItemExtension(string url, GComponentCreator creator) { if (url == null) { throw new Exception("Invaild url: " + url); } PackageItem pi = UIPackage.GetItemByURL(url); if (pi != null) { pi.extensionCreator = creator; } packageItemExtensions[url] = creator; }
protected void LoadFromPackage(string itemURL) { _contentItem = UIPackage.GetItemByURL(itemURL); if (_contentItem != null) { _contentItem.Load(); if (_contentItem.type == PackageItemType.Image) { _content.texture = _contentItem.texture; _content.scale9Grid = _contentItem.scale9Grid; _content.scaleByTile = _contentItem.scaleByTile; _content.tileGridIndice = _contentItem.tileGridIndice; _contentSourceWidth = _contentItem.width; _contentSourceHeight = _contentItem.height; UpdateLayout(); } else if (_contentItem.type == PackageItemType.MovieClip) { _contentSourceWidth = _contentItem.width; _contentSourceHeight = _contentItem.height; _content.interval = _contentItem.interval; _content.swing = _contentItem.swing; _content.repeatDelay = _contentItem.repeatDelay; _content.SetData(_contentItem.texture, _contentItem.frames, new Rect(0, 0, _contentSourceWidth, _contentSourceHeight)); UpdateLayout(); } else { if (_autoSize) { this.SetSize(_contentItem.width, _contentItem.height); } SetErrorState(); } } else { SetErrorState(); } }
/// <summary> /// 收集创建目标对象所需的所有类型信息 /// </summary> /// <param name="item"></param> /// <param name="list"></param> void CollectComponentChildren(PackageItem item, List<DisplayListItem> list) { if (!item.decoded) LoadComponent(item); if (item.displayList == null) LoadComponentChildren(item); int cnt = item.displayList.Length; for (int i = 0; i < cnt; i++) { DisplayListItem di = item.displayList[i]; if (di.packageItem != null && di.packageItem.type == PackageItemType.Component) CollectComponentChildren(di.packageItem, list); else if (di.type == "list") //也要收集列表的item { XMLList.Enumerator et = di.desc.GetEnumerator("item"); string defaultItem = null; di.listItemCount = 0; while (et.MoveNext()) { XML ix = et.Current; string url = ix.GetAttribute("url"); if (string.IsNullOrEmpty(url)) { if (defaultItem == null) defaultItem = di.desc.GetAttribute("defaultItem"); url = defaultItem; if (string.IsNullOrEmpty(url)) continue; } PackageItem pi = UIPackage.GetItemByURL(url); if (pi != null) { if (pi.type == PackageItemType.Component) CollectComponentChildren(pi, list); list.Add(new DisplayListItem(pi, null)); di.listItemCount++; } } } list.Add(di); } }
static int CollectListChildren(ByteBuffer buffer, List <DisplayListItem> list) { buffer.Seek(buffer.position, 8); string defaultItem = buffer.ReadS(); int listItemCount = 0; int itemCount = buffer.ReadShort(); for (int i = 0; i < itemCount; i++) { int nextPos = buffer.ReadShort(); nextPos += buffer.position; string url = buffer.ReadS(); if (url == null) { url = defaultItem; } if (!string.IsNullOrEmpty(url)) { PackageItem pi = UIPackage.GetItemByURL(url); if (pi != null) { DisplayListItem di = new DisplayListItem(pi, pi.objectType); if (pi.type == PackageItemType.Component) { di.childCount = CollectComponentChildren(pi, list); } list.Add(di); listItemCount++; } } buffer.position = nextPos; } return(listItemCount); }
protected void LoadFromPackage(string itemURL) { _contentItem = UIPackage.GetItemByURL(itemURL); if (_contentItem != null) { _contentItem = _contentItem.getBranch(); sourceWidth = _contentItem.width; sourceHeight = _contentItem.height; _contentItem = _contentItem.getHighResolution(); _contentItem.Load(); if (_contentItem.type == PackageItemType.Image) { _content.texture = _contentItem.texture; _content.textureScale = new Vector2(_contentItem.width / (float)sourceWidth, _contentItem.height / (float)sourceHeight); _content.scale9Grid = _contentItem.scale9Grid; _content.scaleByTile = _contentItem.scaleByTile; _content.tileGridIndice = _contentItem.tileGridIndice; UpdateLayout(); } else if (_contentItem.type == PackageItemType.MovieClip) { _content.interval = _contentItem.interval; _content.swing = _contentItem.swing; _content.repeatDelay = _contentItem.repeatDelay; _content.frames = _contentItem.frames; UpdateLayout(); } else if (_contentItem.type == PackageItemType.Component) { GObject obj = UIPackage.CreateObjectFromURL(itemURL); if (obj == null) { SetErrorState(); } else if (!(obj is GComponent)) { obj.Dispose(); SetErrorState(); } else { _content2 = (GComponent)obj; ((Container)displayObject).AddChild(_content2.displayObject); UpdateLayout(); } } else { if (_autoSize) { this.SetSize(_contentItem.width, _contentItem.height); } SetErrorState(); Debug.LogWarning("Unsupported type of GLoader: " + _contentItem.type); } } else { SetErrorState(); } }
protected void LoadFromPackage(string itemURL) { _contentItem = UIPackage.GetItemByURL(itemURL); if (_contentItem != null) { _contentItem.Load(); if (_contentItem.type == PackageItemType.Image) { _content.texture = _contentItem.texture; _content.scale9Grid = _contentItem.scale9Grid; _content.scaleByTile = _contentItem.scaleByTile; _content.tileGridIndice = _contentItem.tileGridIndice; _contentSourceWidth = _contentItem.width; _contentSourceHeight = _contentItem.height; UpdateLayout(); } else if (_contentItem.type == PackageItemType.MovieClip) { _contentSourceWidth = _contentItem.width; _contentSourceHeight = _contentItem.height; _content.interval = _contentItem.interval; _content.swing = _contentItem.swing; _content.repeatDelay = _contentItem.repeatDelay; _content.SetData(_contentItem.texture, _contentItem.frames, new Rect(0, 0, _contentSourceWidth, _contentSourceHeight)); UpdateLayout(); } else if (_contentItem.type == PackageItemType.Component) { _contentSourceWidth = _contentItem.width; _contentSourceHeight = _contentItem.height; GObject obj = UIPackage.CreateObjectFromURL(itemURL); if (obj == null) { SetErrorState(); } else if (!(obj is GComponent)) { obj.Dispose(); SetErrorState(); } else { _content2 = (GComponent)obj; ((Container)displayObject).AddChild(_content2.displayObject); UpdateLayout(); } } else { if (_autoSize) { this.SetSize(_contentItem.width, _contentItem.height); } SetErrorState(); } } else { SetErrorState(); } }