예제 #1
0
 private void FindCanvas()
 {
     if (canvas == null)
     {
         canvas = CanvasUtils.FindCanvas();
         canvasRectTransform = canvas.GetComponent <RectTransform>();
     }
 }
예제 #2
0
    public RectTransform CreateDebugPoint(RectTransform parent = null)
    {
        if (parent == null)
        {
            parent = CanvasUtils.FindCanvas().GetComponent <RectTransform>();
        }
        RectTransform debugPoint = GameObject.Instantiate(debugPositionIndicatorPrefab, parent);

        debugPoints.Add(debugPoint);
        return(debugPoint);
    }
예제 #3
0
    void Start()
    {
        rectTransform       = GetComponent <RectTransform>();
        singSceneController = FindObjectOfType <SingSceneController>();

        // Get the canvas width.
        Canvas        canvas = CanvasUtils.FindCanvas();
        RectTransform canvasRectTransform = canvas.GetComponent <RectTransform>();

        canvasWidth = canvasRectTransform.rect.width;
    }
예제 #4
0
파일: UiManager.cs 프로젝트: xxxDSSxxx/Play
    public void CreateShowFpsInstance()
    {
        if (showFpsInstance != null)
        {
            return;
        }

        showFpsInstance = Instantiate(showFpsPrefab, CanvasUtils.FindCanvas().GetComponent <RectTransform>());
        // Move to front
        showFpsInstance.transform.SetAsLastSibling();
        showFpsInstance.transform.position = new Vector3(20, 20, 0);
    }
예제 #5
0
    public void StartEditingNoteText()
    {
        if (activeLyricsInputField != null)
        {
            return;
        }

        activeLyricsInputField = Instantiate(lyricsInputFieldPrefab, transform);
        injector.Inject(activeLyricsInputField);
        activeLyricsInputField.Init(this, Note.Text);

        // Set min width of input field
        RectTransform inputFieldRectTransform = activeLyricsInputField.GetComponent <RectTransform>();
        Canvas        canvas      = CanvasUtils.FindCanvas();
        float         canvasWidth = canvas.GetComponent <RectTransform>().rect.width;

        if ((inputFieldRectTransform.rect.width / canvasWidth) < 0.1)
        {
            inputFieldRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, canvasWidth * 0.1f);
        }
    }
예제 #6
0
    void Start()
    {
        string playerProfilesCsv = SceneData.SelectedPlayerProfiles.Select(it => it.Name).ToCsv();

        Debug.Log($"{playerProfilesCsv} start (or continue) singing of {SongMeta.Title} at {SceneData.PositionInSongInMillis} ms.");

        // Prepare columns and rows for player UI
        PlayerUiArea.SetupPlayerUiGrid(SceneData.SelectedPlayerProfiles.Count, playerUiArea.GetComponent <GridLayoutGroupCellSizer>());

        // Handle players
        List <PlayerProfile> playerProfilesWithoutMic = new List <PlayerProfile>();

        foreach (PlayerProfile playerProfile in SceneData.SelectedPlayerProfiles)
        {
            SceneData.PlayerProfileToMicProfileMap.TryGetValue(playerProfile, out MicProfile micProfile);
            if (micProfile == null)
            {
                playerProfilesWithoutMic.Add(playerProfile);
            }
            PlayerController playerController = CreatePlayerController(playerProfile, micProfile);

            if (SceneData.PlayerProfileToScoreDataMap.TryGetValue(playerProfile, out PlayerScoreControllerData scoreData))
            {
                playerController.PlayerScoreController.ScoreData = scoreData;
            }

            // Handle crown display
            if (SceneData.SelectedPlayerProfiles.Count > 1)
            {
                playerController.PlayerScoreController.NoteScoreEventStream.Subscribe(noteScoreEvent => { RecomputeCrowns(); });
                playerController.PlayerScoreController.SentenceScoreEventStream.Subscribe(sentenceScoreEvent => { RecomputeCrowns(); });
            }
            playerController.PlayerUiController.PlayerCrownDisplayer.ShowCrown(false);
        }

        // Handle dummy singers
        if (Application.isEditor)
        {
            DummySingers = FindObjectsOfType <AbstractDummySinger>().ToList();
            foreach (AbstractDummySinger dummySinger in DummySingers)
            {
                if (dummySinger.playerIndexToSimulate < PlayerControllers.Count)
                {
                    dummySinger.SetPlayerController(PlayerControllers[dummySinger.playerIndexToSimulate]);
                }
                else
                {
                    Debug.LogWarning("DummySinger cannot simulate player with index " + dummySinger.playerIndexToSimulate);
                    dummySinger.gameObject.SetActive(false);
                }
            }
        }

        // Create warning about missing microphones
        string playerNameCsv = string.Join(",", playerProfilesWithoutMic.Select(it => it.Name).ToList());

        if (!playerProfilesWithoutMic.IsNullOrEmpty())
        {
            UiManager.Instance.CreateWarningDialog(
                I18NManager.GetTranslation(R.String.singScene_missingMicrophones_title),
                I18NManager.GetTranslation(R.String.singScene_missingMicrophones_message, "playerNameCsv", playerNameCsv));
        }

        // Associate LyricsDisplayer with one of the (duett) players
        InitLyricsDisplayers();

        //Save information about the song being started into stats
        Statistics stats = StatsManager.Instance.Statistics;

        stats.RecordSongStarted(SongMeta);

        songVideoPlayer.Init(SongMeta, songAudioPlayer);

        StartCoroutine(StartMusicAndVideo());

        // Rebuild whole UI
        LayoutRebuilder.ForceRebuildLayoutImmediate(CanvasUtils.FindCanvas().GetComponent <RectTransform>());
    }