アバター風にしてみる
- Cube作成。ここでは"Avatar"いう名前に変更した。
- CubeにBoxColliderが追加されていることを確認
- CubeのAddComponentにPhotonAvaterとPhotonViewとPhotonTransformViewを追加
- CubeをPrefabに追加
- 以下スクリプトでPrefabのAvaterをロードする。
GameObject avater = PhotonNetwork.Instantiate("Avater", Vector3.zero, Quaternion.Euler(Vector3.zero),0);
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
public class PhotonAvater : MonoBehaviourPunCallbacks {
public string str = "guest1";
void Awake() {
this.name = "Cube"+GetComponent<PhotonView> ().InstantiationId;
if (GetComponent<PhotonView>().IsMine) {
GetComponent<Renderer>().material.color = Color.red;
}
}
}