コード例 #1
0
ファイル: LayoutScript.cs プロジェクト: huai707/Mahjong
    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
ファイル: GameLayout.cs プロジェクト: huai707/Mahjong
 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);
    }
コード例 #5
0
    //------------------------------------------------------------------------------------------------------------
    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());
 }
コード例 #10
0
    //------------------------------------------------------------------------------------------------------------------------------------------
    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
ファイル: LayoutScript.cs プロジェクト: huai707/Mahjong
    // 创建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
ファイル: LayoutScript.cs プロジェクト: huai707/Mahjong
    // 创建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
ファイル: LayoutScript.cs プロジェクト: huai707/Mahjong
    public void instantiateObject(txUIObject parent, string name)
    {
        GameObject gameObject = mLayoutSubPrefabManager.instantiate(name, parent.getObject(), name);

        gameObject.SetActive(false);
    }
コード例 #17
0
ファイル: GameLayout.cs プロジェクト: huai707/Mahjong
 public void registerUIObject(txUIObject uiObj)
 {
     mObjectList.Add(uiObj.getID(), uiObj);
     mGameObjectSearchList.Add(uiObj.getObject(), uiObj);
 }