当前位置: 首页>>代码示例>>C#>>正文


C# UIPanel.IsVisible方法代码示例

本文整理汇总了C#中UIPanel.IsVisible方法的典型用法代码示例。如果您正苦于以下问题:C# UIPanel.IsVisible方法的具体用法?C# UIPanel.IsVisible怎么用?C# UIPanel.IsVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIPanel的用法示例。


在下文中一共展示了UIPanel.IsVisible方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateGeometry

    /// <summary>
    /// Update the widget and fill its geometry if necessary. Returns whether something was changed.
    /// </summary>
    public bool UpdateGeometry(UIPanel p, bool forceVisible)
    {
        if (material != null && p != null)
        {
            mPanel = p;
            bool hasMatrix = false;
            float final = finalAlpha;
            bool visibleByAlpha = (final > 0.001f);
            bool visibleByPanel = forceVisible || mVisibleByPanel;

            // Has transform moved?
            if (HasTransformChanged())
            {
                // Check to see if the widget has moved relative to the panel that manages it
        #if UNITY_EDITOR
                if (!mPanel.widgetsAreStatic || !Application.isPlaying)
        #else
                if (!mPanel.widgetsAreStatic)
        #endif
                {
                    mLocalToPanel = p.worldToLocal * cachedTransform.localToWorldMatrix;
                    hasMatrix = true;

                    Vector2 offset = pivotOffset;

                    float x0 = -offset.x * mWidth;
                    float y0 = -offset.y * mHeight;
                    float x1 = x0 + mWidth;
                    float y1 = y0 + mHeight;

                    Transform wt = cachedTransform;

                    Vector3 v0 = wt.TransformPoint(x0, y0, 0f);
                    Vector3 v1 = wt.TransformPoint(x1, y1, 0f);

                    v0 = p.worldToLocal.MultiplyPoint3x4(v0);
                    v1 = p.worldToLocal.MultiplyPoint3x4(v1);

                    if (Vector3.SqrMagnitude(mOldV0 - v0) > 0.000001f ||
                        Vector3.SqrMagnitude(mOldV1 - v1) > 0.000001f)
                    {
                        mChanged = true;
                        mOldV0 = v0;
                        mOldV1 = v1;
                    }
                }

                // Is the widget visible by the panel?
                if (visibleByAlpha || mForceVisible != forceVisible)
                {
                    mForceVisible = forceVisible;
                    visibleByPanel = forceVisible || mPanel.IsVisible(this);
                }
            }
            else if (visibleByAlpha && mForceVisible != forceVisible)
            {
                mForceVisible = forceVisible;
                visibleByPanel = mPanel.IsVisible(this);
            }

            // Is the visibility changing?
            if (mVisibleByPanel != visibleByPanel)
            {
                mVisibleByPanel = visibleByPanel;
                mChanged = true;
            }

            // Has the alpha changed?
            if (mVisibleByPanel && mLastAlpha != final) mChanged = true;
            mLastAlpha = final;

            if (mChanged)
            {
                mChanged = false;

                if (isVisible)
                {
                    bool hadVertices = mGeom.hasVertices;
                    mGeom.Clear();
                    OnFill(mGeom.verts, mGeom.uvs, mGeom.cols);

                    if (mGeom.hasVertices)
                    {
                        // Want to see what's being filled? Uncomment this line.
                        //Debug.Log("Fill " + name + " (" + Time.time + ")");

                        if (!hasMatrix) mLocalToPanel = p.worldToLocal * cachedTransform.localToWorldMatrix;
                        mGeom.ApplyTransform(mLocalToPanel);
                        return true;
                    }
                    return hadVertices;
                }
                else if (mGeom.hasVertices)
                {
                    mGeom.Clear();
                    return true;
                }
//.........这里部分代码省略.........
开发者ID:Attila22,项目名称:LittleBard,代码行数:101,代码来源:UIWidget.cs

示例2: UpdateGeometry

	/// <summary>
	/// Update the widget and fill its geometry if necessary. Returns whether something was changed.
	/// </summary>

	public bool UpdateGeometry (UIPanel p, bool forceVisible)
#endif
	{
		if (material != null && p != null)
		{
			mPanel = p;
			bool hasMatrix = false;
#if !OLD_UNITY
			float final = finalAlpha;
			bool visibleByAlpha = (final > 0.001f);
			bool visibleByPanel = forceVisible || mVisibleByPanel;

			// Has transform moved?
			if (cachedTransform.hasChanged)
			{
				mTrans.hasChanged = false;
				
				// Check to see if the widget has moved relative to the panel that manages it
#if UNITY_EDITOR
				if (!mPanel.widgetsAreStatic || !Application.isPlaying)
#else
				if (!mPanel.widgetsAreStatic)
#endif
				{
					Vector2 size = relativeSize;
					Vector2 offset = pivotOffset;
					Vector4 padding = relativePadding;

					float x0 = offset.x * size.x - padding.x;
					float y0 = offset.y * size.y + padding.y;

					float x1 = x0 + size.x + padding.x + padding.z;
					float y1 = y0 - size.y - padding.y - padding.w;

					mLocalToPanel = p.worldToLocal * cachedTransform.localToWorldMatrix;
					hasMatrix = true;

					Vector3 v0 = new Vector3(x0, y0, 0f);
					Vector3 v1 = new Vector3(x1, y1, 0f);

					v0 = mLocalToPanel.MultiplyPoint3x4(v0);
					v1 = mLocalToPanel.MultiplyPoint3x4(v1);

					if (Vector3.SqrMagnitude(mOldV0 - v0) > 0.000001f || Vector3.SqrMagnitude(mOldV1 - v1) > 0.000001f)
					{
						mChanged = true;
						mOldV0 = v0;
						mOldV1 = v1;
					}
				}

				// Is the widget visible by the panel?
				if (visibleByAlpha || mForceVisible != forceVisible)
				{
					mForceVisible = forceVisible;
					visibleByPanel = forceVisible || mPanel.IsVisible(this);
				}
			}
			else if (visibleByAlpha && mForceVisible != forceVisible)
			{
				mForceVisible = forceVisible;
				visibleByPanel = mPanel.IsVisible(this);
			}

			// Is the visibility changing?
			if (mVisibleByPanel != visibleByPanel)
			{
				mVisibleByPanel = visibleByPanel;
				mChanged = true;
			}

			// Has the alpha changed?
			if (mVisibleByPanel && mLastAlpha != final) mChanged = true;
			mLastAlpha = final;
#endif
			if (mChanged)
			{
				mChanged = false;

				if (isVisible)
				{
					mGeom.Clear();
					OnFill(mGeom.verts, mGeom.uvs, mGeom.cols);

					// Want to see what's being filled? Uncomment this line.
					//Debug.Log("Fill " + name + " (" + Time.time + ")");

					if (mGeom.hasVertices)
					{
						Vector3 offset = pivotOffset;
						Vector2 scale = relativeSize;

						offset.x *= scale.x;
						offset.y *= scale.y;

						if (!hasMatrix) mLocalToPanel = p.worldToLocal * cachedTransform.localToWorldMatrix;
//.........这里部分代码省略.........
开发者ID:Burnknee,项目名称:IpadApp,代码行数:101,代码来源:UIWidget.cs


注:本文中的UIPanel.IsVisible方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。