浏览代码
prototype fix
prototype fix
The issue is that, create UI in Update (like in TestFei.cs) will cause crash. this is just a prototype fix: only latch2 part is useful. we will look into this issue later when having time/zxw-fix_crash
xingweizhu
3 年前
当前提交
728df288
共有 3 个文件被更改,包括 106 次插入 和 8 次删除
-
33engine/src/shell/platform/unity/windows/uiwidgets_panel.cc
-
78Samples/UIWidgetsSamples_2019_4/Assets/Script/TestFei.cs
-
3Samples/UIWidgetsSamples_2019_4/Assets/Script/TestFei.cs.meta
|
|||
using UnityEngine; |
|||
using UnityEngine.UI; |
|||
|
|||
namespace UIWidgetsSample |
|||
{ |
|||
public class TestFei : MonoBehaviour |
|||
{ |
|||
private float curTime = 0.0f; |
|||
|
|||
private int totalNum = 10; |
|||
|
|||
private bool isOk = false; |
|||
|
|||
public static bool needwaiting = false; |
|||
|
|||
private void Update() |
|||
{ |
|||
if (Input.GetKeyDown(KeyCode.A)) |
|||
{ |
|||
this.isOk = true; |
|||
} |
|||
|
|||
if (!this.isOk) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
//if (needwaiting)
|
|||
//{
|
|||
// return;
|
|||
//}
|
|||
|
|||
if (this.totalNum <= 0) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
this.curTime += Time.deltaTime; |
|||
if (this.curTime < 0) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
this.curTime = 0; |
|||
this.totalNum--; |
|||
|
|||
//needwaiting = true;
|
|||
//for (int i = 0; i < 10; i++)
|
|||
{ |
|||
GameObject gameobject = new GameObject(); |
|||
GameObject newCanvas = new GameObject(); |
|||
|
|||
Canvas c = newCanvas.AddComponent<Canvas>(); |
|||
c.renderMode = RenderMode.WorldSpace; |
|||
|
|||
newCanvas.AddComponent<CanvasScaler>(); |
|||
newCanvas.AddComponent<GraphicRaycaster>(); |
|||
|
|||
var canvasTransform = c.GetComponent<RectTransform>(); |
|||
canvasTransform.anchorMin = new Vector2(0, 0); |
|||
canvasTransform.anchorMax = new Vector2(0, 0); |
|||
canvasTransform.sizeDelta = new Vector2(800, 800); |
|||
|
|||
GameObject panel = new GameObject("RawImage"); |
|||
var rectTransform = panel.AddComponent<RectTransform>(); |
|||
rectTransform.anchorMin = new Vector2(0, 0); |
|||
rectTransform.anchorMax = new Vector2(1, 1); |
|||
rectTransform.offsetMin = new Vector2(0, 0); |
|||
rectTransform.offsetMax = new Vector2(0, 0); |
|||
|
|||
panel.AddComponent<CanvasRenderer>(); |
|||
panel.AddComponent<HoverSample>(); |
|||
panel.transform.SetParent(newCanvas.transform, false); |
|||
newCanvas.transform.SetParent(gameobject.transform, true); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3e9daa87a52a47e488207acb4a2a0bd0 |
|||
timeCreated: 1645414930 |
撰写
预览
正在加载...
取消
保存
Reference in new issue