private void DoLayoutToolbar() { GUILayout.Space(1); using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar)) { using (var projectScope = new EditorGUILayout.HorizontalScope(GUILayout.Width(120))) { var buttonLabel = GetProjectButtonName(); if (UTinyEditorApplication.IsChanged) { buttonLabel += " *"; } if (GUILayout.Button(buttonLabel, EditorStyles.toolbarDropDown)) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("New Project"), false, NewProject); menu.AddItem(new GUIContent("New Module"), false, NewModule); menu.AddSeparator(string.Empty); menu.AddItem(new GUIContent("Load..."), false, LoadProject); menu.AddSeparator(string.Empty); var save = new GUIContent("Save"); if (UTinyEditorApplication.Project == null) { menu.AddDisabledItem(save); } else { menu.AddItem(save, false, () => { UTinyEditorApplication.Save(); }); } var saveAs = new GUIContent("Save As..."); if (UTinyEditorApplication.Project == null) { menu.AddDisabledItem(saveAs); } else { menu.AddItem(saveAs, false, () => { UTinyEditorApplication.SaveAs(); }); } menu.AddSeparator(string.Empty); var closeProject = new GUIContent("Close"); if (UTinyEditorApplication.Project == null) { menu.AddDisabledItem(closeProject); } else { menu.AddItem(closeProject, false, () => { if (!UTinyEditorApplication.SaveChanges()) { return; } m_TabType = TabType.Settings; UTinyEditorApplication.Close(); }); } menu.DropDown(projectScope.rect); } } GUILayout.FlexibleSpace(); if (UTinyEditorApplication.ContextType == EditorContextType.Project) { var project = UTinyEditorApplication.Project; var workspace = UTinyEditorApplication.EditorContext.Workspace; if (null != project && null != workspace) { var lastBuildConfiguration = workspace.BuildConfiguration; workspace.BuildConfiguration = (UTinyBuildConfiguration)EditorGUILayout.EnumPopup(workspace.BuildConfiguration, EditorStyles.toolbarDropDown, GUILayout.Width(100)); if (workspace.BuildConfiguration != lastBuildConfiguration) { UTinyEditorUtility.RepaintAllWindows(); } if (GUILayout.Button("Export", EditorStyles.toolbarButton, GUILayout.Width(100))) { UTinyBuildPipeline.Export(project); } workspace.Preview = GUILayout.Toggle( workspace.Preview, new GUIContent(UTinyIcons.Export, "Toggles preview in browser."), EditorStyles.toolbarButton, GUILayout.Width(35)); } } } }
public override void Header() { var entities = Targets.Cast <UTinyEntity>(); var firstEntity = entities.FirstOrDefault(); if (null == firstEntity) { return; } UTinyGUI.BackgroundColor(new Rect(0, 0, Screen.width, 15 + 2 * UTinyGUIUtility.SingleLineAndSpaceHeight), UTinyColors.Inspector.HeaderBackground); GUILayout.Space(10); var name = firstEntity.Name; name = entities.All(entity => entity.Name == name) ? name : "-"; var enabled = firstEntity.Enabled; var sameEnabled = entities.All(tiny => tiny.Enabled == enabled); using (new EditorGUILayout.HorizontalScope()) { EditorGUI.BeginChangeCheck(); var mixed = EditorGUI.showMixedValue; EditorGUI.showMixedValue = !sameEnabled; enabled = EditorGUILayout.ToggleLeft(GUIContent.none, enabled, GUILayout.Width(EditorGUIUtility.singleLineHeight)); EditorGUI.showMixedValue = mixed; if (EditorGUI.EndChangeCheck()) { foreach (var entity in entities) { entity.Enabled = enabled; entity.View.gameObject.SetActive(enabled); } UTinyHierarchyWindow.InvalidateDataModel(); UTinyEditorUtility.RepaintAllWindows(); } EditorGUI.BeginChangeCheck(); name = EditorGUILayout.DelayedTextField(name, UTinyStyles.ComponentHeaderStyle); if (EditorGUI.EndChangeCheck()) { foreach (var entity in entities) { entity.Name = name; } UTinyHierarchyWindow.InvalidateDataModel(); UTinyEditorUtility.RepaintAllWindows(); } GUILayout.Space(EditorGUIUtility.singleLineHeight); } var layer = firstEntity.Layer; var sameLayer = entities.All(tiny => tiny.Layer == layer); using (new EditorGUILayout.HorizontalScope()) { GUILayout.Space(50); EditorGUILayout.LabelField("Layer", GUILayout.Width(50)); EditorGUI.BeginChangeCheck(); var mixed = EditorGUI.showMixedValue; EditorGUI.showMixedValue = !sameLayer; layer = EditorGUILayout.LayerField(layer); if (EditorGUI.EndChangeCheck()) { foreach (var entity in entities) { entity.Layer = layer; entity.View.gameObject.layer = layer; } UTinyHierarchyWindow.InvalidateDataModel(); UTinyEditorUtility.RepaintAllWindows(); } GUILayout.Space(EditorGUIUtility.singleLineHeight); EditorGUI.showMixedValue = mixed; } GUILayout.Space(5); UTinyGUILayout.Separator(UTinyColors.Inspector.Separator, UTinyGUIUtility.ComponentHeaderSeperatorHeight); }
private static void Update() { if (EditorApplication.isPlayingOrWillChangePlaymode) { return; } if (null == EditorContext) { // Flush asset changes from the persistence system // We don't care about any changes unless we have a project loaded UTinyPersistence.ClearChanges(); return; } // Poll for workspace changes if (null != EditorContext.Workspace && s_WorkspaceVersion != EditorContext.Workspace.Version) { UTinyEditorPrefs.SaveWorkspace(EditorContext.Workspace, EditorContext.PersistentObject.PersistenceId); s_WorkspaceVersion = EditorContext.Workspace.Version; } // Poll for file/asset changes var changes = UTinyPersistence.DetectChanges(Registry); if (changes.changesDetected) { var persistenceId = EditorContext.PersistentObject.PersistenceId; foreach (var change in changes.changedSources) { // The currently opened project or module has been changed on disc if (change.Equals(persistenceId)) { // Ask the user if they want to keep their changes or reload from disc if (EditorUtility.DisplayDialog($"{UTinyConstants.ApplicationName} assets changed", $"{UTinyConstants.ApplicationName} assets have changed on disk, would you like to reload the current project?", "Yes", "No")) { LoadPersistenceId(persistenceId); } else { UTinyModificationProcessor.MarkChanged(); } } else { // This is some other file. We assume they are in a readonly state and we silently reload the object UTinyPersistence.ReloadObject(EditorContext.Registry, change); } } foreach (var deletion in changes.deletedSources) { // The currently opened project or module has been deleted on disc if (deletion.Equals(persistenceId)) { // Ask the user if they want to keep their changes or close the project if (EditorUtility.DisplayDialog($"{UTinyConstants.ApplicationName} assets changed", "The current project has been deleted, would you like to close the current project?", "Yes", "No")) { // Force close the project Close(); } else { UTinyModificationProcessor.MarkChanged(); EditorContext.PersistentObject.PersistenceId = string.Empty; } } else { // This is some other file. We assume they are in a readonly state and we silently reload the object EditorContext.Registry.UnregisterAllBySource(deletion); } } foreach (var moved in changes.movedSources) { if (!moved.Equals(persistenceId)) { continue; } var path = AssetDatabase.GUIDToAssetPath(moved); var asset = AssetDatabase.LoadAssetAtPath(path, typeof(UnityEngine.Object)); if (null != asset) { EditorContext.PersistentObject.Name = asset.name; } } OnChangesDetected?.Invoke(); } // Poll for module or project changes if (EditorContext.ContextType == EditorContextType.Project && (s_ProjectVersion != EditorContext.Project.Version || s_ModuleVersion != EditorContext.Module.Version)) { EditorContext.Project.RefreshConfiguration(); s_ProjectVersion = EditorContext.Project.Version; s_ModuleVersion = EditorContext.Module.Version; } if (s_Save) { s_Save = false; // NOTE: It is possible that this call will fail Save(); } if (s_Repaint) { UTinyEditorUtility.RepaintAllWindows(); s_Repaint = false; } }
public static UTinyBuildResults Build(UTinyBuildOptions options) { if (options?.Project == null || options.Destination == null) { throw new ArgumentException($"{UTinyConstants.ApplicationName}: invalid build options provided", nameof(options)); } var buildStart = DateTime.Now; var results = new UTinyBuildResults(); IUTinyBuilder builder = null; switch (options.Platform) { case UTinyPlatform.HTML5: builder = new UTinyHTML5Builder(); break; default: throw new ArgumentException($"{UTinyConstants.ApplicationName}: build platform not supported", nameof(options)); } try { EditorUtility.DisplayProgressBar(ProgressBarTitle, "Build started for " + options.Platform.ToString(), 0.0f); var destFolder = options.Destination; destFolder.Create(); // BUILD = <DEST>/PLATFORM/CONFIG var buildFolder = new DirectoryInfo(GetBuildDirectory(options.Project, options.Platform, options.Configuration)); results.OutputFolder = buildFolder; UTinyBuildUtilities.PurgeDirectory(buildFolder); buildFolder.Create(); options.Destination = results.BinaryFolder = buildFolder; var idlFile = new FileInfo(Path.Combine(buildFolder.FullName, "generated.cs")); UTinyIDLGenerator.GenerateIDL(options.Project, idlFile); var distFolder = GetRuntimeDistFolder(); var bindGem = new FileInfo(Path.Combine( distFolder.FullName, "bindgem/BindGem/bin/Release/BindGem.exe")); var exeName = "\"" + bindGem.FullName + "\""; // always call bindgem with mono for consistency exeName = "mono " + exeName; // reference the core runtime file var bindReferences = $"-r \"{RuntimeDefsAssemblyPath}\""; UTinyBuildUtilities.RunInShell( $"{exeName} -j {bindReferences} -o bind-generated {idlFile.Name}", new ShellProcessArgs() { WorkingDirectory = buildFolder, ExtraPaths = TinyPreferences.MonoDirectory.AsEnumerable() }); // @TODO Perform a full refresh before building builder.Build(options, results); results.BuildReport.Update(); Debug.Log($"{UTinyConstants.ApplicationName} project generated at: {results.BinaryFolder.FullName}"); TinyEditorAnalytics.SendBuildEvent(options.Project, results, DateTime.Now - buildStart); return(results); } catch (Exception ex) { TinyEditorAnalytics.SendException("BuildPipeline.Build", ex); throw; } finally { EditorUtility.ClearProgressBar(); UTinyEditorUtility.RepaintAllWindows(); } }
private static void RepaintAll() { UTinyEditorUtility.RepaintAllWindows(); }