예제 #1
0
    public void destroyObject(txUIObject obj, bool immediately = false)
    {
        // 查找该节点下的所有窗口,从布局中注销
        List <GameObject> children = new List <GameObject>();

        findAllChild(obj.getObject(), children);
        int count = children.Count;

        for (int i = 0; i < count; ++i)
        {
            mLayout.unregisterUIObject(mLayout.getUIObject(children[i]));
        }
        UnityUtility.destroyGameObject(obj.getObject(), immediately);
    }
예제 #2
0
 public void unregisterUIObject(txUIObject uiObj)
 {
     if (uiObj == null)
     {
         return;
     }
     mObjectList.Remove(uiObj.getID());
     mGameObjectSearchList.Remove(uiObj.getObject());
 }
예제 #3
0
    public void destroyInstantiateObject(txUIObject window, bool destroyReally)
    {
        GameObject go = window.getObject();

        txUIObject.destroyWindow(window, false);
        mObjectPool.destroyObject(ref go, destroyReally);
        // 通知布局有窗口添加
        mLayout.notifyObjectChanged();
    }
예제 #4
0
    public bool hasObject(txUIObject parent, string name)
    {
        if (parent == null)
        {
            parent = mRoot;
        }
        GameObject gameObject = getGameObject(parent.getObject(), name);

        return(gameObject != null);
    }
    //------------------------------------------------------------------------------------------------------------
    protected override void setValue(float value)
    {
        txUIObject obj = mComponentOwner as txUIObject;

        // 因为NGUI中透明度小于0.001时认为是将窗口隐藏,会重新构建网格顶点,所以此处最低为0.002
        if (WidgetUtility.isNGUI(obj.getObject()))
        {
            clampMin(ref value, 0.002f);
        }
        obj.setAlpha(value, false);
    }
예제 #6
0
    public static void setGameObjectLayer(txUIObject obj, int layer)
    {
        GameObject go = obj.getObject();

        go.layer = layer;
        Transform[] childTransformList = go.transform.GetComponentsInChildren <Transform>(true);
        foreach (Transform t in childTransformList)
        {
            t.gameObject.layer = layer;
        }
    }
예제 #7
0
    //------------------------------------------------------------------------------------------------------------
    protected override void applyTrembling(float value)
    {
        txUIObject obj      = mComponentOwner as txUIObject;
        float      newAlpha = lerpSimple(mStartAlpha, mTargetAlpha, value);

        // 因为NGUI中透明度小于0.001时认为是将窗口隐藏,会重新构建网格顶点,所以此处最低为0.002
        if (WidgetUtility.isNGUI(obj.getObject()))
        {
            clampMin(ref newAlpha, 0.002f);
        }
        obj.setAlpha(newAlpha, false);
    }
예제 #8
0
 public void registerUIObject(txUIObject uiObj)
 {
     // 如果此时正在遍历列表,则需要加入添加列表
     if (mLockObjectList)
     {
         mAddList.Add(uiObj);
         return;
     }
     // 同步列表,确保mObjectList是最新的
     syncObjectList();
     mObjectList.Add(uiObj.getID(), uiObj);
     mGameObjectSearchList.Add(uiObj.getObject(), uiObj);
 }
예제 #9
0
 public void unregisterUIObject(txUIObject uiObj)
 {
     // 如果此时正在遍历列表,则需要添加到移除列表,待后续从主列表移除
     if (mLockObjectList)
     {
         mRemoveList.Add(uiObj);
         return;
     }
     // 同步列表,确保mObjectList是最新的
     syncObjectList();
     mObjectList.Remove(uiObj.getID());
     mGameObjectSearchList.Remove(uiObj.getObject());
 }
    //------------------------------------------------------------------------------------------------------------------------------------------
    protected Vector3[] getLocalMinMaxPixelPos()
    {
        if (mMinMaxPosDirty)
        {
            bool    isNGUI           = mWindow.getLayout().isNGUI();
            Vector2 parentWidgetSize = Vector2.zero;
            if (isNGUI)
            {
#if USE_NGUI
                // 获得第一个带widget的父节点的rect
                if (mParentRect == null)
                {
                    mParentRect = WidgetUtility.findNGUIParentRect(mWindow.getObject());
                }
                parentWidgetSize = WidgetUtility.getNGUIRectSize(mParentRect);
#endif
            }
            else
            {
                parentWidgetSize = mWindow.getParent().getWindowSize();
            }
            // 计算父节点的世界缩放
            Vector2    worldScale  = getMatrixScale(mWindow.getTransform().parent.localToWorldMatrix);
            txUIObject root        = mLayoutManager.getUIRoot(isNGUI);
            Vector2    uiRootScale = root.getTransform().localScale;
            Vector2    parentScale = worldScale / uiRootScale;
            // 计算移动的位置范围
            Vector2 minPos = parentWidgetSize * 0.5f * mMinRelativePos / parentScale;
            Vector2 maxPos = parentWidgetSize * 0.5f * mMaxRelativePos / parentScale;
            if (mClampType == CLAMP_TYPE.CT_EDGE)
            {
                Vector2 thisSize = mWindow.getWindowSize(true);
                minPos += thisSize * 0.5f;
                maxPos -= thisSize * 0.5f;
                if (!mClampInner)
                {
                    swap(ref minPos, ref maxPos);
                }
            }
            else if (mClampType == CLAMP_TYPE.CT_CENTER)
            {
            }
            mMinMaxPos[0]   = minPos;
            mMinMaxPos[1]   = maxPos;
            mMinMaxPosDirty = false;
        }
        return(mMinMaxPos);
    }
예제 #11
0
    // 创建txUIObject,并且新建GameObject,分配到txUIObject中
    public T createObject <T>(txUIObject parent, string name, bool active = true) where T : txUIObject, new()
    {
        GameObject go = UnityUtility.createObject(name);

        if (parent == null)
        {
            parent = mRoot;
        }
        go.layer = parent.getObject().layer;
        T obj = newUIObject <T>(name, parent, mLayout, go);

        obj.setActive(active);
        go.transform.localScale       = Vector3.one;
        go.transform.localEulerAngles = Vector3.zero;
        go.transform.localPosition    = Vector3.zero;
        return(obj);
    }
예제 #12
0
    // 创建txUIObject,并且在布局中查找GameObject分配到txUIObject
    // active为-1则表示不设置active,0表示false,1表示true
    public T newObject <T>(out T obj, txUIObject parent, string name, int active = -1, bool showError = true) where T : txUIObject, new()
    {
        obj = null;
        GameObject parentObj = parent != null?parent.getObject() : null;

        GameObject gameObject = getGameObject(parentObj, name, showError, false);

        if (gameObject == null)
        {
            return(obj);
        }
        obj = newUIObject <T>(parent, mLayout, gameObject);
        if (active >= 0)
        {
            obj.setActive(active != 0);
        }
        return(obj);
    }
예제 #13
0
    // 创建txUIObject,并且在布局中查找GameObject分配到txUIObject
    // active为-1则表示不设置active,0表示false,1表示true
    public T newObject <T>(out T obj, txUIObject parent, string name, int active = -1) where T : txUIObject, new()
    {
        obj = null;
        GameObject parentObj  = (parent != null) ? parent.getObject(): null;
        GameObject gameObject = getGameObject(parentObj, name);

        if (gameObject == null)
        {
            logError("object is null, name : " + name);
            return(obj);
        }
        obj = newUIObject <T>(name, parent, mLayout, gameObject);
        if (active == 0)
        {
            obj.setActive(false);
        }
        else if (active == 1)
        {
            obj.setActive(true);
        }
        return(obj);
    }
예제 #14
0
 public GameObject getUGUIRootObject()
 {
     return(mUGUIRoot.getObject());
 }
예제 #15
0
    public GameObject getRootObject(bool ngui)
    {
        txUIObject root = getUIRoot(ngui);

        return(root != null?root.getObject() : null);
    }
예제 #16
0
    public void instantiateObject(txUIObject parent, string name)
    {
        GameObject gameObject = mLayoutSubPrefabManager.instantiate(name, parent.getObject(), name);

        gameObject.SetActive(false);
    }
예제 #17
0
 public void registerUIObject(txUIObject uiObj)
 {
     mObjectList.Add(uiObj.getID(), uiObj);
     mGameObjectSearchList.Add(uiObj.getObject(), uiObj);
 }