Esempio n. 1
0
    //This method trigger the creation of the objects on which films are rendered
    void spawnFilms(RectTransform canvasRect, VideoClip[] clips)
    {
        GameObject films = new GameObject();

        films.name = "Films";
        films.transform.SetParent(canvasRect.transform);

        float available_size = (1 - (clips.Length + 1) * 0.01f) * Mathf.Min(canvasRect.rect.width, canvasRect.rect.height);

        float       min_width = canvasRect.rect.width / 8f * Mathf.Max(15f / (5 + 1f), 1f);
        float       max_width = canvasRect.rect.width / 7.5f * Mathf.Max(15f / (5 + 1f), 1f);
        SquaresTree sqt       = new SquaresTree(canvasRect.rect.width * widthRatio, canvasRect.rect.height, max_width, min_width, canvasRect.position - new Vector3(canvasRect.rect.width * (1 - widthRatio) * 0.5f, 0, 0));

        int choice = Random.Range(0, clips.Length);


        SquareCell sqc  = sqt.getSquare();
        float      size = sqc.side;
        GameObject vid  = Instantiate(image, sqc.center, Quaternion.identity);

        vid.name = string.Format("film{0}", 1);
        vid.transform.SetParent(films.transform);

        var videoPlayer = vid.AddComponent <UnityEngine.Video.VideoPlayer>();

        videoPlayer.clip        = clips[choice];
        videoPlayer.playOnAwake = false;
        (vid.GetComponent <VideoController>()).StartCoroutine((vid.GetComponent <VideoController>()).SetUpFilm());
        (vid.GetComponent <VideoController>()).SetSize(size, size);
        (vid.GetComponent <VideoController>()).SetPos(sqc.center);
    }
Esempio n. 2
0
 void spawnImage(Texture2D texture)
 {
     if (sqt.CountSquare() != 0)
     {
         SquareCell sqc  = sqt.getSquare();
         float      size = sqc.side;
         GameObject img  = Instantiate(image, sqc.center, Quaternion.identity);
         img.name = string.Format("image{0}", counter);
         img.transform.SetParent(images.transform);
         (img.GetComponent <ImageController>()).StartCoroutine((img.GetComponent <ImageController>()).SetUpImage(texture, sqc));
         (img.GetComponent <ImageController>()).SetSize(size, size);
         (img.GetComponent <ImageController>()).SetPos(sqc.center);
     }
 }
Esempio n. 3
0
    void spawnImages(RectTransform canvasRect, Texture2D[] textures)
    {
        GameObject images = new GameObject();

        images.name = "Images";
        images.transform.SetParent(canvasRect.transform);
        float       available_size = (1 - (textures.Length + 1) * 0.01f) * Mathf.Min(canvasRect.rect.width, canvasRect.rect.height);
        float       min_width      = canvasRect.rect.width / 8f * Mathf.Max(15f / (textures.Length + 1f), 1f);
        float       max_width      = canvasRect.rect.width / 7.5f * Mathf.Max(15f / (textures.Length + 1f), 1f);
        SquaresTree sqt            = new SquaresTree(canvasRect.rect.width * widthRatio, canvasRect.rect.height, max_width, min_width, canvasRect.position - new Vector3(canvasRect.rect.width * (1 - widthRatio) * 0.5f, 0, 0));

        for (int i = 0; i < textures.Length; i++)
        {
            SquareCell sqc  = sqt.getSquare();
            float      size = sqc.side;
            GameObject img  = Instantiate(image, sqc.center, Quaternion.identity);
            img.name = string.Format("image{0}", i);
            img.transform.SetParent(images.transform);
            (img.GetComponent <ImageController>()).SetUpImage(textures[i]);
            (img.GetComponent <ImageController>()).SetSize(size, size);
            (img.GetComponent <ImageController>()).SetPos(sqc.center);
        }
    }