- Home /
This post has been wikified, any user with enough reputation can edit it.
[Solved]Tell everyone what my texture is
So i have this code with the RPC set up, but im worried, if that the textures wont sync with other. So basicaly : if network is ours, get the skin, tell everyone my skin, done. If player joins server, send rpc to him.
But im worried that it will apply the textures not on the player that owns it, but on everyone.
using UnityEngine;
using System.Collections;
public class PlayerSkin : MonoBehaviour {
public string skinURL;
public Texture skin;
void Start()
{
if(networkView.isMine == true)
{
StartCoroutine(GetSkin(skinURL));
}
}
IEnumerator GetSkin(string url)
{
WWW www = new WWW(url);
yield return www;
skin = www.texture;
transform.Find("Body").renderer.material.mainTexture = skin;
transform.Find("Head").renderer.material.mainTexture = skin;
networkView.RPC("SetSkin", RPCMode.All, skinURL);
}
IEnumerator RecieveSkin(string url)
{
WWW www = new WWW(url);
yield return www;
skin = www.texture;
transform.Find("Body").renderer.material.mainTexture = skin;
transform.Find("Head").renderer.material.mainTexture = skin;
}
void OnPlayerConnected(NetworkPlayer who)
{
networkView.RPC("SetSkin", who, skinURL);
}
[RPC]
void SetSkin (string url)
{
StartCoroutine(GetSkin(url));
}
}
Comment
What do you mean worried? Have you not tried testing it.
Sounds right. Thats how a tutorial I followed updated peoples positions.
Your answer
![](https://koobas.hobune.stream/wayback/20220613124035im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Share Texture 0 Answers
Send Texture Over Network 1 Answer
RPC can't send string? 1 Answer