protected void Awake() { Debug.Log("Container awake", this); BloxGlobal.Create(this.bloxGlobalPrefab); this.customEvents = new Dictionary <string, List <BloxEvent> >(); this.bloxVarCache = new Dictionary <string, BloxVariables>(); Debug.Log("生成事件和变量缓存"); for (int i = 0; i < this.bloxVars.Count; i++) { Debug.Log("添加变量缓存" + this.bloxVars[i].bloxIdent + " 值 " + this.bloxVars[i]); this.bloxVarCache.Add(this.bloxVars[i].bloxIdent, this.bloxVars[i]); this.CheckVariables(this.bloxVars[i], BloxGlobal.Instance.FindBloxDef(this.bloxIdents[i])); this.bloxVars[i].BuildCache(); } for (int j = 0; j < this.bloxIdents.Count; j++) { Blox blox = BloxGlobal.Instance.FindBloxDef(this.bloxIdents[j]); if (!((UnityEngine.Object)blox == (UnityEngine.Object)null)) { if (!this.bloxVarCache.ContainsKey(this.bloxIdents[j])) { BloxVariables bloxVariables = new BloxVariables(); bloxVariables.bloxIdent = this.bloxIdents[j]; this.bloxVars.Add(bloxVariables); this.bloxVarCache.Add(bloxVariables.bloxIdent, bloxVariables); this.CheckVariables(bloxVariables, blox); bloxVariables.BuildCache(); } this.AttachComponents(blox); } } }
public plyVar FindVariable(string bloxIdent, string varName) { BloxVariables bloxVariables = this.GetBloxVariables(bloxIdent, null); if (bloxVariables == null) { return(null); } return(bloxVariables.FindVariable(varName)); }
public plyVar FindVariable(string bloxIdent, string varName) { Debug.Log("查找变量 FindVariable " + "bloxIdent:" + bloxIdent + "varName:" + varName); BloxVariables bloxVariables = this.GetBloxVariables(bloxIdent, null); if (bloxVariables == null) { return(null); } return(bloxVariables.FindVariable(varName)); }
private void CheckVariables(BloxVariables v, Blox b) { Debug.Log("CheckVariables " + " BloxVariables: " + v + "Blox: " + b); if (v != null && !((UnityEngine.Object)b == (UnityEngine.Object)null)) { if (v.varDefs.Count > 0) { for (int num = v.varDefs.Count - 1; num >= 0; num--) { plyVar plyVar = v.varDefs[num]; bool flag = false; for (int i = 0; i < b.variables.varDefs.Count; i++) { plyVar plyVar2 = b.variables.varDefs[i]; if (plyVar.ident == plyVar2.ident) { plyVar.name = plyVar2.name; if (plyVar.variableType != plyVar2.variableType) { plyVar2.CopyTo(plyVar); } flag = true; break; } } if (!flag) { v.varDefs.RemoveAt(num); } } } for (int j = 0; j < b.variables.varDefs.Count; j++) { plyVar plyVar3 = b.variables.varDefs[j]; bool flag2 = false; int num2 = 0; while (num2 < v.varDefs.Count) { if (plyVar3.ident != v.varDefs[num2].ident) { num2++; continue; } flag2 = true; break; } if (!flag2) { v.varDefs.Add(plyVar3.Copy()); } } } }
public BloxVariables GetBloxVariables(string bloxIdent, Blox b = null) { BloxVariables bloxVariables = null; if ((UnityEngine.Object)b == (UnityEngine.Object)null) { if (this.bloxVarCache == null) { this.BuildVarCache(); } if (this.bloxVarCache.TryGetValue(bloxIdent, out bloxVariables)) { return(bloxVariables); } Debug.LogError("This Blox Container does not contain variables for a Blox with ident: " + bloxIdent, base.gameObject); } else { if (this.bloxVars.Count > 0) { for (int num = this.bloxVars.Count - 1; num >= 0; num--) { if (!this.bloxIdents.Contains(this.bloxVars[num].bloxIdent)) { this.bloxVars.RemoveAt(num); } } } if (this.bloxVarCache == null) { this.bloxVarCache = new Dictionary <string, BloxVariables>(); for (int i = 0; i < this.bloxVars.Count; i++) { this.bloxVarCache.Add(this.bloxVars[i].bloxIdent, this.bloxVars[i]); } } this.bloxVarCache.TryGetValue(bloxIdent, out bloxVariables); if (bloxVariables == null) { bloxVariables = new BloxVariables(); bloxVariables.bloxIdent = bloxIdent; this.bloxVars.Add(bloxVariables); this.bloxVarCache.Add(bloxIdent, bloxVariables); } else if (!Application.isPlaying) { bloxVariables.Deserialize(false); } this._CheckVariables(bloxVariables, b); } return(bloxVariables); }
private void OnSelectBlox() { this.activeVars = null; this.selectedBlox = this.targetBloxCache[this.list.index]; if ((UnityEngine.Object) this.selectedBlox != (UnityEngine.Object)null) { if (this.selectedBlox.variables.varDefs.Count == 0) { this.selectedBlox.variables.Serialize(); this.selectedBlox.variables.Deserialize(false); } BloxContainerInspector.GC_VarsHead.text = "Variables of: " + this.selectedBlox.screenName; this.activeVars = this.Target.GetBloxVariables(this.selectedBlox.ident, this.selectedBlox); this.activeVars._SetDirty(); this.Save(); this.varEditor.SetTarget(this.activeVars, this.Target.gameObject); base.Repaint(); } if (!BloxEdGlobal.DoubleClickOpenBloxDef && this.list.index >= 0 && this.list.index < this.targetBloxCache.Count) { BloxEditorWindow.Show_BloxEditorWindow(this.targetBloxCache[this.list.index]); } }
protected void Awake() { BloxGlobal.Create(this.bloxGlobalPrefab); this.customEvents = new Dictionary <string, List <BloxEvent> >(); this.BuildVarCache(); for (int i = 0; i < this.bloxIdents.Count; i++) { Blox blox = BloxGlobal.Instance.FindBloxDef(this.bloxIdents[i]); if (!((UnityEngine.Object)blox == (UnityEngine.Object)null)) { if (!this.bloxVarCache.ContainsKey(this.bloxIdents[i])) { BloxVariables bloxVariables = new BloxVariables(); bloxVariables.bloxIdent = this.bloxIdents[i]; this.bloxVars.Add(bloxVariables); this.bloxVarCache.Add(bloxVariables.bloxIdent, bloxVariables); this._CheckVariables(bloxVariables, blox); bloxVariables.BuildCache(); } this.AttachComponents(blox); } } }