Hey Guys I need this Loop to work for Script Array and Disable on Child, If Network View is not Mine. Make Sense?
using UnityEngine;
using System.Collections;
public class Network_Obj : MonoBehaviour {
public string[] scriptName;
void Awake () {
if (!networkView.isMine)
{
for ( int i = 0; i < scriptName.Length; i ++)
{
GameObject.FindGameObjectWithTag("Player").GetComponentInChildren(scriptName*).enabled = false;*
-
}* -
}* -
}*
}
Here is one error :
Assets/Script/NetWork/Network_Obj.cs(12,76): error CS1503: Argument #1' cannot convert string’ expression to type `System.Type’
Updated :
using UnityEngine;
using System.Collections;
using System;
public class Network_Obj : MonoBehaviour {
-
public Type scriptName;*
-
void Awake () {*
-
if (!networkView.isMine)* -
{* -
for ( int i = 0; i < scriptName.Length; i ++)* -
{*
_ GameObject.FindGameObjectWithTag(“Player”).GetComponentInChildren(scriptName*).enabled = false;_
_ }_
_ }*_
* }*
}
error now is, Cant Disable it. Please help me if possible
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Solved
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Updated -
using UnityEngine;
using System.Collections;
using System;
public class Network_Obj : MonoBehaviour {
* public Type[] scriptName;*
* void Awake () {*
* if (!networkView.isMine)*
* {*
* GameObject s = this.gameObject;*
// for ( float i = 0; i < scriptName.Length; i ++)
// {
// s.GetComponentInChildren<scriptName*>().enabled = false;*
// }
* s.GetComponentInChildren<FPS_shooting>().enabled = false;
_ s.GetComponentInChildren().enabled = false;
s.GetComponentInChildren().enabled = false;
s.GetComponentInChildren().enabled = false;
s.GetComponentInChildren().enabled = false;
s.GetComponentInChildren().enabled = false;
s.GetComponentInChildren().enabled = false;
s.GetComponentInChildren().enabled = false;*_
* }*
* }*
}
the lines i keep typing, they work. However this is reason i want to do it faster with a for command.