public void SetAsset(MlfAsset asset) { this.scriptString = asset.mlfObject.MlfInstance.RawScript; instanced = false; compiledCode = null; instance = null; }
private void DrawDebug(MlfAsset scriptAsset) { foreach (string ds in MlfProcessorManager.DebugInstance(scriptAsset.mlfObject.MlfInstance)) { if (ds == null) { continue; } EditorGUILayout.LabelField(ds, EditorStyles.helpBox); } }
public override void OnImportAsset(AssetImportContext ctx) { MlfAsset mainObject = AssetDatabase.LoadAssetAtPath <MlfAsset>(ctx.assetPath); if (mainObject == null) { mainObject = ScriptableObject.CreateInstance <MlfAsset>(); } //Modify ScriptableAsset here mainObject.mlfObject = new MlfObject(File.ReadAllText(ctx.assetPath), ctx.assetPath); ctx.AddObjectToAsset("main obj", mainObject); ctx.SetMainObject(mainObject); }
public override void OnInspectorGUI() { Tree.UpdateTree(); MlfAsset scriptAsset = (MlfAsset)target; this.Tree.GetPropertyAtPath("mlfObject").Draw(null); EditorUtility.SetDirty(target); Tree.ApplyChanges(); if (scriptAsset.mlfObject.MlfInstance == null) { return; } debugDropdown = EditorGUILayout.Foldout(debugDropdown, "Debug Info", true); if (debugDropdown) { DrawDebug(scriptAsset); } }
public void OnGUI() { scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); //Regex: regexTesterDropdown = EditorGUILayout.Foldout(regexTesterDropdown, "Regex tester", true); if (regexTesterDropdown) { EditorGUI.indentLevel++; regex_pattern = EditorGUILayout.TextField("Pattern", regex_pattern); EditorGUILayout.LabelField("Text:"); regex_text = EditorGUILayout.TextArea(regex_text, GUILayout.MinHeight(400)); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Match", GUILayout.ExpandWidth(false))) { MatchCollection matches = Regex.Matches(regex_text, regex_pattern); regex_output = "(Match)\n"; regex_output += "count: " + matches.Count + "\n"; for (int i = 0; i < matches.Count; i++) { regex_output += i + ": " + matches[i].Value + "\n"; } } if (GUILayout.Button("Split", GUILayout.ExpandWidth(false))) { string[] splits = Regex.Split(regex_text, regex_pattern); regex_output = "(Split)\n"; regex_output += "count: " + splits.Length + "\n"; for (int i = 0; i < splits.Length; i++) { regex_output += i + ": " + splits[i] + "\n"; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("Output:"); EditorGUILayout.SelectableLabel(regex_output, EditorStyles.helpBox, GUILayout.MinHeight(400)); } inputScriptDopdown = EditorGUILayout.Foldout(inputScriptDopdown, "Input Script", true); if (inputScriptDopdown) { EditorGUI.indentLevel++; //Asset Selection EditorGUILayout.BeginHorizontal(); scriptAsset = (MlfAsset)EditorGUILayout.ObjectField(scriptAsset, typeof(MlfAsset), false); if (GUILayout.Button("Use Asset", GUILayout.ExpandWidth(false)) && scriptAsset != null) { SetAsset(scriptAsset); } EditorGUILayout.EndHorizontal(); //Text sekection EditorGUILayout.BeginHorizontal(); textInputText = EditorGUILayout.TextArea(textInputText); if (GUILayout.Button("Use Text", GUILayout.ExpandWidth(false)) && textInputText.Replace(" ", "") != "") { SetString(textInputText); } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; } if (scriptString == null) { EditorGUILayout.EndScrollView(); return; } clean = EditorGUILayout.Toggle("Clean", clean); if (instance == null && instanced == false) { instance = new MlfInstance(scriptString); instance.Interpret(clean); instanced = true; } if (instance != null && instance.Blocks != null) { DisplayScriptInfo(); } EditorGUILayout.EndScrollView(); }
//Opens a window with a script asset private static void ShowWindow(MlfAsset asset) { MlfInspectorWindow window = (MlfInspectorWindow)MlfInspectorWindow.GetWindow(typeof(MlfInspectorWindow), false, "Script Inspector"); window.SetAsset(asset); }
public void SetMlfInstance(MlfInstance instance) { parentAsset = null; mlfInstance = instance; }
public MlfObject(MlfAsset parentAsset) { this.parentAsset = parentAsset; this.overrideProperties = new PropertyOverrideList(); }