private void OnGUI() { // styles var titleLabelStyle = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter, fontSize = 14 }; var subtitleLabelStyle = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter, fontSize = 10 }; GUILayout.Space(5); EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Space(10); EditorGUILayout.HelpBox("Copy world and media to a subfolder in Assets/External/Environments", MessageType.Info); string sourcePath = "Assets/External/Environments"; var options = new List <string>(); foreach (var dir in Directory.EnumerateDirectories(sourcePath)) { if (!Directory.Exists(dir + "/worlds")) { continue; } var files = Directory.EnumerateFiles(dir + "/worlds"); foreach (var world in files) { if (Path.GetExtension(world) != ".world") { continue; } options.Add(world); } } if (options.Count == 0) { return; } int selectedWorldBefore = options.IndexOf(WorldFileName); var foundWorlds = options.Select(p => p.Substring(sourcePath.Length + 1).Replace('/', '\u2215')).ToArray(); var selectedWorld = EditorGUILayout.Popup("World", selectedWorldBefore < 0 ? 0 : selectedWorldBefore, foundWorlds); WorldFileName = options[selectedWorld]; if (selectedWorld != selectedWorldBefore || sdfRoot == null) { var combined = Path.Combine(Application.dataPath, Path.GetDirectoryName(WorldFileName), "../models"); combined = Path.GetFullPath(combined); var modelPath = combined.Substring(Application.dataPath.Length + 1); sdfRoot = new SDFDocument(WorldFileName, modelPath); spawnLocationSelection = null; } EditorGUILayout.HelpBox($"version {sdfRoot.Version}", MessageType.Info); (GameObject, SDFModel)[] dynamicModels = null;
public SDFModel(SDFDocument document) { this.document = document; }
public SDFLink(SDFDocument document) { this.document = document; }
public SDFVisual(SDFDocument document) { this.document = document; }
private void OnGUI() { // styles var titleLabelStyle = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter, fontSize = 14, fontStyle = FontStyle.Bold }; GUILayout.Space(5); EditorGUILayout.LabelField("Import world file", titleLabelStyle, GUILayout.ExpandWidth(true)); GUILayout.Space(10); EditorGUILayout.HelpBox("Copy world and media to a subfolder in Assets/External/Environments. Worlds should sit in 'worlds' subfolder", MessageType.Info); string sourcePath = "Assets/External/Environments"; var options = new List <string>(); foreach (var dir in Directory.EnumerateDirectories(sourcePath)) { if (!Directory.Exists(dir + "/worlds")) { continue; } var files = Directory.EnumerateFiles(dir + "/worlds"); foreach (var world in files) { if (Path.GetExtension(world) != ".world") { continue; } options.Add(world); } } if (options.Count == 0) { return; } int selectedWorldBefore = options.IndexOf(WorldFileName); var foundWorlds = options.Select(p => p.Substring(sourcePath.Length + 1).Replace('/', '\u2215')).ToArray(); var selectedWorld = EditorGUILayout.Popup("World", selectedWorldBefore < 0 ? 0 : selectedWorldBefore, foundWorlds); WorldFileName = options[selectedWorld]; var worldDir = Path.GetDirectoryName(WorldFileName); if (selectedWorld != selectedWorldBefore || sdfRoot == null) { string modelPath; if (sdfRoot != null) { modelPath = sdfRoot.ModelPath; } else { var defaultLocations = new List <string> { "models", "../models", "assets/models", "../assets/models", "." }; modelPath = defaultLocations .Select(p => Path.Combine(worldDir, p)) .FirstOrDefault(p => Directory.Exists(p)); } // get rid of .. modelPath = Path.GetFullPath(Path.Combine(Application.dataPath, modelPath)).Substring(Application.dataPath.Length + 1); spawnLocationSelection.Clear(); sdfRoot = new SDFDocument(WorldFileName, modelPath); } EditorGUILayout.HelpBox($"version {sdfRoot.Version}", MessageType.Info); if (sdfRoot != null) { GUILayout.Label("SDF model include path"); GUILayout.BeginHorizontal(); GUILayout.Label(sdfRoot.ModelPath); if (GUILayout.Button("set")) { var path = EditorUtility.OpenFolderPanel("Add SDF include search path", sourcePath, ""); if (!string.IsNullOrWhiteSpace(path)) { sdfRoot.ModelPath = MakeRelativePath(Application.dataPath, path + "/"); } } GUILayout.EndHorizontal(); } (GameObject, SDFModel)[] dynamicModels = null;
public SDFLight(SDFDocument document) { this.document = document; }
public SDFCollision(SDFDocument document) { this.document = document; }