6 namespace droid.Runtime.Utilities.GameObjects {
15 [Header(
"Naming", order = 10)]
16 protected string _Custom_Name =
"";
18 [SerializeField]
bool _debugging;
20 [Header(
"Development", order = 90)]
24 bool _disables_children =
false;
30 bool _editor_reregistering =
true;
33 [SerializeField]
bool _unregister_at_disable =
false;
36 public bool Debugging {
get {
return this._debugging; }
set { this._debugging = value; } }
40 public virtual string PrototypingTypeName {
get {
return this.GetType().Name; } }
46 public string Identifier {
48 if (!
string.IsNullOrWhiteSpace(this._Custom_Name)) {
49 return this._Custom_Name.Trim();
52 return this.name + this.PrototypingTypeName;
58 protected void Start() { this.ReRegister(); }
62 if (this.enabled && this.isActiveAndEnabled) {
64 this.UnRegisterComponent();
65 this.RegisterComponent();
67 }
catch (ArgumentNullException e) {
69 Debug.Log($
"You must override RegisterComponent and UnRegisterComponent for component {this.GetType()} for gameobject {this.Identifier} in order to Re-register component on every 'OnValidate' while in edit-mode");
76 if (this.enabled && this.isActiveAndEnabled) {
84 if (this._disables_children) {
85 var children = this.GetComponentsInChildren<PrototypingGameObject>();
86 foreach (var child
in children) {
87 if (child.gameObject !=
this.gameObject) {
88 child.enabled =
false;
89 child.gameObject.SetActive(
false);
93 foreach (Transform child
in this.transform) {
94 if (child != this.transform) {
96 child.gameObject.SetActive(
false);
101 if (this._unregister_at_disable) {
102 this.UnRegisterComponent();
108 void CallOnDisable() { this.OnDisable(); }
112 void CallOnEnable() { this.OnEnable(); }
117 if (this._disables_children) {
118 foreach (Transform child
in this.transform) {
119 if (child != this.transform) {
120 child.gameObject.SetActive(
true);
125 var children = this.GetComponentsInChildren<PrototypingGameObject>();
126 foreach (var child
in children) {
127 if (child.gameObject !=
this.gameObject) {
128 child.enabled =
true;
129 child.gameObject.SetActive(
true);
149 if (EditorApplication.isPlaying || !
this._editor_reregistering) {
160 protected abstract void UnRegisterComponent();
165 protected abstract void RegisterComponent();
170 if (this.enabled && this.isActiveAndEnabled) {
178 if (this.enabled && this.isActiveAndEnabled) {