コード例 #1
0
    public void Setup()
    {
        transform.SetParent(null, false);
        Util.FindIfNotSet(this, ref voosEngine);
        Util.FindIfNotSet(this, ref networkingController);
        Util.FindIfNotSet(this, ref consoleMessages);
        Util.FindIfNotSet(this, ref dynamicPopup);
        Util.FindIfNotSet(this, ref hudManager);
        Util.FindIfNotSet(this, ref mouseoverTooltip);
        Util.FindIfNotSet(this, ref globalExceptionHandler);
        Util.FindIfNotSet(this, ref undoStack);
        Util.FindIfNotSet(this, ref sceneController);
        Util.FindIfNotSet(this, ref gbStage);
        Util.FindIfNotSet(this, ref virtualPlayerManager);
        Util.FindIfNotSet(this, ref playerControlsManager);
        Util.FindIfNotSet(this, ref bsod);
        Util.FindIfNotSet(this, ref logHandler);

        codeErrorNotification.Setup();
        logHandler.onDisplayCodeError = codeErrorNotification.Display;

        inputControl.Setup();
        undoStack.onUndone += item => AddDebugMessage($"Undoing \"{item.actionLabel}.\"");
        undoStack.onRedone += item => AddDebugMessage($"Re-doing \"{item.actionLabel}.\"");
        systemMenu          = GameObject.Instantiate(systemMenuPrefab, editMain.topLeftAnchor);
        systemMenu.Setup();

        mouseoverTooltip.Setup(this);
        mouseoverTooltip.SetText("");

        commandConsole = Instantiate(commandConsolePrefab);
        commandConsole.SetHudManager(hudManager);

        consoleMessages.GetComponent <RectTransform>().SetParent(consoleAnchor, false);
        consoleMessages.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;

        LoadPlayerOptions();

        sidebarManager.Setup();

        //change layer for player
        Transform[] transforms = gameObject.GetComponentsInChildren <Transform>();
        foreach (Transform t in transforms)
        {
            t.gameObject.layer = LayerMask.NameToLayer("Player");
        }

        avatars = new AvatarMain[] { playMain, editMain };
        foreach (AvatarMain av in avatars)
        {
            av.Setup(this);
            av.transform.SetParent(null);
        }

        navigationControls.UpdateTargetThirdPersonPivot(userBody.thirdPersonCameraPivotAnchor);

        SetEditMode(CanEdit() ? GameBuilderApplication.CurrentGameOptions.playOptions.startInBuildMode : false);

        Application.wantsToQuit += WantsToQuit;

        if (networkingController.GetIsInMultiplayer())
        {
            headerMenu.OpenMultiplayerMenu();
        }
    }