public int GetState(StateRequirement requirement) { if (requirement.requireOn) { return(1); } if (requirement.requireOff) { return(2); } return(0); }
public string DrawState(StateRowData[] rowData, int rowIndex, string title, bool flip = false) { StateRowData row = rowData[rowIndex]; string phrase = ""; var alias = "State-" + this.target.As <StateBehaviour>().alias; if (title.ToLabel().DrawFoldout(alias + "-" + title + rowIndex.ToString() + flip.Serialize(), EditorStyles.foldout.RichText(true))) { EditorGUILayout.BeginVertical(); bool hasDrawn = false; for (int index = 0; index < row.data.Length; ++index) { StateRequirement requirement = row.data[index]; if (flip && requirement.name == "@External") { continue; } if (!requirement.requireOn && !requirement.requireOff && !requirement.requireUsed) { continue; } string name = "</i><color=" + this.nameColor + ">" + requirement.name + "</color><i>"; string stateName = "ON"; string stateColor = this.onColor; if (requirement.requireOff || (flip && requirement.requireOn)) { stateName = "OFF"; stateColor = this.offColor; } if (requirement.requireUsed) { stateName = "USED"; stateColor = this.usedColor; } string state = "</i><color=" + stateColor + "><b>" + stateName + "</b></color><i>"; phrase = name + " " + state; var extraColor = "<color=" + this.nameColor.ToColor().SetAlpha(0.3f).ToHex() + ">"; if (hasDrawn) { phrase = extraColor + (flip ? "or " : "and ") + "</color>" + phrase; } phrase = "<i>" + phrase.ToUpper() + "</i>"; phrase.ToLabel().DrawLabel(this.labelStyle); hasDrawn = true; } EditorGUILayout.EndVertical(); } return(phrase); }