because Component_Name is a string and not a type defined in your project and this is the reason of the error you get: Component_Move.Component_Name' is a field’ but a `type’ was expected.
However my question is: why have you to make a parameter for a type?
Why don’t you use an abstract class that could be then extended from different ones so you can have common operations redefined as much as you like?
Another suggestion is to not use the gameObject.Find because it’s a lot expensive. If you need the reference to a prefab that is not instantiated you can give the reference direcly after instantiation to the class who made the instance of the prefab.
To make you understand better what I’m saying, take a look to the new example. You will find 2 scenes: the first is the use of different component by using abstract class and its overrides, the second one is the use of a player and enemy hierarchy WITHOUT USING ANY GameObject.Find to optimaze the execution !!!
If you want you can also combine these 2 solutions to have one really optimized project !!!
The reason why we are so write,Because they can reduce the complexity of upgrading.
When adding a new gameobject,Do not need to modify other object.Only modify their own script code (Only set GameObject name and script name and to pass to Script_Center script ,It’s go! ),This can be achieved Uniformity and flexibility.
using UnityEngine;
using System.Collections;
public class Chief_Script : MonoBehaviour
{
public bool ON=false;
// Use this for initialization
public string GO_name;
public string Script_name;
void Start () {
}
// Update is called once per frame
void Update () {
if (ON)
{
// ((MyClass)GameObject.Find(GO_name).GetComponent("MyClass")).move=true; //It can go
((MyClass)GameObject.Find(GO_name).GetComponent(Script_name)).move = true;
ON = false;
}
}
}