private static void Initialize() { #if UNITY_EDITOR return; #endif var infos = BuildInformations.LoadDefault(); if (infos != null) { GameObject gameObject = new GameObject(nameof(BuildInformationsDisplay)); Object.DontDestroyOnLoad(gameObject); gameObject.layer = LayerMask.NameToLayer("UI"); var canvas = gameObject.AddComponent <Canvas>(); canvas.sortingOrder = short.MaxValue; canvas.renderMode = RenderMode.ScreenSpaceOverlay; var child = new GameObject("DateText"); child.transform.SetParent(gameObject.transform); var rectTransform = child.AddComponent <RectTransform>(); rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.zero; rectTransform.anchoredPosition = Vector2.zero; rectTransform.pivot = Vector2.zero; rectTransform.sizeDelta = new Vector2(200, 60); var textComponent = child.AddComponent <Text>(); textComponent.text = "Date:" + infos.BuildTimeAsString; textComponent.alignment = TextAnchor.MiddleCenter; textComponent.font = Resources.GetBuiltinResource <Font>("Arial.ttf"); } }
public void OnPreprocessBuild(BuildReport report) { var buildInformations = BuildInformations.LoadDefault(); buildInformations.BuildTimeAsString = DateTime.Now.ToString(CultureInfo.InvariantCulture); EditorUtility.SetDirty(buildInformations); Debug.Log("BuildData:\n" + EditorJsonUtility.ToJson(buildInformations, true)); }