FairyGUI.GComponent.ConstructFromResource C# (CSharp) Method

ConstructFromResource() private method

private ConstructFromResource ( List objectPool, int poolIndex ) : void
objectPool List
poolIndex int
return void
        internal void ConstructFromResource(List<GObject> objectPool, int poolIndex)
        {
            this.gameObjectName = packageItem.name;

            XML xml = packageItem.componentData;

            string str;
            string[] arr;

            underConstruct = true;

            arr = xml.GetAttributeArray("size");
            sourceWidth = int.Parse(arr[0]);
            sourceHeight = int.Parse(arr[1]);
            initWidth = sourceWidth;
            initHeight = sourceHeight;

            SetSize(sourceWidth, sourceHeight);

            arr = xml.GetAttributeArray("pivot");
            if (arr != null)
            {
                float f1 = float.Parse(arr[0]);
                float f2 = float.Parse(arr[1]);
                this.SetPivot(f1, f2, xml.GetAttributeBool("anchor"));
            }

            this.opaque = xml.GetAttributeBool("opaque", true);
            arr = xml.GetAttributeArray("hitTest");
            if (arr != null)
            {
                PixelHitTestData hitTestData = packageItem.owner.GetPixelHitTestData(arr[0]);
                if (hitTestData != null)
                    this.rootContainer.hitArea = new PixelHitTest(hitTestData, int.Parse(arr[1]), int.Parse(arr[2]));
            }

            OverflowType overflow;
            str = xml.GetAttribute("overflow");
            if (str != null)
                overflow = FieldTypes.ParseOverflowType(str);
            else
                overflow = OverflowType.Visible;

            str = xml.GetAttribute("margin");
            if (str != null)
                _margin.Parse(str);

            if (overflow == OverflowType.Scroll)
            {
                ScrollType scroll;
                str = xml.GetAttribute("scroll");
                if (str != null)
                    scroll = FieldTypes.ParseScrollType(str);
                else
                    scroll = ScrollType.Vertical;

                ScrollBarDisplayType scrollBarDisplay;
                str = xml.GetAttribute("scrollBar");
                if (str != null)
                    scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str);
                else
                    scrollBarDisplay = ScrollBarDisplayType.Default;

                int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags");

                Margin scrollBarMargin = new Margin();
                str = xml.GetAttribute("scrollBarMargin");
                if (str != null)
                    scrollBarMargin.Parse(str);

                string vtScrollBarRes = null;
                string hzScrollBarRes = null;
                arr = xml.GetAttributeArray("scrollBarRes");
                if (arr != null)
                {
                    vtScrollBarRes = arr[0];
                    hzScrollBarRes = arr[1];
                }

                SetupScroll(scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags, vtScrollBarRes, hzScrollBarRes);
            }
            else
                SetupOverflow(overflow);

            arr = xml.GetAttributeArray("clipSoftness");
            if (arr != null)
                this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1]));

            _buildingDisplayList = true;

            XMLList.Enumerator et = xml.GetEnumerator("controller");
            Controller controller;
            while (et.MoveNext())
            {
                controller = new Controller();
                _controllers.Add(controller);
                controller.parent = this;
                controller.Setup(et.Current);
            }

            GObject child;

            DisplayListItem[] displayList = packageItem.displayList;
            int childCount = displayList.Length;
            for (int i = 0; i < childCount; i++)
            {
                DisplayListItem di = displayList[i];
                if (objectPool != null)
                    child = objectPool[poolIndex + i];
                else if (di.packageItem != null)
                {
                    di.packageItem.Load();
                    child = UIObjectFactory.NewObject(di.packageItem);
                    child.packageItem = di.packageItem;
                    child.ConstructFromResource();
                }
                else
                    child = UIObjectFactory.NewObject(di.type);

                child.underConstruct = true;
                child.Setup_BeforeAdd(di.desc);
                child.InternalSetParent(this);
                _children.Add(child);
            }

            this.relations.Setup(xml);

            for (int i = 0; i < childCount; i++)
                _children[i].relations.Setup(displayList[i].desc);

            for (int i = 0; i < childCount; i++)
            {
                child = _children[i];
                child.Setup_AfterAdd(displayList[i].desc);
                child.underConstruct = false;
                if (child.displayObject != null)
                    ToolSet.SetParent(child.displayObject.cachedTransform, this.displayObject.cachedTransform);
            }

            str = xml.GetAttribute("mask");
            if (str != null)
                this.mask = GetChildById(str).displayObject;

            et = xml.GetEnumerator("transition");
            while (et.MoveNext())
            {
                Transition trans = new Transition(this);
                trans.Setup(et.Current);
                _transitions.Add(trans);
            }

            if (_transitions.Count > 0)
            {
                this.onAddedToStage.Add(__addedToStage);
                this.onRemovedFromStage.Add(__removedFromStage);
            }

            ApplyAllControllers();

            _buildingDisplayList = false;
            underConstruct = false;

            BuildNativeDisplayList();
            SetBoundsChangedFlag();

            ConstructFromXML(xml);
        }

Same methods

GComponent::ConstructFromResource ( ) : void

Usage Example

 static int ConstructFromResource(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         FairyGUI.GComponent obj = (FairyGUI.GComponent)ToLua.CheckObject(L, 1, typeof(FairyGUI.GComponent));
         obj.ConstructFromResource();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
All Usage Examples Of FairyGUI.GComponent::ConstructFromResource