Skip to content

Commit

Permalink
Check that UI already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
vberezkin committed Mar 11, 2019
1 parent ddbf26a commit 39a3674
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
42 changes: 20 additions & 22 deletions Assets/Resources/Expload/ExploadBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,27 @@ public class ExploadBehaviour : MonoBehaviour
void Start()
{
#if !UNITY_EDITOR
GameObject canvas = new GameObject("ExploadCanvas");
canvas.AddComponent<Canvas>();
canvas.GetComponent<Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;
canvas.GetComponent<Canvas>().sortingOrder = 99;
DontDestroyOnLoad(canvas);
GameObject raw_image = new GameObject("OverlayImage");
raw_image.transform.parent = canvas.transform;
raw_image.AddComponent<RawImage>();
if (!GameObject.Find("ExploadCanvas"))
{
GameObject canvas = new GameObject("ExploadCanvas");
canvas.AddComponent<Canvas>();
canvas.GetComponent<Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;
canvas.GetComponent<Canvas>().sortingOrder = 99;
DontDestroyOnLoad(canvas);
GameObject raw_image = new GameObject("OverlayImage");
raw_image.transform.parent = canvas.transform;
raw_image.AddComponent<RawImage>();

raw_image.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f);
raw_image.GetComponent<RectTransform>().anchorMin = new Vector2(0, 0);
raw_image.GetComponent<RectTransform>().anchorMax = new Vector2(1, 1);
raw_image.GetComponent<RectTransform>().sizeDelta = new Vector2(Screen.width, Screen.height);
raw_image.GetComponent<RectTransform>().offsetMin = new Vector2(0, 0);
raw_image.GetComponent<RectTransform>().offsetMax = new Vector2(0, 0);
raw_image.GetComponent<RawImage>().color = new Color(1, 1, 1, 0.5f);
raw_image.AddComponent<Expload.OffscreenCEF>();
raw_image.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f);
raw_image.GetComponent<RectTransform>().anchorMin = new Vector2(0, 0);
raw_image.GetComponent<RectTransform>().anchorMax = new Vector2(1, 1);
raw_image.GetComponent<RectTransform>().sizeDelta = new Vector2(Screen.width, Screen.height);
raw_image.GetComponent<RectTransform>().offsetMin = new Vector2(0, 0);
raw_image.GetComponent<RectTransform>().offsetMax = new Vector2(0, 0);
raw_image.GetComponent<RawImage>().color = new Color(1, 1, 1, 0.5f);
raw_image.AddComponent<Expload.OffscreenCEF>();
}
#endif
}

// Update is called once per frame
void Update()
{

}
}

4 changes: 2 additions & 2 deletions package/expload.unitypackage
Git LFS file not shown

0 comments on commit 39a3674

Please sign in to comment.