devNotes 3-31-16 networking remote client

using UnityEngine;
using System.Collections;
using UnityEngine.Networking;

public class netCamMove : NetworkBehaviour
{
    bool bLMButtonisDown = false;
    bool bRMButtonisDown = false;
    bool bMMMouseButtonisDown = false;
    float xMouse_Damped;
    float yMouse_Damped;

    GameObject aCam;
    public GameObject remote_Paint_Controller_Prefab;
    GameObject remote_Paint_Controller_Inst;
    public GameObject localPaintControl;

    [SyncVar]
    public bool bPaintOn;
    bool bPaintLast = false;

    [SyncVar]
    public bool bQuadOn;
    bool bQuadLast = false;

    [SyncVar]
    public bool bHexOn;
    bool bHexLast = false;

    public override void OnStartLocalPlayer()
    {            
        aCam = GameObject.Find("Argos_Camera");
        aCam.transform.parent = this.transform;
        this.name = "ArgosNet_Local";

        localPaintControl = GameObject.Find("Paint_Controller");
    }

    public override void OnStartClient()
    {
        if (!isLocalPlayer)
        {
            this.name = "ArgosNet_Remote";
            remote_Paint_Controller_Inst = (GameObject)Instantiate(remote_Paint_Controller_Prefab);
            remote_Paint_Controller_Inst.transform.parent = this.transform;
        }
    }


    void checkMouseButts()
    {
        if(Input.GetMouseButtonDown(0))
        {
            bLMButtonisDown = true;
        }
        if(Input.GetMouseButtonUp(0))
        {
            bLMButtonisDown = false;
        }
        if (Input.GetMouseButtonDown(1))
        {
            bRMButtonisDown = true;
        }
        if (Input.GetMouseButtonUp(1))
        {
            bRMButtonisDown = false;
        }
        if (Input.GetMouseButtonDown(2))
        {
            bMMMouseButtonisDown = true;
        }
        if (Input.GetMouseButtonUp(2))
        {
            bMMMouseButtonisDown = false;
        }
    }


    void Update()
    {
        if (!isLocalPlayer)
        {      
            if (bPaintOn != bPaintLast)
            {
                remote_Paint_Controller_Inst.GetComponent<Remote_Paint_Controller>().onPaintTogSwitched(bPaintOn);
            }
            bPaintLast = bPaintOn;

            if (bQuadOn != bQuadLast)
            {
                remote_Paint_Controller_Inst.GetComponent<Remote_Paint_Controller>().onQuadTogSwitched(bQuadOn);
            }
            bQuadLast = bQuadOn;

            if (bHexOn != bHexLast)
            {
                remote_Paint_Controller_Inst.GetComponent<Remote_Paint_Controller>().onHexTogSwitched(bHexOn);
            }
            bHexLast = bHexOn;

            return;
        }

        float x = Input.GetAxis("Mouse X") * 60f * Time.deltaTime;
        float y = Input.GetAxis("Mouse Y") * 60f * Time.deltaTime;

        xMouse_Damped = Mathf.Lerp(xMouse_Damped, x, 0.1f);
        yMouse_Damped = Mathf.Lerp(yMouse_Damped, y, 0.1f);

        checkMouseButts();
        if (bLMButtonisDown)
        {
            transform.Rotate(-yMouse_Damped, xMouse_Damped, 0);
        }
        if(bRMButtonisDown)
        {
            transform.Translate(xMouse_Damped / 10f, yMouse_Damped / 10f, 0);
        }
        if (bMMMouseButtonisDown)
        {
            transform.Translate(xMouse_Damped/10f, 0, yMouse_Damped/10f);
        }
    }
}

 

Add Button to clear all.

network