void Start() { if (!serverIsRunned) { Server(); serverIsRunned = true; } mainCanvas = new MyCanvas(new Vector2(Screen.width, Screen.height)); MakeState(); windowTests = MakeTests(); windowTests.SetActive(stateMenu.IsOpenTestsWindow); var buttonWindowTests = new MyButton(() => windowTests.SetActive(!windowTests.isOpen), ButtonSprite, new Rect(0, 0, 64, 48), "Tests"); var rectB = buttonWindowTests.Element.GetComponent<RectTransform>(); var inputField = new MyInputField("Input", ButtonSprite, new Rect(0, 0, 160, 25)); buttonWindowTests.SetAnchor(new Vector2(0, 1), new Vector2(0, 1)); var buttonLog = new MyButton( () => Dispatcher.AddRunner(new LogRunner(inputField.Element.GetComponent<InputField>().text)), ButtonSprite, new Rect(0, 0, 64, 48), "Log play"); var rectLog = buttonLog.Element.GetComponent<RectTransform>(); buttonLog.SetAnchor(0, 0, 0, 0); rectLog.anchoredPosition = new Vector2(300, 40); rectB.offsetMin = new Vector2(100, -200); UIElement.SetSize(rectB, new Vector2(120, 30)); var buttonTutorial = new MyButton( () => Dispatcher.AddRunner(new TutorialRunner(new LoadingData { AssemblyName = "RoboMovies", Level = "Test" })), ButtonSprite, new Rect(0, 00, 120, 48), "Tutorial"); buttonTutorial.SetAnchor(new Vector2(0, 1), new Vector2(0, 1)); rectB = buttonTutorial.Element.GetComponent<RectTransform>(); rectB.offsetMin = new Vector2(100, -300); UIElement.SetSize(rectB, new Vector2(120, 30)); dropDownListAssembly = Instantiate(DropDownList); dropDownListAssembly.name = "BambaLeilo"; dropDownListAssembly.transform.localPosition = new Vector3(0, 0); var dropDown = dropDownListAssembly.GetComponent<Dropdown>(); dropDown.GetComponent<RectTransform>().position = new Vector3(0, 0, 0); dropDown.options = new List<Dropdown.OptionData>(); foreach (var e in Dispatcher.Loader.Levels.Keys) dropDown.options.Add(new Dropdown.OptionData(e)); for (var i = 0; i < dropDown.options.Count; i++) if (dropDown.options[i].text == stateMenu.CurrentAssembly) dropDown.value = i; dropDownListLevel = Instantiate(DropDownList); dropDownListLevel.name = "BambaLeiloLevel"; dropDownListLevel.transform.localPosition = new Vector3(0, 0); var dropDownList = dropDownListLevel.GetComponent<Dropdown>(); dropDownList.GetComponent<RectTransform>().position = new Vector3(0, 0, 0); dropDownList.options = new List<Dropdown.OptionData>(); foreach (var e in Dispatcher.Loader.Levels[stateMenu.CurrentAssembly].Keys) dropDownList.options.Add(new Dropdown.OptionData(e)); for (var i = 0; i < dropDownList.options.Count; i++) if (dropDownList.options[i].text == stateMenu.CurrentLevel) { dropDownList.value = i; dropDownList.options[i] = new Dropdown.OptionData(stateMenu.CurrentLevel); } var backGround = new MyImage(menuBackground, new Rect(0, 0, menuBackground.textureRect.width, menuBackground.textureRect.height)); mainCanvas.AddElement(backGround); mainCanvas.AddElement(inputField); mainCanvas.AddElement(windowTests.Head); mainCanvas.AddElement(buttonWindowTests); mainCanvas.AddElement(buttonTutorial); mainCanvas.AddElement(buttonLog); dropDownListLevel.transform.SetParent(mainCanvas.Element.transform); dropDown.transform.SetParent(mainCanvas.Element.transform); var rectDrop = dropDownListAssembly.GetComponent<RectTransform>(); rectDrop.anchorMin = new Vector2(0, 1); rectDrop.anchorMax = new Vector2(0, 1); rectDrop.anchoredPosition = new Vector3(100, -40, 0); rectDrop = dropDownListLevel.GetComponent<RectTransform>(); rectDrop.anchorMin = new Vector2(0, 1); rectDrop.anchorMax = new Vector2(0, 1); rectDrop.anchoredPosition = new Vector3(300, -40, 0); rectDrop = inputField.Element.GetComponent<RectTransform>(); inputField.SetAnchor(0, 0, 0, 0); rectDrop.anchoredPosition = new Vector3(100, 40, 0); }
void Start() { Dispatcher.RoundStart(); timeOnStartSession = Time.fixedTime; curWorldTime = 0; Behaviour = this; CameraCreator(); ScoresFieldsCreator(); var mainCanvas = new MyCanvas(new Vector2(Screen.width, Screen.height)); var buttonGO = new MyButton(() => Dispatcher.SetGameOver(), button, new Rect(100, -100, 100, 30), "Back to menu"); buttonGO.SetAnchor(new Vector2(0,1), new Vector2(0, 1)); mainCanvas.AddElement(buttonGO); world = Dispatcher.CurrentRunner.World; if (world != null) Debugger.Log(DebuggerMessageType.Unity, "World loaded"); else Debugger.Log(DebuggerMessageType.Unity, "Fail. World not loaded"); CollisionInfo = new Tuple<string, string, int>(null, null, 0); Time.timeScale = 1; // вот почему так? //в момент повторного запуска время уже не нулевое }