void OnEnable() { string val = DialogueLua.GetVariable("UserChoice").asString; var graphReference = GraphReference.New(_TargetFlowMachine, true); Variables.Graph(graphReference).Set(_TargetGraphVariableName, val); }
public override string GenerateValueOutput(ValueOutput output, int indent) { var outputString = string.Empty; if (output == liveUnit.result) { var a = liveUnit.a; var b = liveUnit.b; var entry = (unit.graph.units.ToListPooled().Where((x) => { return((x as EntryUnit) != null); }).ToListPooled()[0] as EntryUnit); var methodInput = entry as MethodInputUnit; GraphReference reference = null; if (methodInput != null) { reference = GraphReference.New(methodInput.macro, BoltX.UnitGuids(methodInput.graph as FlowGraph), false); } var aConnection = a.connection; var bConnection = b.connection; var aSource = aConnection.source; var bSource = bConnection.source; outputString += aConnection != null?aSource.unit.CodeGenerator().GenerateValueOutput(aSource, 0) : Patcher.ActualValue(a.type, Flow.FetchValue(a, a.type, reference)); outputString += CodeBuilder.Operator(BinaryOperator.Or); outputString += bConnection != null?bSource.unit.CodeGenerator().GenerateValueOutput(bSource, 0) : Patcher.ActualValue(b.type, Flow.FetchValue(b, b.type, reference)); } return(outputString); }
private void EditButton(Rect position) { if (GUI.Button(position, "Edit")) { GraphWindow.OpenActive(GraphReference.New((Method)macro.objectReferenceValue, true)); } }
/// <summary> /// Draws a button to click and edit the graph of this method. /// </summary> /// <param name="previous"></param> private Rect EditGraph(Rect previous) { var padding = 4f; var doublePadding = padding * 2; var returnLabelSize = GUI.skin.label.CalcSize(new GUIContent("Returns")); var buttonRect = previous; buttonRect.y += 24; buttonRect.x += padding; buttonRect.width -= doublePadding; buttonRect.height = 18; if (GUI.Button(buttonRect, "Edit Graph")) { declaration.owner.activeGraph = declaration.graph; var reference = GraphReference.New(declaration, true); GraphWindow.OpenActive(reference); } y += 20; return(buttonRect); }
void EditGraph() { if (graphReference.IsUnityNull()) { graphReference = GraphReference.New(flowMacro, ensureValid: true); } if (!graphReference.IsUnityNull() && graphReference.isValid) { GraphWindow.OpenActive(graphReference); } }
/// <summary> /// Invokes a method of a Live Type. /// </summary> /// <param name="method"></param> /// <param name="liveType"></param> /// <param name="parameters"></param> public static void InvokeVoid(MethodInstance instance) { var reference = GraphReference.New(instance.method, true); var flow = Flow.New(reference, instance.isCoroutine); flow.AssignLocal <ILiveObject>("This", instance.target); SetParameters(instance, ((MethodInputUnit)instance.method.entry)); TriggerFlow(flow, instance.method.entry.trigger); RemoveInstance(instance); }
protected override void DefinePorts() { @do = ControlOutput("do"); next = ControlOutput("next"); enter = ControlInput("enter", new System.Func <Flow, ControlOutput>((flow) => { do { var _flow = Flow.New(GraphReference.New((entry as MethodInputUnit)?.declaration, false)); flow.Invoke(@do); }while (flow.GetValue <bool>(condition)); return(next); })); condition = ValueInput <bool>("condition", true); }
/// <summary> /// Invokes a method of a Live Type. /// </summary> /// <param name="method"></param> /// <param name="liveType"></param> /// <param name="parameters"></param> public static IEnumerator InvokeEnumerator(MethodInstance instance) { var reference = GraphReference.New(instance.method, true); var flow = Flow.New(reference, instance.isCoroutine); flow.AssignLocal <ILiveObject>("This", instance.target); SetParameters(instance, ((MethodInputUnit)instance.method.entry)); yield return(TriggerFlowEnumerator(flow, instance.method.entry.trigger)); IEnumerator output = (IEnumerator)instance.returnObject; RemoveInstance(instance); yield return(output); }
/// <summary> /// Invokes a method of a Live Type. /// </summary> /// <param name="method"></param> /// <param name="liveType"></param> /// <param name="parameters"></param> public static TReturnType InvokeReturn <TReturnType>(MethodInstance instance) { var reference = GraphReference.New(instance.method, true); var flow = Flow.New(reference, instance.isCoroutine); flow.AssignLocal <ILiveObject>("This", instance.target); SetParameters(instance, ((MethodInputUnit)instance.method.entry)); TriggerFlow(flow, instance.method.entry.trigger); TReturnType output = (TReturnType)instance.returnObject; RemoveInstance(instance); return(output); }
public static void MethodOverride(Metadata method, GUIContent label) { var _method = ((Method)method.value); HUMEditor.Horizontal(() => { HUMEditor.Horizontal().Box(HUMEditorColor.DefaultEditorBackground.Darken(0.075f), Styles.borderColor, new RectOffset(2, 2, 2, 2), new RectOffset(1, 1, 1, 1), () => { if (_method.entry.declaration.isMagic) { GUILayout.Box(GUIContent.none, new GUIStyle() { normal = new GUIStyleState() { background = Images.special_16 } }, GUILayout.Width(16), GUILayout.Height(16)); } EditorGUILayout.LabelField(GUIContent.none, GUILayout.Width(100)); var lastRect = GUILayoutUtility.GetLastRect(); HUMEditor.Disabled(_method.entry.declaration.isAbstract, () => { HUMEditor.Disabled(_method.entry.declaration.hasOptionalOverride, () => { LudiqGUI.Inspector(method["entry"]["declaration"]["type"], new Rect(lastRect.x, lastRect.y, 80, 20), GUIContent.none); }); LudiqGUI.Inspector(method["entry"]["declaration"]["isOverridden"], new Rect(lastRect.x + lastRect.width - 16, lastRect.y, 20, 20), GUIContent.none); GUILayout.Label(label); }); HUMEditor.Disabled(_method.entry.declaration.hasOptionalOverride && !_method.entry.declaration.isOverridden, () => { if (GUILayout.Button("Edit", GUILayout.Width(42))) { GraphWindow.OpenActive(GraphReference.New(_method, true)); } }); }); }); }
protected override void OnGUIBlock(Rect position, GUIContent label) { EditorGUI.BeginDisabledGroup(!((Property)propertyMeta.value).isProperty); var getRect = position; getRect.height = 16; getRect.width = 40; var useScopeRect = position; useScopeRect.x += 40; useScopeRect.height = 16; useScopeRect.width = 16; var y = 0f; bool canEditAccessor = ((Property)propertyMeta.value).get && !((Property)propertyMeta.value).set || ((Property)propertyMeta.value).get && ((Property)propertyMeta.value).set; bool getAccessible = ((Property)propertyMeta.value).setter.scope == AccessModifier.Public; LudiqGUI.Inspector(getMeta, getRect, new GUIContent("Get")); EditorGUI.BeginDisabledGroup(!canEditAccessor); EditorGUI.BeginDisabledGroup(!getAccessible); LudiqGUI.Inspector(scopeMeta, new Rect(useScopeRect.x + 18, useScopeRect.y, (position.width * 0.65f) - 18, 16), GUIContent.none); EditorGUI.EndDisabledGroup(); EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(!canEditAccessor || !((Property)propertyMeta.value).isProperty); if (GUI.Button(new Rect(useScopeRect.x + position.width * 0.65f + 4, useScopeRect.y, position.width * 0.35f - 4, 16), "Edit")) { GraphWindow.OpenActive(GraphReference.New((Getter)accessor.value, false)); } EditorGUI.EndDisabledGroup(); EditorGUI.EndDisabledGroup(); y += 18; height = y; }
private void OnGUI() { GUIStyle style = new GUIStyle("label"); style.richText = true; EditorGUILayout.BeginHorizontal(); mode = (Mode)EditorGUILayout.EnumPopup(mode, GUILayout.Width(100)); if (GUILayout.Button("Collect", GUILayout.Width(100))) { unitList.Clear(); searchResultMap.Clear(); Collect <string>(); Search(); } EditorGUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Filter", GUILayout.Width(100)); filter = EditorGUILayout.DelayedTextField(filter); EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { Search(); } EditorGUILayout.LabelField($@"Unit Count = {searchResultMap.Count} / {unitList.Count}"); // Navigation n.StartNavigation(); GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(4)); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); foreach (var kvp in searchResultMap) { var sr = kvp.Value; // Navigation if (!n.CheckNavigation()) { continue; } var unitData = sr.unitData; var mb = unitData.monoBehaviour; var unit = unitData.unit; var graph = unitData.flowGraph; var flowMacro = unitData.flowMacro; EditorGUILayout.LabelField($@"<b>[{n.RefCount}]</b> {sr.unitData.hierachy}", style); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(unit.ToSafeString(), GUILayout.Width(200))) { if (mb) { Selection.activeObject = mb; } if (flowMacro.IsUnityNull()) { GraphWindow.OpenTab(); } else { if (!unitData.superUnit.IsUnityNull()) { // Open SuperUnit var graphRef = GraphReference.New(flowMacro, true); var hierachyUnits = new List <SuperUnit>(); var currUnitData = unitData; while (currUnitData != null && !currUnitData.superUnit.IsUnityNull()) { hierachyUnits.Insert(0, currUnitData.superUnit); currUnitData = unitList.Find(x => x.unit == currUnitData.superUnit); } for (int i = 0; i < hierachyUnits.Count; i++) { var u = hierachyUnits[i]; Debug.Log($"{u.ToString()} { u.nest.graph.title}"); var currGraphRef = graphRef.ChildReference(u, false); if (!currGraphRef.IsUnityNull()) { graphRef = currGraphRef; } } GraphWindow.OpenActive(graphRef); } else { // Open Macro GraphWindow.OpenActive(GraphReference.New(flowMacro, true)); } } // Pan graph.pan = unit.position; } if (mb) { EditorGUILayout.ObjectField(mb, typeof(MonoBehaviour), true, GUILayout.Width(200)); } if (flowMacro) { EditorGUILayout.ObjectField(flowMacro, typeof(FlowMacro), true, GUILayout.Width(200)); } EditorGUILayout.EndHorizontal(); // Matched ports EditorGUILayout.BeginVertical(); foreach (var idx in sr.matchPorts) { var pd = idx >= 0 ? sr.unitData.portDatas[idx] : null; if (pd != null) { var portName = pd.GetPortName(); string valueContent = pd.GetValueCache <string>(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField($"{portName}", GUILayout.Width(200)); EditorGUILayout.TextField(valueContent, GUILayout.Width(200)); EditorGUILayout.EndHorizontal(); } } GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(4)); EditorGUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(4)); // End Navigation n.EndNavigation(); }
private void Methods(Rect position) { UAGUI.IconFoldout(ref _target.editorData.customMethodsOpen, "Methods", Images.flow_icon_16, () => { HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.025f), Styles.borderColor, new RectOffset(4, 4, 4, 2), new RectOffset(1, 1, 0, 1), () => { var methods = metadata["methods"]["custom"]; var methodsVal = (List <Method>)metadata["methods"]["custom"].value; for (int i = 0; i < methodsVal.Count; i++) { if (i != 0) { GUILayout.Space(2); } var meth = methodsVal[i]; methodsVal[i].isOpen = HUMEditor.Foldout(methodsVal[i].isOpen, Styles.backgroundColor.Brighten(0.05f), Styles.borderColor, 1, () => { BeginBlock(metadata["name"], position); meth.name = GUILayout.TextField(meth.name); meth.entry.declaration.name = meth.name; if (EndBlock(metadata["name"])) { meth.entry.declaration.Changed(); } if (GUILayout.Button("Edit", GUILayout.Width(42))) { GraphWindow.OpenActive(GraphReference.New(methodsVal[i], true)); } if (GUILayout.Button("-", GUILayout.Width(16), GUILayout.Height(18))) { methodsVal.Remove(meth); meth.entry.Define(); AssetDatabase.RemoveObjectFromAsset(meth); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); var definer = _target.Definer() as ClassDefiner; definer.Define(); } }, () => { HUMEditor.Vertical(() => { BeginBlock(methods[i], position, GUIContent.none); HUMEditor.Horizontal(() => { HUMEditor.Vertical().Box(HUMEditorColor.DefaultEditorBackground.Darken(0.025f), Styles.borderColor, new RectOffset(8, 8, 8, 8), new RectOffset(1, 1, 0, 1), () => { LudiqGUI.InspectorLayout(methods[i]["entry"]["declaration"]["type"], new GUIContent("Returns")); if ((Type)methods[i]["entry"]["declaration"]["type"].value == typeof(Lasm.UAlive.Void)) { GUILayout.Space(6); } else { LudiqGUI.InspectorLayout(methods[i]["entry"]["declaration"]["pure"], new GUIContent("Pure")); } UAGUI.IconFoldout(ref methodsVal[i].entry.declaration.parametersOpen, "Parameters", Images.parameters_16, () => { LudiqGUI.InspectorLayout(methods[i]["entry"]["declaration"]["parameters"], GUIContent.none); }, Styles.backgroundColor.Brighten(0.05f), 0); }); }); if (EndBlock(methods[i])) { meth.entry.Define(); } }); }); } if (GUILayout.Button("+ New Method")) { var meth = Method.Create(_target); methodsVal.Add(meth); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); var definer = _target.Definer() as ClassDefiner; definer.Define(); } }); }); }
public void Invoke() { var flow = Flow.New(GraphReference.New(this, true), false); flow.Invoke(entry.trigger); }
public static GraphReference GetReference(FlowMacro macro) { return(GraphReference.New(macro, false)); }
public static void InvokeCustomEvent(FlowMacro macro, string name, [AllowsNull] params object[] args) { var reference = GraphReference.New(macro, true); reference.TriggerEventHandler <CustomEventArgs>(hook => hook.name == "Custom", new CustomEventArgs(name, args), parent => true, true); }