2020-06-02 19:05:08 登录注册 RSS

当前位置: 公理网 >> 显明公道 >> Unity强制引导遮罩

Unity强制引导遮罩
发布时间:05-22| 来源:公理网 | 点击发表评论
79372797","ab":"new"}'target="_blank"href="https://blog.csdn.net/bigpaolee/article/details/79372797">Resources.UnloadA...
sunny__chen:1.Resources.UnloadAsset确实将贴图从内存中释放了
2.虽然释放了,但是因为textureTex001这个引用还在,再次使用这个引用时,会自动将贴图从Resources中加载进内存



效果:

2019041222194859.gif"alt="在这里插入图片描述">

主要代码:


usingSystem.Collections;
usingSystem.Collections.Generic;
usingUnityEngine;
usingUnityEngine.UI;
publicclassMain:MonoBehaviour
publicstaticMainSelf;
publicRectTransformCanvasRectTransform;
publicCanvasScalerCanvasScaler;

return!RectTransformUtility.RectangleContainsScreenPoint(_targetArea,sp,eventCamera);
publicvoidClose()
gameObject.SetActive(false);
publicvoidPlay(RectTransformtarget)
gameObject.SetActive(true);
varscreenPoint=RectTransformUtility.WorldToScreenPoint(Camera.main,target.position);
Vector2localPoint;
if(!RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform,screenPoint,Camera.main,
outlocalPoint))
Close();
return;

_targetArea.anchorMin=target.anchorMin;
_targetArea.anchoredPosition=target.anchoredPosition;
_targetArea.anchoredPosition3D=target.anchoredPosition3D;
_targetArea.offsetMax=target.offsetMax;
_targetArea.offsetMin=target.offsetMin;
_targetArea.pivot=target.pivot;
_targetArea.sizeDelta=target.sizeDelta;
_targetArea.localPosition=localPoint;
_targetArea.ForceUpdateRectTransforms();
_target=_targetArea;
_target.ForceUpdateRectTransforms();
LateUpdate();

varmaskRectLeftTop=newVector2(-maskRect.width/2,maskRect.height/2);
varmaskRectLeftBottom=newVector2(-maskRect.width/2,-maskRect.height/2);
varmaskRectRightTop=newVector2(maskRect.width/2,maskRect.height/2);
varmaskRectRightBottom=newVector2(maskRect.width/2,-maskRect.height/2);
vartargetRectLeftTop=newVector2(_targetMin.x,_targetMax.y);
vartargetRectLeftBottom=_targetMin;
vartargetRectRightTop=_targetMax;
vartargetRectRightBottom=newVector2(_targetMax.x,_targetMin.y);
toFill.AddVert(maskRectLeftBottom,color,Vector2.zero);
toFill.AddVert(targetRectLeftBottom,color,Vector2.zero);
toFill.AddVert(targetRectRightBottom,color,Vector2.zero);
toFill.AddVert(maskRectRightBottom,color,Vector2.zero);
toFill.AddVert(targetRectRightTop,color,Vector2.zero);
toFill.AddVert(maskRectRightTop,color,Vector2.zero);
toFill.AddVert(targetRectLeftTop,color,Vector2.zero);
toFill.AddVert(maskRectLeftTop,color,Vector2.zero);
toFill.AddTriangle(0,1,2);
toFill.AddTriangle(2,3,0);
toFill.AddTriangle(3,2,4);
toFill.AddTriangle(4,5,3);
toFill.AddTriangle(6,7,5);
toFill.AddTriangle(5,4,6);
toFill.AddTriangle(7,6,1);
toFill.AddTriangle(1,0,7);

varbounds=RectTransformUtility.CalculateRelativeRectTransformBounds(transform,_target);
newMin=bounds.min;
newMax=bounds.max;
else
newMin=Vector2.zero;
newMax=Vector2.zero;
if(_targetMin!=newMin||_targetMax!=newMax)
_targetMin=newMin;
_targetMax=newMax;
SetAllDirty();


Github地址:https://github.com/asyncrun/GuideMask


UI背景图随机网上下载,侵权告知马上删除31436645/Mobile-Game-UI-Portfolio"rel="nofollow">下载地址

最新新闻

手机浏览

公理网 版权所有

公理网 Total 0.035939(s) query 6, 报料QQ:点击这里

给我发消息