当前位置:网站首页>设置Canvas的 overrideSorting不生效
设置Canvas的 overrideSorting不生效
2022-06-28 12:00:00 【Unique_849997563】
当我想在游戏中的特效上添加Canvas并且修改overrideSorting时,发现虽然代码执行了,但是没有得到预期效果。
Canvas _canvas = m_princeEffectGo.AddComponent<Canvas>();
_canvas.overrideSorting = true;最后发现如果在Awake修改的话,不能修改成功,只能在Start 中修改。
但之后我用我们项目的框架写了一个测试代码挂在UI上测试,不论是Awake还是Start都会执行。
using UnityEngine;
using YoukiaUnity.App;
public class CanvasTest : MonoSwitch
{
public GameObject canvas;
public override void OnAwake()
{
base.OnAwake();
GameObject _go = Instantiate(canvas, transform);
Canvas _canvas = _go.AddComponent<Canvas>();
_canvas.overrideSorting = true;
}
protected override void Initialization()
{
base.Initialization();
GameObject _go = Instantiate(canvas, transform);
Canvas _canvas = _go.AddComponent<Canvas>();
_canvas.overrideSorting = true;
}
}搞不动为什么在Awake中设置Canvas的 overrideSorting不生效!简单记录一下!
边栏推荐
- Vivo手机的权限管理
- Day32 JS note event (Part 1) September 27, 2021
- Which programming language will attract excellent talents?
- ByteV搭建动态数字孪生网络安全平台----助力网络安全发展
- recent developments
- 2018 joint examination of nine provinces & Merging of line segment trees
- Prefix and (2D)
- Usage and principle of precomputedtextcompat
- Contract quantification system development (construction explanation) - contract quantification system development (source code analysis and ready-made cases)
- Custom title bar view
猜你喜欢

【C语言】如何产生正态分布或高斯分布随机数

Build your own website (18)

Why do many people want to change careers as programmers, while some programmers want to change careers as others?

Leetcode 705. 设计哈希集合

Many benefits of SEO optimization are directly related to traffic

Oracle date format exception: invalid number

Day31 JS notes DOM 2021.09.26

Prepare for Jin San Yin Si I. testers without experience in automated testing projects should look at it quickly

Deployment and optimization of vsftpd service

. Net hybrid development solution 24 webview2's superior advantages over cefsharp
随机推荐
Difference (one dimension)
【Unity编辑器扩展基础】、GUI
ByteV搭建动态数字孪生网络安全平台----助力网络安全发展
智联招聘基于 Nebula Graph 的推荐实践分享
Random forest and poetry maker trained by AMR
Leetcode 705. 设计哈希集合
Software test interview classic + 1000 high-frequency real questions, and the hit rate of big companies is 80%
Which programming language will attract excellent talents?
双缓冲绘图
Batch will png . bmp . JPEG format pictures are converted to Jpg format picture
已知两个点和中间一个比例的点,求该点坐标
Remoteviews layout and type restriction source code analysis
Int~long long indicates the maximum and minimum number
Why do many people want to change careers as programmers, while some programmers want to change careers as others?
Timestamp and date conversion "suggested collection"
Day36 JS notes ecma6 syntax 2021.10.09
Using soapUI to obtain freemaker's FTL file template
On the output representation of bidirectional LSTM in pytoch
2. single digit statistics
【vi/vim】基本使用及命令汇总