Пример #1
0
        private void GameStart()
        {
            // ゲームスタートフラグを立てる
            this.isGameStart = true;

            // ある程度ランダムな場所にプレイヤーを配置する
            Vector3 position = Vector3.zero;

            position.x = Random.Range(-10.0f, 10.0f);
            position.z = Random.Range(-10.0f, 10.0f);
            Quaternion rotation = Quaternion.AngleAxis(Random.Range(-180.0f, 180.0f), Vector3.up);

            // プレイヤーの配置(他クライアントにも同時にInstantiateする)
            MonobitNetwork.Instantiate("SD_unitychan_generic_PC", position, rotation, 0);

            // 出現させたことを確認
            this.isSpawnMyChara = true;
        }
Пример #2
0
        // 自身がルーム入室に成功したときの処理
        public void OnJoinedRoom()
        {
            vcPlayerInfo.Clear();
            vcPlayerInfo.Add(MonobitNetwork.player, (Int32)EnableVC.DISABLE);

            foreach (MonobitPlayer player in MonobitNetwork.otherPlayersList)
            {
                vcPlayerInfo.Add(player, (Int32)EnableVC.ENABLE);
            }

            GameObject go = MonobitNetwork.Instantiate("VoiceActor", Vector3.zero, Quaternion.identity, 0);

            myVoice = go.GetComponent <MonobitVoice>();
            if (myVoice != null)
            {
                myVoice.SetMicrophoneErrorHandler(OnMicrophoneError);
                myVoice.SetMicrophoneRestartHandler(OnMicrophoneRestart);
            }
        }
Пример #3
0
    void DropItem()
    {
        if (this.dropItemPrefab.Length == 0)
        {
            return;
        }
        var dropItem = this.dropItemPrefab[Random.Range(0, this.dropItemPrefab.Length)];

        MonobitNetwork.Instantiate(
            dropItem.name,
            this.transform.position,
            Quaternion.identity,
            0,
            null,
            true,
            false,
            true
            );
    }
Пример #4
0
        void OnGameStart()
        {
            // ゲームスタートフラグを立てる
            isGameStart = true;

            if (!isReconnecting)
            {
                // ある程度ランダムな位置・姿勢でプレイヤーを配置する
                myPosition   = Vector3.zero;
                myPosition.x = UnityEngine.Random.Range(-10.0f, 10.0f);
                myPosition.z = UnityEngine.Random.Range(-10.0f, 10.0f);
                myRotation   = Quaternion.AngleAxis(UnityEngine.Random.Range(-180.0f, 180.0f), Vector3.up);
            }

            // プレイヤーの配置(他クライアントにも同時にInstantiateする)
            myObject = MonobitNetwork.Instantiate("SD_unitychan_PC", myPosition, myRotation, 0);

            // 再接続処理完了
            isReconnecting = false;
        }
Пример #5
0
 void Generate()
 {
     for (var enemyCount = 0; enemyCount < this.existEnemys.Length; ++enemyCount)
     {
         if (this.existEnemys[enemyCount] == null)
         {
             // 敵作成
             this.existEnemys[enemyCount] = MonobitNetwork.Instantiate(
                 this.enemy.name,
                 this.transform.position,
                 this.transform.rotation,
                 0,
                 null,
                 false,
                 false,
                 false
                 );
             return;
         }
     }
 }
Пример #6
0
 // Update is called once per frame
 void Update()
 {
     // 未接続状態なら何もしない
     if (!MonobitNetwork.isConnect)
     {
         return;
     }
     // ルーム入室処理未実行であれば、ルームの作成or入室をする
     if (!isJoinOrCreateRoom)
     {
         MonobitNetwork.JoinOrCreateRoom("MonobitTest", new RoomSettings(), null);
         isJoinOrCreateRoom = true;
         return;
     }
     // ルーム入室済みでキャラクタ未生成であれば、キャラクタを生成する
     if (MonobitNetwork.inRoom && !isMakeMyPlayer)
     {
         MonobitNetwork.Instantiate("Player", Vector3.zero, Quaternion.identity, 0);
         isMakeMyPlayer = true;
         return;
     }
 }
Пример #7
0
        void OnGameStart()
        {
            // オブジェクト情報のクリア
            s_PlayerObject = new List <SD_Unitychan_PC>();
            itemObject     = new List <GameObject>();

            // ルームをクローズする
            MonobitNetwork.room.open = false;

            // ゲームスタートフラグを立てる
            isGameStart = true;

            // 変数初期化
            gameTimeLimit       = 6000;
            gameItemIsPut       = 0;
            gameItemRakeupCount = 0;

            if (!isReconnecting)
            {
                // ある程度ランダムな位置・姿勢でプレイヤーを配置する
                myPosition   = Vector3.zero;
                myPosition.x = UnityEngine.Random.Range(-10.0f, 10.0f);
                myPosition.z = UnityEngine.Random.Range(-10.0f, 10.0f);
                myRotation   = Quaternion.AngleAxis(UnityEngine.Random.Range(-180.0f, 180.0f), Vector3.up);
            }

            // プレイヤーの配置(他クライアントにも同時にInstantiateする)
            GameObject go = MonobitNetwork.Instantiate("SD_unitychan_PC", myPosition, myRotation, 0);

            myObject = go.GetComponent <SD_Unitychan_PC>();

            // 出現させたことを確認
            isSpawnMyChara = true;

            // 再接続処理完了
            isReconnecting = false;
        }
    void createText(string text, string parentName)
    {
        // ホスト以外は処理をしない
        if (!MonobitEngine.MonobitNetwork.isHost)
        {
            return;
        }
        GameObject newText = MonobitNetwork.Instantiate(
            ToSpawn.name,
            Vector3.zero,
            Quaternion.identity,
            0,
            null,
            true,
            false,
            true
            ) as GameObject;

        newText.GetComponentInChildren <textStatusReceiver>().parentName = parentName;
        newText.GetComponentInChildren <textStatusReceiver>().text       = text;
        newText.GetComponentInChildren <textStatusReceiver>().color      = fcp.color;
        //入力された言葉を連想配列に追加する
        wordList.AddWord(text);
    }
Пример #9
0
 // Update is called once per frame
 public void Update()
 {
     if (monobitView.isMine)
     {
         if (monobitView.isMine)
         {
             // キャラクタの移動&アニメーション切り替え
             if (currentAnimId == 3)
             {
                 if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") || animator.GetCurrentAnimatorStateInfo(0).normalizedTime <= 0.55)
                 {
                     gameObject.transform.position += jumpFixedSpeed;
                 }
                 else
                 {
                     jumpFixedSpeed = Vector3.zero * Time.deltaTime;
                     gameObject.transform.position += jumpFixedSpeed;
                     currentAnimId = 0;
                     animator.SetInteger(animId, currentAnimId);
                     animator.SetFloat(moveSpeed, jumpFixedSpeed.magnitude);
                 }
             }
             else if (currentAnimId == 4)
             {
                 if (animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion") && animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 0.90)
                 {
                     jumpFixedSpeed = Vector3.zero * Time.deltaTime;
                     gameObject.transform.position += jumpFixedSpeed;
                     currentAnimId = 0;
                     animator.SetInteger(animId, currentAnimId);
                     animator.SetFloat(moveSpeed, jumpFixedSpeed.magnitude);
                 }
             }
             else if (Input.GetButtonDown("Jump"))
             {
                 if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") && !animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion"))
                 {
                     gameObject.transform.position += jumpFixedSpeed;
                     currentAnimId = 3;
                     animator.SetInteger(animId, currentAnimId);
                     animator.SetFloat(moveSpeed, jumpFixedSpeed.magnitude);
                 }
             }
             else if (Input.GetKeyDown("z"))
             {
                 if (animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Stand"))
                 {
                     jumpFixedSpeed = Vector3.zero * Time.deltaTime;
                     gameObject.transform.position += jumpFixedSpeed;
                     currentAnimId = 4;
                     animator.SetInteger(animId, currentAnimId);
                     animator.SetFloat(moveSpeed, jumpFixedSpeed.magnitude);
                 }
             }
             else if (Input.GetKey("up"))
             {
                 if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") && !animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion"))
                 {
                     if (animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Stand") || animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Walk"))
                     {
                         jumpFixedSpeed = gameObject.transform.forward * 1.5f * Time.deltaTime;
                     }
                     else
                     {
                         jumpFixedSpeed = gameObject.transform.forward * 3.0f * Time.deltaTime;
                     }
                     gameObject.transform.position += jumpFixedSpeed;
                     currentAnimId = 1;
                     animator.SetInteger(animId, currentAnimId);
                     animator.SetFloat(moveSpeed, jumpFixedSpeed.magnitude);
                 }
             }
             else if (Input.GetKey("down"))
             {
                 if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") && !animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion"))
                 {
                     jumpFixedSpeed = gameObject.transform.forward * -0.1f * Time.deltaTime;
                     gameObject.transform.position += jumpFixedSpeed;
                     currentAnimId = 2;
                     animator.SetInteger(animId, currentAnimId);
                     animator.SetFloat(moveSpeed, jumpFixedSpeed.magnitude);
                     if (animator.GetCurrentAnimatorStateInfo(0).normalizedTime <= 0.0f)
                     {
                         animator.Play(Animator.StringToHash("Walking@loop"), 0, 1.0f);
                     }
                 }
             }
             else
             {
                 if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") && !animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion"))
                 {
                     jumpFixedSpeed = Vector3.zero * Time.deltaTime;
                     gameObject.transform.position += jumpFixedSpeed;
                     currentAnimId = 0;
                     animator.SetInteger(animId, currentAnimId);
                     animator.SetFloat(moveSpeed, jumpFixedSpeed.magnitude);
                     ChangeFace("default@sd_generic");
                 }
             }
             if (Input.GetKey("right"))
             {
                 if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") && !animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion"))
                 {
                     gameObject.transform.Rotate(0, 30.0f * Time.deltaTime, 0);
                 }
             }
             if (Input.GetKey("left"))
             {
                 if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") && !animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion"))
                 {
                     gameObject.transform.Rotate(0, -30.0f * Time.deltaTime, 0);
                 }
             }
             if (Input.GetKeyDown("x"))
             {
                 if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") && !animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion"))
                 {
                     MonobitNetwork.Instantiate("Cube", transform.position, transform.rotation, 0);
                 }
             }
             animator.SetLayerWeight(1, currentFace);
             monobitView.RPC("SetFaceID", MonobitTargets.OthersBuffered, currentAnimId, currentFace, currentFaceName);
         }
         else
         {
             animator.SetInteger(animId, currentAnimId);
             animator.SetLayerWeight(1, currentFace);
             foreach (var animation in animations)
             {
                 if (currentFaceName == animation.name)
                 {
                     ChangeFace(currentFaceName);
                 }
             }
         }
     }
 }
    // Update is called once per frame
    public void Update()
    {
        if (monobitView.isOwner)
        {
            // キャラクタの移動&アニメーション切り替え
            if (Input.GetKey("up"))
            {
                gameObject.transform.position += gameObject.transform.forward * 0.1f;
                animator.SetInteger(animId, 1);
            }
            else
            {
                animator.SetInteger(animId, 0);
            }
            if (Input.GetKey("right"))
            {
                gameObject.transform.Rotate(0, 2.0f, 0);
            }
            if (Input.GetKey("left"))
            {
                gameObject.transform.Rotate(0, -2.0f, 0);
            }
            if (Input.GetKeyDown("z"))
            {
                MonobitNetwork.Instantiate("Cube", transform.position, transform.rotation, 0);
            }
            if (Input.GetKeyDown("s"))
            {
                MonobitNetwork.Instantiate("Cube", transform.position, transform.rotation, 0, null, true, false, true);
            }
            if (Input.GetKeyDown("e"))
            {
                MonobitNetwork.Instantiate("Cube", transform.position, transform.rotation, 0, null, true, false, false);
            }
            if (Input.GetKeyDown("d"))
            {
                UnityEngine.Debug.Log("Destroy Cube Start");
                foreach (GameObject go in FindObjectsOfType(typeof(GameObject)))
                {
                    MonobitView view = go.GetComponent <MonobitView>();
                    if (null == view)
                    {
                        continue;
                    }
                    if ("Cube(Clone)" != go.name)
                    {
                        continue;
                    }

                    MonobitNetwork.Destroy(go);
                    if (!view.enabled)
                    {
                        UnityEngine.Debug.Log("Destroy Cube: " + view);
                    }
                }
                UnityEngine.Debug.Log("Destroy Cube End");
            }
            if (Input.GetKeyDown("r"))
            {
                UnityEngine.Debug.Log("RequestOwnership Cube Start");
                foreach (GameObject go in FindObjectsOfType(typeof(GameObject)))
                {
                    MonobitView view = go.GetComponent <MonobitView>();
                    if (null == view)
                    {
                        continue;
                    }
                    if ("Cube(Clone)" != go.name)
                    {
                        continue;
                    }

                    view.RequestOwnership();
                    UnityEngine.Debug.Log("RequestOwnership Cube: " + view);
                }
                UnityEngine.Debug.Log("RequestOwnership Cube End");
            }
            if (Input.GetKeyDown("t"))
            {
                UnityEngine.Debug.Log("TransferOwnership Cube Start");
                int playerId = MonobitNetwork.player.ID;
                foreach (GameObject go in FindObjectsOfType(typeof(GameObject)))
                {
                    MonobitView view = go.GetComponent <MonobitView>();
                    if (null == view)
                    {
                        continue;
                    }
                    if ("Cube(Clone)" != go.name)
                    {
                        continue;
                    }

                    view.TransferOwnership(playerId);
                    UnityEngine.Debug.Log("TransferOwnership Cube: " + view);
                }
                UnityEngine.Debug.Log("TransferOwnership Cube End");
            }
            if (Input.GetKeyDown("i"))
            {
                UnityEngine.Debug.Log("Change IsDontDestroyOnRoom Cube Start");
                foreach (GameObject go in FindObjectsOfType(typeof(GameObject)))
                {
                    MonobitView view = go.GetComponent <MonobitView>();
                    if (null == view)
                    {
                        continue;
                    }
                    if ("Cube(Clone)" != go.name)
                    {
                        continue;
                    }

                    bool isDontDestroyOnRoom = view.isDontDestroyOnRoom;
                    view.isDontDestroyOnRoom = !isDontDestroyOnRoom;
                    if (isDontDestroyOnRoom != view.isDontDestroyOnRoom)
                    {
                        UnityEngine.Debug.Log("Change IsDontDestroyOnRoom Cube: " + view + " " + isDontDestroyOnRoom + " -> " + view.isDontDestroyOnRoom);
                    }
                }
                UnityEngine.Debug.Log("Change IsDontDestroyOnRoom Cube End");
            }
            if (Input.GetKeyDown("0"))
            {
                serializeBytes[0] = 0;
            }
            if (Input.GetKeyDown("1"))
            {
                serializeBytes[0] = 1;
            }
        }
    }
        void DoAction(MonobitKeySettings settings, float keyActiveValue)
        {
            switch (settings.actionType)
            {
            case ActionType.Move:
                gameObject.transform.position += gameObject.transform.right * settings.Position.x * keyActiveValue;
                gameObject.transform.position += gameObject.transform.up * settings.Position.y * keyActiveValue;
                gameObject.transform.position += gameObject.transform.forward * settings.Position.z * keyActiveValue;
                break;

            case ActionType.Rotate:
                gameObject.transform.Rotate(settings.Rotation * keyActiveValue);
                break;

            case ActionType.ChangeAnimLayerWeight:
                if (animView != null && animView.m_Animator != null)
                {
                    AnimLayerInfo info = settings.layerInfo[settings.SelectLayer];
                    animView.m_Animator.SetLayerWeight(info.m_Index, info.m_animWeight * keyActiveValue);
                }
                break;

            case ActionType.ChangeAnimParam:
                if (keyActiveValue > 0.0f)
                {
                    if (animView != null && animView.m_Animator != null)
                    {
                        AnimParamInfo info = settings.paramInfo[settings.SelectParam];
                        switch (info.m_Type)
                        {
                        case MonobitAnimatorView.AnimatorControllerParameterType.Bool:
                            animView.m_Animator.SetBool(info.m_Name, info.m_boolValue);
                            break;

                        case MonobitAnimatorView.AnimatorControllerParameterType.Float:
                            animView.m_Animator.SetFloat(info.m_Name, info.m_floatValue * keyActiveValue);
                            break;

                        case MonobitAnimatorView.AnimatorControllerParameterType.Int:
                            animView.m_Animator.SetInteger(info.m_Name, (int)(info.m_intValue * keyActiveValue));
                            break;

                        case MonobitAnimatorView.AnimatorControllerParameterType.Trigger:
                            break;
                        }
                    }
                }
                break;

            case ActionType.Instantiate:
                if (keyActiveValue >= 1.0f)
                {
                    switch (settings.instantiateType)
                    {
                    case InstantiateType.Absolute:
                    {
                        Quaternion rotation = Quaternion.Euler(settings.Rotation);
                        MonobitNetwork.Instantiate(settings.instantiatePrefab.name, settings.Position, rotation, 0);
                    }
                    break;

                    case InstantiateType.Relative:
                    {
                        Vector3 position = gameObject.transform.position;
                        position += gameObject.transform.right * settings.Position.x;
                        position += gameObject.transform.up * settings.Position.y;
                        position += gameObject.transform.forward * settings.Position.z;
                        Quaternion rotation = gameObject.transform.rotation * Quaternion.Euler(settings.Rotation);
                        MonobitNetwork.Instantiate(settings.instantiatePrefab.name, position, rotation, 0);
                    }
                    break;

                    case InstantiateType.RandomAbsolute:
                    {
                        Vector3 position = new Vector3(UnityEngine.Random.Range(settings.PositionMin.x, settings.PositionMax.x),
                                                       UnityEngine.Random.Range(settings.PositionMin.y, settings.PositionMax.y),
                                                       UnityEngine.Random.Range(settings.PositionMin.z, settings.PositionMax.z));
                        Quaternion rotation = Quaternion.Euler(UnityEngine.Random.Range(settings.RotationMin.x, settings.RotationMax.x),
                                                               UnityEngine.Random.Range(settings.RotationMin.y, settings.RotationMax.y),
                                                               UnityEngine.Random.Range(settings.RotationMin.z, settings.RotationMax.z));
                        MonobitNetwork.Instantiate(settings.instantiatePrefab.name, position, rotation, 0);
                    }
                    break;
                    }
                }
                break;
            }
        }
Пример #12
0
        /**
         * @brief   更新関数.
         */
        void Update()
        {
            // ゲーム中の処理
            if (isGameStart && !isGameEnd)
            {
                // まだ自分のキャラクタのspawnが終わっていない状態であれば、自身のキャラクタをspawnする
                if (!isSpawnMyChara)
                {
                    OnGameStart();
                }

                // 自身のキャラクタ位置の退避
                if (myObject != null)
                {
                    myPosition = myObject.transform.position;
                    myRotation = myObject.transform.rotation;
                }

                // ルーム名の退避
                if (MonobitNetwork.room != null)
                {
                    reconnectRoomName = MonobitNetwork.room.name;
                }

                // ホストの場合の処理
                if (MonobitNetwork.isHost)
                {
                    // アイテムに接近したら、アイテム取得処理を実行する
                    if (gameItemRakeupCount < gameItemLimit)
                    {
                        for (int index = itemObject.Count - 1; index >= 0; --index)
                        {
                            foreach (SD_Unitychan_PC playerObject in s_PlayerObject)
                            {
                                if ((playerObject.transform.position - itemObject[index].transform.position).magnitude < 1.0f)
                                {
                                    // そのオブジェクトを削除する
                                    MonobitNetwork.Destroy(itemObject[index]);

                                    // 自身のスコア情報を加算するRPC処理を実行する
                                    monobitView.RPC("OnUpdateScore", MonobitTargets.All, playerObject.GetPlayerID(), playerObject.MyScore + 100);
                                    gameItemRakeupCount++;
                                }
                            }
                        }
                    }
                    else
                    {
                        // ゲーム終了メッセージを送信
                        monobitView.RPC("OnGameEnd", MonobitTargets.All, null);
                    }

                    // 制限時間の減少
                    if (gameTimeLimit > 0)
                    {
                        gameTimeLimit--;
                    }
                    else
                    {
                        // ゲーム終了メッセージを送信
                        monobitView.RPC("OnGameEnd", MonobitTargets.All, null);
                    }

                    // 個数制限&時間制限のタイミングで、ゲームシーン上にオブジェクトを配置
                    if ((gameItemIsPut < gameItemLimit) && (gameTimeLimit % 10 == 0))
                    {
                        // ある程度ランダムな位置・姿勢でプレイヤーを配置する
                        Vector3 position = Vector3.zero;
                        position.x = UnityEngine.Random.Range(-10.0f, 10.0f);
                        position.z = UnityEngine.Random.Range(-10.0f, 10.0f);
                        Quaternion rotation = Quaternion.AngleAxis(UnityEngine.Random.Range(-180.0f, 180.0f), Vector3.up);

                        // オブジェクトの配置(他クライアントにも同時にInstantiateする)
                        MonobitNetwork.Instantiate("item", position, rotation, 0, null, true, false, true);

                        // ゲームオブジェクト出現個数を加算
                        gameItemIsPut++;
                    }

                    // 制限時間をRPCで送信
                    monobitView.RPC("TickCount", MonobitTargets.Others, gameTimeLimit);
                }
            }
        }
Пример #13
0
    // 自身がルーム入室に成功したときの処理
    public void OnJoinedRoom()
    {
        vcPlayerInfo.Clear();
        vcPlayerInfo.Add(MonobitNetwork.player, (Int32)EnableVC.DISABLE);

        foreach (MonobitPlayer player in MonobitNetwork.otherPlayersList)
        {
            vcPlayerInfo.Add(player, (Int32)EnableVC.ENABLE);
        }

        GameObject go = MonobitNetwork.Instantiate("VoiceActor", Vector3.zero, Quaternion.identity, 0);

        myVoice = go.GetComponent <MonobitVoice>();

        Mc = go.GetComponent <MonobitMicrophone>();
        AC = Mc.GetAudioClip();

        Debug.Log(MonobitNetwork.playerName);

        //7/2試行部分
        // ResourcesフォルダにあるNew SpriteプレハブをGameObject型で取得
        //GameObject obj = (GameObject)Resources.Load("icon");
        // iconプレハブを元に、インスタンスを生成、
        //Instantiate(obj, new Vector3(0.0f, 2.0f, 0.0f), Quaternion.identity);

        //7/6試行部分
        //GameObject user_icon= new GameObject("usericon");
        //user_icon.transform.parent = GameObject.Find("Canvas").transform;
        //user_icon.AddComponent<RectTransform>().anchoredPosition = new Vector3(0, 0, 0);
        //user_icon.GetComponent<RectTransform>().localScale = new Vector3(1, 1, 1);
        //user_icon.AddComponent<Image>().sprite = Resources.Load<Sprite>("textures/ifn0438");
        //7/7 user_icon.AddComponent<Image>().sprite = Resources.Load("textures/ifn0438", typeof(Sprite)) as Sprite;
        //user_icon.GetComponent<Image>().preserveAspect = true;
        //user_icon.GetComponent<Image>().SetNativeSize();

        // 「Sprite sprite = Resources.Load("ban", typeof(Sprite)) as Sprite;」と同じ
        //Sprite sprite = Resources.Load<Sprite>("ban");

        // 空のゲームオブジェクトを生成
        //GameObject gameObj = new GameObject();
        // Imageコンポーネントをアタッチ
        //Image image = gameObj.AddComponent<Image>();
        // Resources.Load()で生成したSpriteを指定
        //image.sprite = sprite;
        // Canvasの子オブジェクトとする
        //gameObj.transform.parent = FindObjectOfType<Canvas>().transform;

        // Texture2Dでサイズを取得し、変更する
        //Texture2D texture = Resources.Load<Texture2D>("ban");
        //gameObj.GetComponent<RectTransform>().sizeDelta = new Vector2(texture.width, texture.height);

        //7/7
        GameObject prefab = (GameObject)Instantiate(UserIcon);

        prefab.transform.SetParent(canvas.transform, false);

        if (myVoice != null)
        {
            myVoice.SetMicrophoneErrorHandler(OnMicrophoneError);
            myVoice.SetMicrophoneRestartHandler(OnMicrophoneRestart);
        }
    }