Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Photon.Pun;
- public class NetworkMove : MonoBehaviour, IPunObservable
- {
- [SerializeField]
- private List<Material> skins = new List<Material>();
- [SerializeField]
- private Renderer skinRender; // наш текущий скин
- private int currentSkin = 0;
- PhotonView _photonView;
- public bool finish;
- void Start()
- {
- _photonView = GetComponent<PhotonView>();
- ChangeSkin(0);
- if (!_photonView.IsMine)
- {
- GetComponent<PlayerLook>().enabled = false;
- GetComponent<GuyMove>().enabled = false;
- GetComponentInChildren<Camera>().gameObject.SetActive(false);
- }
- }
- void Update()
- {
- if (_photonView.IsMine)
- {
- if (Input.GetKeyDown(KeyCode.Alpha0))
- {
- ChangeSkin(0);
- }
- if (Input.GetKeyDown(KeyCode.Alpha1))
- {
- ChangeSkin(1);
- }
- if (Input.GetKeyDown(KeyCode.Alpha2))
- {
- ChangeSkin(2);
- }
- }
- }
- public void ChangeSkin(int skinNum)
- {
- skinRender.material = skins[skinNum];
- currentSkin = skinNum;
- }
- public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
- {
- if (stream.IsWriting)
- {
- stream.SendNext(finish);
- stream.SendNext(currentSkin);
- }
- else
- {
- finish = (bool)stream.ReceiveNext();
- currentSkin = (int)stream.ReceiveNext();
- ChangeSkin(currentSkin);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement