void Refresh() { if (configPaths == null) { configPaths = new List <string>(); } configPaths.Clear(); if (Directory.Exists(EditorOneBuild.ConfigDir)) { foreach (var filePath in Directory.GetFiles(EditorOneBuild.ConfigDir, "*" + EditorOneBuild.ExtensionName)) { string filename = Path.GetFileName(filePath); if (!EditorOneBuild.IsBuildFIle(filename)) { continue; } configPaths.Add(filePath.ReplacePathSeparator()); } } displayPaths = configPaths.Select(o => new GUIContent(o, o)).ToArray(); Select(selectedPath); UpdateBuildOptions(); }
static CachedMemberInfo _FindCachedType(string typeName) { if (cachedMembers == null) { cachedMembers = new Dictionary <string, CachedMemberInfo>(StringComparer.InvariantCultureIgnoreCase); } CachedMemberInfo result; if (!cachedMembers.TryGetValue(typeName, out result)) { Type type = EditorOneBuild.FindType(typeName); var cached = new CachedMemberInfo() { type = type }; cachedMembers[typeName] = cached; if (type != null) { cachedMembers[type.AssemblyQualifiedName] = cached; } } return(result); }
private void OnWizardCreate() { if (string.IsNullOrEmpty(filename)) { return; } string path = EditorOneBuild.CreateConfigFile(filename); callback?.Invoke(path); }
static MemberInfo FindMember(Type type, string memberName) { var mInfo = _FindCachedType(type.AssemblyQualifiedName); if (mInfo == null || mInfo.type == null) { return(null); } MemberInfo member; if (!mInfo.members.TryGetValue(memberName, out member)) { member = EditorOneBuild.FindSetMember(mInfo.type, memberName); mInfo.members[memberName] = member; } return(member); }
static bool OnOpenAsset(int instanceID, int line) { string assetPath; assetPath = AssetDatabase.GetAssetPath(instanceID); if (!string.IsNullOrEmpty(assetPath)) { if (EditorOneBuild.IsBuildFIle(assetPath)) { Show_Menu(); var win = GetWindow <OneBuildConfigEditorWindow>(); win.Select(assetPath); return(true); } } return(false); }
void GUIBuildSettigns() { using (new GUILayout.HorizontalScope()) { GUILayout.Label("Version Name".Localization(), GUILayout.ExpandWidth(false)); string versionName = UserBuildSettings.AvalibleVersionName; if (!UserBuildSettings.IsDebug) { if (string.IsNullOrEmpty(versionName)) { versionName = "Release"; } else { versionName = "Release," + versionName; } } GUILayout.Label("[" + versionName + "]", GUILayout.ExpandWidth(false)); GUILayout.Label("Version".Localization(), GUILayout.ExpandWidth(false)); using (var checker = new EditorGUI.ChangeCheckScope()) { if (versionFile == null) { versionFile = string.Empty; } //string[] parts = versionFile.Split('.'); //for (int i = 0; i < parts.Length; i++) //{ // string label = null; // switch (i) // { // case 0: // label = "Major"; // break; // case 1: // label = "Minor"; // break; // case 2: // label = "Build"; // break; // case 3: // label = "Revision"; // break; // } // if (i > 0) // GUILayout.Label(".", GUILayout.Width(10)); // //if (label != null) // // GUILayout.Label(label.Localization(), GUILayout.ExpandWidth(false)); // parts[i] = EditorGUILayoutx.DelayedEditableLabel(parts[i], GUILayout.Width(20)); //} versionFile = EditorGUILayoutx.DelayedEditableLabel(versionFile, GUILayout.ExpandWidth(false)); if (checker.changed) { //versionFile = string.Join(".", parts); EditorOneBuild.SaveVersionFile(versionFile); } } } }
void DrawTypeNode(XmlElement typeNode) { XmlAttribute attr; string typeName; typeName = typeNode.GetAttributeValue("type", string.Empty); attr = typeNode.GetOrAddAttribute("name", string.Empty); Type type = null; if (!string.IsNullOrEmpty(typeName)) { type = FindType(typeName); } object obj = null; using (new EditorGUILayout.HorizontalScope()) { EditorGUILayoutx.MenuButton(new GUIContent(typeName), "label", () => { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Delete".Localization()), false, () => { using (EditorOneBuild.EditorLocalizationValues.BeginScope()) { if (EditorUtility.DisplayDialog("Delete".Localization(), string.Format("msg_del_type_content".Localization(), typeName), "ok", "cancel")) { typeNode.ParentNode.RemoveChild(typeNode); DirtyConfig(); } } }); return(menu); }); attr.Value = EditorGUILayoutx.DelayedPlaceholderField(attr.Value ?? string.Empty, new GUIContent("Alias".Localization()), GUILayout.Width(120)); EditorGUILayoutx.MenuButton(new GUIContent("+"), "label", () => { GenericMenu menu = new GenericMenu(); var members = new Dictionary <string, MemberInfo>(EditorOneBuild.GetSetMembers(type)); foreach (XmlNode itemNode in typeNode.SelectNodes("ns:*", nsMgr)) { if (itemNode.NodeType == XmlNodeType.Element) { members.Remove(itemNode.Name); } } foreach (var member in members.Values.OrderBy(o => o.Name)) { if (member.IsDefined(typeof(System.ObsoleteAttribute), true)) { continue; } MethodInfo method1 = member as MethodInfo; if (method1 != null) { if (member.Name.StartsWith("Get") && method1.ReturnType != typeof(void)) { continue; } } menu.AddItem(new GUIContent(member.Name), false, (data) => { MemberInfo mInfo = (MemberInfo)data; XmlNode memberNode = typeNode.OwnerDocument.CreateElement(mInfo.Name, EditorOneBuild.XMLNS); if (mInfo.MemberType == MemberTypes.Field || mInfo.MemberType == MemberTypes.Property) { Type valueType; if (mInfo.MemberType == MemberTypes.Field) { FieldInfo fInfo = (FieldInfo)mInfo; valueType = fInfo.FieldType; } else { PropertyInfo pInfo = (PropertyInfo)mInfo; valueType = pInfo.PropertyType; } memberNode.InnerText = valueType.GetDefaultValue().ToStringOrEmpty(); } else if (mInfo.MemberType == MemberTypes.Method) { MethodInfo method = (MethodInfo)mInfo; foreach (var p in method.GetParameters()) { XmlNode paramNode = memberNode.OwnerDocument.CreateElement(p.Name, EditorOneBuild.XMLNS); paramNode.InnerText = p.ParameterType.GetDefaultValue().ToStringOrEmpty(); memberNode.AppendChild(paramNode); } } typeNode.AppendChild(memberNode); DirtyConfig(); }, member); } return(menu); }, GUILayout.ExpandWidth(false)); } if (string.IsNullOrEmpty(typeName)) { //EditorGUILayout.HelpBox("type name empty", MessageType.Error); // GUIUtility.ExitGUI(); } if (type == null) { //if (Event.current.type == EventType.Repaint) //EditorGUILayout.HelpBox($"type null, <{typeName}>", MessageType.Error); return; } using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope()) { foreach (var itemNode in ToEnumerable(typeNode.SelectNodes("*"))) { DrawConfigItem(type, itemNode); } } }
private void OnGUI() { using (EditorOneBuild.EditorLocalizationValues.BeginScope()) { GUIBuildSettigns(); using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("Open Project Settings".Localization())) { //EditorApplication.ExecuteMenuItem("Edit/Project Settings.../Player"); SettingsService.OpenProjectSettings("Project/Player"); // Selection.activeObject = Unsupported.GetSerializedAssetInterfaceSingleton("PlayerSettings"); } if (GUILayout.Button("Load Settings".Localization())) { EditorOneBuild.UpdateConfig(); } if (GUILayout.Button("Build".Localization())) { if (Event.current.shift) { var options = EditorOneBuild.CreateBuildOptions(); options.versionName = UserBuildSettings.AvalibleVersionName; options.isPreBuild = true; EditorOneBuild.Build(options); } else { EditorOneBuild.Build(UserBuildSettings.AvalibleVersionName); } } } using (new GUILayout.HorizontalScope()) { var style = new GUIStyle(EditorStyles.largeLabel); style.fontSize += 4; style.padding = new RectOffset(5, 0, 1, 0); style.margin = new RectOffset(); if (GUILayout.Button("↻", style, GUILayout.ExpandWidth(false))) { Refresh(); } int selectedIndex = configPaths.IndexOf(selectedPath); int newIndex = EditorGUILayout.Popup(selectedIndex, displayPaths); if (newIndex != selectedIndex) { Select(configPaths[newIndex]); } EditorGUILayoutx.PingButton(selectedPath); if (GUILayout.Button("New Config".Localization(), GUILayout.ExpandWidth(false))) { var wizard = ScriptableWizard.DisplayWizard <CreateBuildConfigWizard>("Create Build Config"); wizard.callback = (path) => { if (path != null) { path = path.ReplacePathSeparator(); GUIUtility.keyboardControl = -1; Refresh(); string newPath = null; for (int i = 0; i < configPaths.Count; i++) { if (configPaths[i].Equals(path, StringComparison.InvariantCultureIgnoreCase)) { newPath = configPaths[i]; break; } } Select(path); } }; } } if (doc == null) { return; } using (var sv = new GUILayout.ScrollViewScope(scrollPos)) { scrollPos = sv.scrollPosition; using (var checker = new EditorGUI.ChangeCheckScope()) { float oldWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = Mathf.Max(EditorGUIUtility.labelWidth, Screen.width * 0.3f); foreach (XmlElement typeNode in doc.DocumentElement.SelectNodes("ns:Type", nsMgr)) { DrawTypeNode(typeNode); } EditorGUIUtility.labelWidth = oldWidth; if (checker.changed) { DirtyConfig(); } } using (new GUILayout.HorizontalScope()) { if (doc != null) { if (GUILayout.Button("Add Type...", "popup")) { GenericMenu menu = new GenericMenu(); configTypes.Where(item => { Type configType = item.Key; if (!ContainsType(configType.FullName)) { menu.AddItem(new GUIContent(configType.FullName), false, () => { AddType(configType, item.Value); }); } return(false); }).ToArray(); menu.ShowAsContext(); } } } } } }
static void Show_Menu() { EditorOneBuild.EnsureConfig(); GetWindow <OneBuildConfigEditorWindow>().Show(); }
public static void UpdateBuildOptions() { versionFile = EditorOneBuild.GetVersionFile(); }
private void OnValidate() { filename = EditorOneBuild.GetConfigFileName(platform, channelName, userName, debug); isValid = !File.Exists(Path.Combine(EditorOneBuild.ConfigDir, filename)); }