Hi, is there a way to assign variables to ScriptA, which is required by ScriptZ, so that these variables already show up in the editor? I want to accomplish some sort of auto-setup: A GameObject needs script A,B,C and I just want to assign script Z which assigns script A, B, C already with the right public variables. I can only imagine to do this in the Awake function but then false variables will be shown while still in the editor…
Example Code:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(ScriptA))]
public class ScriptB : MonoBehaviour {
public int a = 1;
public int b = 2;
void Awake() {
ScriptA scriptA = GetComponent<ScriptA>();
scriptA.a = a; // when game is inactive maybe ScriptA shows 42 instead of 1
}
void Update() {
do_something...
}
}