Easier enable/disablign scripts

Hey I am working on networkign for the first time, and I want to be able to disabled/enable script easier to certain people. Right now I am asking if the Newtowk view is yours, if it is then the scrips are enabled to you, if it isn’t then it does not enable them.

This works fine, but I am manually going to have to type out every single script I want to add in to the code.

		if(networkView.isMine) {
			GetComponentInChildren<AudioListener>().enabled = true; //manually type in each of these
			GetComponentInChildren<MoveOnPath>().enabled = true;
			GetComponentInChildren<PathMaker>().enabled = true;
		}

what I was thinking was making some kind of array of names where I can just add an element in the inspector then it would take everything in that array and enable them if the neworkView is true.

so Something along these lines… Yet what I have tried hasn’t worked.

public string[] scriptList;

	// Use this for initialization
	void Start () {
		if(networkView.isMine) {
			foreach(string script in scriptList) {
				GetComponentInChildren<script>().enabled = true;
			}
		}
	}

How about using BroadcastMessage, with a small function that does the disable/enable in those scripts you want to allow that in.

–Eric

When you doing many functions with multiplayer this would be quit hard to setup, and would probably harder than just listing them in the owner script at the top.

So I thought of the listing but it seems to return “scriptName” and not the strings in the scriptList. any ideas?

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Owner : MonoBehaviour {
public List<string> scriptList = new List<string>();
private int scriptCount;

	/*/ Use this for initialization
	void Start () {
		if(networkView.isMine) {
			GetComponentInChildren<AudioListener>().enabled = true;
			GetComponentInChildren<Camera>().enabled = true;
			GetComponentInChildren<MoveOnPath>().enabled = true;
			GetComponentInChildren<PathMaker>().enabled = true;
			GetComponentInChildren<CamSelection>().enabled = true;
			GetComponentInChildren<camMovement>().enabled = true;
			GetComponentInChildren<MouseLook>().enabled = true;
		}
	}*/
	
	// Use this for initialization
	void Start () {
		scriptCount = scriptList.Count;
	}
	
	// Update is called once per frame
	void Update () {
		if(scriptCount <= 0)
			gameObject.GetComponent<Owner>().enabled = false;
		if(networkView.isMine) {
			foreach (string scriptName in scriptList) {
				Debug.Log(scriptCount);
				Debug.Log("scriptName");
				scriptCount --;
			}
		}
	}
}