UGUI AspectRatioFitter组件
AspectRatioFitter组件下的方法:
public bool IsAspectModeValid()
描述:AspectRatioFitter组件是否有效。
测试过程:
条件:
①AspectRatioFitter.AspectMode是Fit In Parent/Envelope Parent;
②AspectRatioFitter组件所在游戏对象有父物体;
③AspectRatioFitter组件是激活状态(AspectRatioFitter组件和它所在的游戏对象都是激活的);
测试结果:
1.
①√
②√
③√
IsAspectModeValid()
在Awake中的返回值:False;
在OnEnable的返回值:False;
在Start的返回值:True。
2.
①√
②×
③√或×
IsAspectModeValid()
在Awake中的返回值:False;
在OnEnable的返回值:False;
在Start的返回值:False。
3.
①√
②√
③×
IsAspectModeValid()
在Awake中的返回值:False;
在OnEnable的返回值:False;
在Start的返回值:False。
4.
①×
②√或×
③√或×
IsAspectModeValid()
在Awake中的返回值:True;
在OnEnable的返回值:True;
在Start的返回值:True。
结论:
由测试结果1和4得出以下结论(推测):
1.
AspectRatioFitter.Aspect是Fit In Parent/Envelope Parent时,AspectRatioFitte组件在Start中生效,但是AspectRatioFitter组件所在游戏对象要有父物体且AspectRatioFitter组件和它所在的游戏对象都是激活的;
2.
AspectRatioFitter.Aspect是None/Width Controls Height/Height Controls Width 时,AspectRatioFitte组件在Awake中生效,不管有没父物体不管是不是激活的。
public void IsComponentValidOnObject()
不知道此方法是干什么的。
测试结果:
不管AspectRatioFitter.AspectMode是什么,不管AspectRatioFitter组件和它所在的游戏对象是不是激活的,此方法在Awake、OnEnable、Start中的返回值都是True。

浙公网安备 33010602011771号