FairyGUI.Utils.ToolSet.SetParent C# (CSharp) Method

SetParent() public static method

public static SetParent ( Transform t, Transform parent ) : void
t UnityEngine.Transform
parent UnityEngine.Transform
return void
        public static void SetParent(Transform t, Transform parent)
        {
            if ((object)t.parent == (object)t)
                return;

            #if (UNITY_4_6 || UNITY_4_7 || UNITY_5)
                t.SetParent(parent, false);
            #else
            Vector3 p = t.localPosition;
            Vector3 s = t.localScale;
            Quaternion q = t.localRotation;
            t.parent = parent;
            t.localPosition = p;
            t.localScale = s;
            t.localRotation = q;
            #endif
        }

Usage Example

Example #1
0
        virtual public void FreeObject(IHtmlObject obj)
        {
            obj.Release();
            if (!Application.isPlaying)
            {
                obj.Dispose();
                return;
            }

            //可能已经被GameObject tree deleted了,不再回收
            if (obj.displayObject != null && obj.displayObject.isDisposed)
            {
                return;
            }

            if (obj is HtmlImage)
            {
                _imagePool.Push(obj);
            }
            else if (obj is HtmlInput)
            {
                _inputPool.Push(obj);
            }
            else if (obj is HtmlButton)
            {
                _buttonPool.Push(obj);
            }
            else if (obj is HtmlLink)
            {
                _linkPool.Push(obj);
            }

            if (obj.displayObject != null)
            {
                if (_poolManager == null)
                {
                    _poolManager = Stage.inst.CreatePoolManager("HtmlObjectPool");
                }

                ToolSet.SetParent(obj.displayObject.cachedTransform, _poolManager);
            }
        }