- Home /
This question was
closed Dec 09, 2014 at 06:27 PM by
unimechanic for the following reason:
Duplicate Question
Question by
applejuices · Jun 08, 2014 at 08:35 PM ·
materialnetworkchange
[Help Please]Changing a Material over network. Not working.
using UnityEngine;
using System.Collections;
public class Paint : MonoBehaviour {
public Material[] Mats;
public int selected;
public RaycastHit Hit;
public Camera Cam;
public GUISkin skins;
public AudioSource lol;
public int idofmat;
public NetworkView Changed;
// Use this for initialization
void Start () {
GameObject brickers = GameObject.Find ("ServerSetts");
Mats = brickers.GetComponent<SingInitialize> ().Matss;
}
void OnGUI(){
if (!networkView || networkView.isMine) {
GUI.skin = skins;
for (int i = 0; i < Mats.Length; i++) {
if (GUILayout.Button (Mats [i].name)) {
selected = i;
}//
}
}
}
// Update is called once per frame
void Update () {
if (!networkView || networkView.isMine) {
if (Input.GetMouseButton (0)) {
if (Physics.Raycast (Cam.ScreenPointToRay (Input.mousePosition), out Hit, 300) && Hit.distance > 1 && Hit.collider.gameObject.renderer.sharedMaterial.name != Mats [selected].name) {
if (Hit.collider.gameObject.tag == "Brick") {
Hit.collider.gameObject.renderer.sharedMaterial = Mats [selected];
Changed = Hit.collider.gameObject.networkView;
NetworkViewID NV = Hit.collider.gameObject.networkView.viewID;
networkView.RPC("colorno", RPCMode.AllBuffered, selected,NV );//
lol.Play ();
}
}
}
}
}
[RPC]
public void colorno(int selected, NetworkViewID NV){
NetworkView.Find (NV).gameObject.renderer.sharedMaterial = Mats [selected];
//GameObject.Find (Changed.observed.name).renderer.sharedMaterial = Mats [selected];
}
}
Does not work at all. I mean I can paint on client, mainly because the line that regularly does material, but doesn't network it :/
Comment
Answer by unimechanic · Dec 09, 2014 at 06:27 PM
Why i nthe world would you bump a post thats a few months old?
Follow this Question
Related Questions
referring to a particular material 0 Answers
Material on/off 1 Answer
Change texure on NGUI BUTTUN press 0 Answers
Change enemy color when hit 2 Answers
Change material per element 1 Answer