This Is For My Game With The Building Tools. I Have A Feature Where You Can Change The Color And Texture Of An Object. However It Only Works For Your Client And Not Other Peoples Clients. Here Is My Script I’m Using.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;
using Photon.Realtime;
public class _script3again : MonoBehaviourPunCallbacks
{
public float R = 0f;
public float G = 0f;
public float B = 0f;
public float A = 0f;
public Sprite customtext;
public Sprite grasstext;
public Sprite dirttext;
public Sprite stonetext;
public Sprite sandtext;
public Sprite bricktext;
public Sprite planktext;
public Sprite custombricktext;
public PhotonView photonViewer;
public SpriteRenderer sprite;
void Start()
{
sprite = GetComponent<SpriteRenderer>();
}
void Update()
{
// fix all this code
}
[PunRPC]
public void OnMouseDown()
{
if (_script3.buildtype == 2)
{
PhotonNetwork.Destroy(gameObject);
}
if (_script3.buildtype == 3)
{
photonView.RPC("Color", Photon.Pun.RpcTarget.AllBuffered);
}
}
[PunRPC]
public void Color()
{
R = GameManager.Red;
G = GameManager.Green;
B = GameManager.Blue;
sprite.color = new Color(R, G, B);
if (GameManager.TextureFloat == 0)
{
sprite.sprite = customtext;
}
if (GameManager.TextureFloat == 1)
{
sprite.sprite = grasstext;
}
if (GameManager.TextureFloat == 2)
{
sprite.sprite = dirttext;
}
if (GameManager.TextureFloat == 3)
{
sprite.sprite = stonetext;
}
if (GameManager.TextureFloat == 4)
{
sprite.sprite = sandtext;
}
if (GameManager.TextureFloat == 5)
{
sprite.sprite = bricktext;
}
if (GameManager.TextureFloat == 6)
{
sprite.sprite = planktext;
}
if (GameManager.TextureFloat == 7)
{
sprite.sprite = custombricktext;
}
}
}
I Know I Have Posted Here Several Times But I Don’t Know What I’m Doing Sometimes. Please Help I Need This Version Done In 3 Days. Thanks.
If I Don’t Have This Version Done In 3 Days My Boss Is Gonna Hit Me With A Cast Iron Pot.