void OnGUI() { PhxLuaRuntime rt = PhxGameRuntime.GetLuaRuntime(); if (!Application.isPlaying || rt == null) { EditorGUILayout.LabelField("LUA is not running"); return; } ScrollPos = EditorGUILayout.BeginScrollView(ScrollPos); PhxTimerDB tdb = PhxGameRuntime.GetTimerDB(); for (int i = 0; i < tdb.InUseIndices.Count; ++i) { int idx = tdb.InUseIndices[i]; tdb.GetTimer(idx, out PhxTimerDB.PhxTimer timer); EditorGUILayout.LabelField("Name", timer.Name); EditorGUILayout.LabelField("Time", (Mathf.Round(timer.Time * 100f) / 100f).ToString()); EditorGUILayout.LabelField("Rate", timer.Rate.ToString()); EditorGUILayout.LabelField("IsRunning", timer.IsRunning.ToString()); GUILayout.Space(20); } EditorGUILayout.EndScrollView(); }
void OnGUI() { PhxLuaRuntime rt = PhxGameRuntime.GetLuaRuntime(); if (!Application.isPlaying || rt == null) { EditorGUILayout.LabelField("LUA is not running"); return; } PhxRuntimeMatch gm = PhxGameRuntime.GetMatch(); ScrollPos = EditorGUILayout.BeginScrollView(ScrollPos); for (int i = 0; i < PhxRuntimeMatch.MAX_TEAMS; ++i) { PhxRuntimeMatch.PhxTeam t = gm.Teams[i]; EditorGUILayout.LabelField("Team ID", (i + 1).ToString()); EditorGUILayout.LabelField("Name", t.Name); EditorGUILayout.LabelField("Aggressiveness", t.Aggressiveness.ToString()); EditorGUILayout.LabelField("Icon", t.Icon?.ToString()); EditorGUILayout.LabelField("Unit Count", t.UnitCount.ToString()); EditorGUILayout.LabelField("Reinforcement Count", t.ReinforcementCount.ToString()); EditorGUILayout.LabelField("Spawn Delay", t.SpawnDelay.ToString()); EditorGUILayout.LabelField("Hero Class", t.HeroClass?.Name); GUILayout.Label("Unit Classes:"); foreach (PhxRuntimeMatch.PhxUnitClass unitClass in t.UnitClasses) { EditorGUILayout.LabelField(" " + unitClass.Unit.Name, unitClass.Count.ToString()); } GUILayout.Space(20); } EditorGUILayout.EndScrollView(); }
public void Invoke(params object[] args) { PhxLuaRuntime rt = PhxGameRuntime.GetLuaRuntime(); if (rt != null) { rt.CallLuaFunction(RefIdx, 0, false, false, args); } }
protected override TreeViewItem BuildRoot() { var root = new TreeViewItem { id = 0, depth = -1, displayName = "TABLE" }; PhxLuaRuntime runtime = PhxGameRuntime.GetLuaRuntime(); if (!Application.isPlaying || runtime == null) { return(root); } Lua L = runtime.GetLua(); // BuildRoot is called every time Reload is called to ensure that TreeViewItems // are created from data. Here we create a fixed set of items. In a real world example, // a data model should be passed into the TreeView and the items created from the model. // This section illustrates that IDs should be unique. The root item is required to // have a depth of -1, and the rest of the items increment from that. PhxLuaRuntime.Table table = runtime.ToValue(TableIdx) as PhxLuaRuntime.Table; if (table != null) { var allItems = new List <TreeViewItem>(); int id = 0; void AddTable(PhxLuaRuntime.Table t, int depth) { foreach (KeyValuePair <object, object> entry in table) { if (entry.Value is PhxLuaRuntime.Table) { AddTable((PhxLuaRuntime.Table)entry.Value, depth + 1); } else { allItems.Add(new TreeViewItem { id = id++, depth = depth, displayName = string.Format($"{entry.Key.ToString()} = {entry.Value.ToString()}") }); } } } AddTable(table, 0); // Utility method that initializes the TreeViewItem.children and .parent for all items. SetupParentsAndChildrenFromDepths(root, allItems); } // Return root of the tree return(root); }
void OnGUI() { PhxLuaRuntime runtime = PhxGameRuntime.GetLuaRuntime(); if (!Application.isPlaying || runtime == null) { EditorGUILayout.LabelField("LUA is not running"); return; } Lua L = runtime.GetLua(); GUILayout.BeginHorizontal(); LuaCode = GUILayout.TextArea(LuaCode, /*EditorStyle, */ GUILayout.Width(400), GUILayout.ExpandHeight(true)); GUILayout.BeginVertical(GUILayout.ExpandWidth(true)); int stackSize = L.GetTop(); for (int i = stackSize - 1; i >= 0; --i) { Lua.ValueType type = L.Type(i); string typeStr = type.ToString(); if (type == Lua.ValueType.TABLE) { GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("TABLE"); if (GUILayout.Button(TreeView == null ? "Expand" : "Collapse")) { if (TreeView == null) { TreeView = new TableTreeView(new TreeViewState(), i); } else { TreeView = null; } } Rect last = GUILayoutUtility.GetLastRect(); GUILayout.EndHorizontal(); if (TreeView != null && TreeView.TableIdx == i) { GUILayout.Space(100); TreeView.OnGUI(new Rect(last.x, last.y + last.height, position.width, 100)); } } else { object value = runtime.ToValue(i); string valueStr = value != null?value.ToString() : "NIL"; EditorGUILayout.LabelField(typeStr, valueStr); } } GUILayout.Space(20); EditorGUILayout.LabelField("GC Count", L.GetGCCount().ToString()); EditorGUILayout.LabelField("GC Threshold", L.GetGCThreshold().ToString()); EditorGUILayout.LabelField("Used callbacks", L.UsedCallbackCount.ToString() + "/200"); GUILayout.EndVertical(); GUILayout.EndHorizontal(); if (GUILayout.Button("Execute")) { runtime.ExecuteString(LuaCode); } }