public IEnumerator BlockServerRootTraversal() { EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects); MeshSyncServer mss = MeshSyncMenu.CreateMeshSyncServer(true); Assert.IsTrue(mss.IsServerStarted()); yield return(null); Assert.IsFalse(CanAccessFileOutsideServerRoot()); }
internal static MeshSyncServer CreateMeshSyncServerMenu(MenuCommand menuCommand) { MeshSyncServer mss = CreateMeshSyncServer(true); if (mss != null) { Undo.RegisterCreatedObjectUndo(mss.gameObject, "MeshSyncServer"); } Selection.activeTransform = mss.transform; return(mss); }
void HandleRedirect(MeshSyncServer server) { var newRedirect = EditorGUILayout.Toggle("Redirect Blender to Unity Console:", redirectBlenderToUnityConsole); if (newRedirect != redirectBlenderToUnityConsole) { redirectBlenderToUnityConsole = newRedirect; if (m_blenderProcess != null) { OpenDCCTool(server.DCCAsset); } } }
public void DrawServerSettings(MeshSyncServer t, SerializedObject so) { var styleFold = EditorStyles.foldout; styleFold.fontStyle = FontStyle.Bold; t.foldServerSettings = EditorGUILayout.Foldout(t.foldServerSettings, "Server", true, styleFold); if (t.foldServerSettings) { EditorGUILayout.PropertyField(so.FindProperty("m_serverPort")); EditorGUILayout.PropertyField(so.FindProperty("m_assetDir")); EditorGUILayout.PropertyField(so.FindProperty("m_rootObject")); EditorGUILayout.Space(); } }
//---------------------------------------------------------------------------------------------------------------------- public void DrawServerSettings(MeshSyncServer t) { var styleFold = EditorStyles.foldout; styleFold.fontStyle = FontStyle.Bold; bool isServerStarted = m_meshSyncServer.IsServerStarted(); string serverStatus = isServerStarted ? "Server (Status: Started)" : "Server (Status: Stopped)"; t.foldServerSettings = EditorGUILayout.Foldout(t.foldServerSettings, serverStatus, true, styleFold); if (t.foldServerSettings) { bool autoStart = EditorGUILayout.Toggle("Auto Start", m_meshSyncServer.IsAutoStart()); m_meshSyncServer.SetAutoStartServer(autoStart); //Draw GUI that are disabled when autoStart is true EditorGUI.BeginDisabledGroup(autoStart); int serverPort = EditorGUILayout.IntField("Server Port:", (int)m_meshSyncServer.GetServerPort()); m_meshSyncServer.SetServerPort((ushort)serverPort); GUILayout.BeginHorizontal(); if (isServerStarted) { if (GUILayout.Button("Stop", GUILayout.Width(110.0f))) { m_meshSyncServer.StopServer(); } } else { if (GUILayout.Button("Start", GUILayout.Width(110.0f))) { m_meshSyncServer.StartServer(); } } GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); string selectedFolder = EditorGUIDrawerUtility.DrawFolderSelectorGUI("Asset Dir", "Asset Dir", t.GetAssetsFolder(), null); t.SetAssetsFolder(AssetUtility.NormalizeAssetPath(selectedFolder)); Transform rootObject = (Transform)EditorGUILayout.ObjectField("Root Object", t.GetRootObject(), typeof(Transform), allowSceneObjects: true); t.SetRootObject(rootObject); EditorGUILayout.Space(); } }
public IEnumerator CreateManualServer() { EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects); MeshSyncServer mss = MeshSyncMenu.CreateMeshSyncServer(false); Assert.IsFalse(mss.IsServerStarted()); yield return(null); Assert.IsFalse(mss.IsServerStarted()); //Still not started mss.StartServer(); yield return(null); Assert.IsTrue(mss.IsServerStarted()); }
void HandleRunMmode(MeshSyncServer server) { GUILayout.BeginHorizontal(); var newRunMode = (RunMode)EditorGUILayout.EnumPopup("Run mode:", runMode); if (newRunMode != runMode) { runMode = newRunMode; if (m_blenderProcess != null) { OpenDCCTool(server.DCCAsset); } } GUILayout.EndHorizontal(); }
static void DrawPrefabListElement(MeshSyncServer t) { if (t.prefabDict.Count > 0) { EditorGUILayout.LabelField("Instance prefabs:"); EditorGUI.indentLevel++; foreach (var prefabHolder in t.prefabDict.Values) { EditorGUILayout.ObjectField(prefabHolder.name, prefabHolder.prefab, typeof(GameObject), true); } EditorGUI.indentLevel--; if (GUILayout.Button("Clear prefabs")) { t.ClearInstancePrefabs(); } } }
public void DrawServerSettings(MeshSyncServer t, SerializedObject so) { var styleFold = EditorStyles.foldout; styleFold.fontStyle = FontStyle.Bold; bool isServerStarted = m_serverAsset.IsServerStarted(); string serverStatus = isServerStarted ? "Server (Status: Started)" : "Server (Status: Stopped)"; t.foldServerSettings = EditorGUILayout.Foldout(t.foldServerSettings, serverStatus, true, styleFold); if (t.foldServerSettings) { bool autoStart = EditorGUILayout.Toggle("Auto Start", m_serverAsset.IsAutoStart()); m_serverAsset.SetAutoStartServer(autoStart); //Draw GUI that are disabled when autoStart is true EditorGUI.BeginDisabledGroup(autoStart); int serverPort = EditorGUILayout.IntField("Server Port:", (int)m_serverAsset.GetServerPort()); m_serverAsset.SetServerPort((ushort)serverPort); GUILayout.BeginHorizontal(); if (isServerStarted) { if (GUILayout.Button("Stop", GUILayout.Width(110.0f))) { m_serverAsset.StopServer(); } } else { if (GUILayout.Button("Start", GUILayout.Width(110.0f))) { m_serverAsset.StartServer(); } } GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); EditorGUILayout.PropertyField(so.FindProperty("m_assetDir")); EditorGUILayout.PropertyField(so.FindProperty("m_rootObject")); EditorGUILayout.Space(); } }
public IEnumerator CreateAutoServer() { EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects); //Delete Server Root Path string serverRootPath = Path.Combine(Application.streamingAssetsPath, DeployStreamingAssets.SERVER_ROOT_DIR_NAME); if (Directory.Exists(serverRootPath)) { Directory.Delete(serverRootPath, true); } Assert.IsFalse(Directory.Exists(serverRootPath)); MeshSyncServer mss = MeshSyncMenu.CreateMeshSyncServer(true); Assert.IsTrue(mss.IsServerStarted()); yield return(null); //Make sure the server files have been deployed Assert.IsTrue(Directory.Exists(serverRootPath)); }
public static void OpenDCCAsset(MeshSyncServer server) { var previousRunMode = server.m_DCCInterop != null ? server.m_DCCInterop.runMode : RunMode.GUI; var asset = server.DCCAsset; server.m_DCCInterop?.Dispose(); server.m_DCCInterop = GetLauncherForAsset(asset); if (server.m_DCCInterop != null) { server.m_DCCInterop.runMode = previousRunMode; server.m_DCCInterop.OpenDCCTool(asset); } else { var assetPath = AssetDatabase.GetAssetPath(asset); var extension = Path.GetExtension(assetPath); EditorUtility.DisplayDialog("Error", $"No DCC handler for {extension} files is implemented.", "OK"); } }
public static void DrawMaterialList(MeshSyncServer t) { foreach (var md in t.materialData) { var rect = EditorGUILayout.BeginHorizontal(); EditorGUI.DrawRect(new Rect(rect.x, rect.y, 16, 16), md.color); EditorGUILayout.LabelField("", GUILayout.Width(16)); EditorGUILayout.LabelField(md.name, GUILayout.Width(80)); { var tmp = EditorGUILayout.ObjectField(md.material, typeof(Material), true) as Material; if (tmp != md.material) { Undo.RecordObject(t, "MeshSyncServer"); md.material = tmp; t.ReassignMaterials(); t.ForceRepaint(); } } EditorGUILayout.EndHorizontal(); } }
public static void DrawMaterialList(MeshSyncServer t) { // calculate label width float labelWidth = 60; // minimum { var style = GUI.skin.box; foreach (var md in t.materialData) { var size = style.CalcSize(new GUIContent(md.name)); labelWidth = Mathf.Max(labelWidth, size.x); } // 100: margin for color and material field labelWidth = Mathf.Min(labelWidth, EditorGUIUtility.currentViewWidth - 100); } foreach (var md in t.materialData) { var rect = EditorGUILayout.BeginHorizontal(); EditorGUI.DrawRect(new Rect(rect.x, rect.y, 16, 16), md.color); EditorGUILayout.LabelField("", GUILayout.Width(16)); EditorGUILayout.LabelField(md.name, GUILayout.Width(labelWidth)); { var tmp = EditorGUILayout.ObjectField(md.material, typeof(Material), true) as Material; if (tmp != md.material) { Undo.RecordObject(t, "MeshSyncServer"); md.material = tmp; t.ReassignMaterials(); t.ForceRepaint(); } } EditorGUILayout.EndHorizontal(); } }
static void DrawDCCToolInfo(MeshSyncServer server) { if (server != null) { GUILayout.BeginHorizontal(); var newAsset = EditorGUILayout.ObjectField("DCC asset file:", server.DCCAsset, typeof(UnityEngine.Object), true); if (newAsset != server.DCCAsset) { server.DCCAsset = newAsset; server.m_DCCInterop = MeshSyncServerInspectorUtils.GetLauncherForAsset(server.DCCAsset); } if (server.DCCAsset != null) { if (GUILayout.Button("Live Edit")) { GUILayout.EndHorizontal(); MeshSyncServerInspectorUtils.OpenDCCAsset(server); return; } } GUILayout.EndHorizontal(); if (server.m_DCCInterop == null) { server.m_DCCInterop = MeshSyncServerInspectorUtils.GetLauncherForAsset(server.DCCAsset); } server.m_DCCInterop?.DrawDCCMenu(server); } }
private void DrawInstanceSettings(MeshSyncServer t) { var style = EditorStyles.foldout; style.fontStyle = FontStyle.Bold; t.foldInstanceSettings = EditorGUILayout.Foldout(t.foldInstanceSettings, "Instances", true, style); if (t.foldInstanceSettings) { var newInstanceHandling = (BaseMeshSync.InstanceHandlingType)EditorGUILayout.EnumPopup("Instance handling", t.InstanceHandling); if (t.InstanceHandling != newInstanceHandling && EditorUtility.DisplayDialog("Warning", "Changing the instance handling mode will delete any prefabs and previously synced objects for this server. Are you sure you want to do this?", "Yes", "No", DialogOptOutDecisionType.ForThisSession, OPT_OUT_INSTANCE_HANDLING)) { t.InstanceHandling = newInstanceHandling; } DrawPrefabListElement(t); } EditorGUILayout.LabelField($"Instance count: {t.InstanceCount}"); }
public static void DrawTextureList(MeshSyncServer t) { }