The reference is actively associated with the declared variable name.
Use this association to refer to two different ways
1. Give you the component inheritance Monoautoquote click on the Component Inspector button to execute
2. Add the [Aautoquote] attribute to your component class by Plateface/setselectgameref execution
[Aautoquote] Public class monoautoquote:monobehaviour, iautoquote{}
Public interface Iautoquote {}
public class Aautoquote:attribute {}
usingSystem.Collections;usingSystem.Collections.Generic;usingUnityengine;usingUnityeditor;usingSystem.Reflection;//[Caneditmultipleobjects][Customeditor (typeof(Monoautoquote),true)] Public classautoquoteeditor:editor{ Public Override voidOninspectorgui () {Base. Oninspectorgui (); if(Guilayout.button ("associating child node references") {Component C= Target asComponent; if(c! =NULL) Autioquotemenu.setref (c, C.gameobject); } }} Public classautioquotemenu{[MenuItem ("plateface/setselectgameref%&a")] Public Static voidSetRef () {gameobject o=Selection.activegameobject; if(O! =NULL) {component[] CAry= o.getcomponents<component>(); foreach(varCinchCAry) {System.Type ComponentType=C.gettype (); if((typeof(Monobehaviour). IsAssignableFrom (componenttype)) | |Ishasattribute (ComponentType)) {SetRef (c, O); } } } } Public Static voidSetRef (Component C, Gameobject o) {System.Type T=C.gettype (); varInfolist = T.getfields (BindingFlags.Public |bindingflags.instance); System.Text.StringBuilder SB=NewSystem.Text.StringBuilder (); stringName =string. Empty; foreach(varIteminchinfolist) { varFieldType =item. FieldType; if((typeof(Monobehaviour). IsAssignableFrom (FieldType))) {if(item. Name.startswith ("m") ) {Name= Item. Name.substring (1); Transform TR=O.transform.find (name); if(tr = =NULL) {debug.logerror (name+"reference not found"); Continue; } Component com=tr. Getcomponent (FieldType); Item. SetValue (c, COM); } } } } Public Static BOOLIshasattribute (System.Type Type) {system.object[] olist= Type. GetCustomAttributes (typeof(Aautoquote),false); foreach(varItemincholist) { if(item asAautoquote)! =NULL) return true; } return false; }}
Unity Inspector automatically associates references to components (ii)