public static bool CanEditScene(SubScene scene) { #if UNITY_EDITOR // Disallow editing when in prefab edit mode if (PrefabStageUtility.GetPrefabStage(scene.gameObject) != null) { return(false); } if (!scene.isActiveAndEnabled) { return(false); } #endif return(!scene.IsLoaded); }
void CleanupScene(SubScene scene) { // Debug.Log("CleanupScene: " + scene.SceneName); scene.CleanupLiveLink(); var streamingSystem = World.GetExistingManager <SubSceneStreamingSystem>(); foreach (var sceneEntity in scene._SceneEntities) { streamingSystem.UnloadSceneImmediate(sceneEntity); EntityManager.DestroyEntity(sceneEntity); } scene._SceneEntities = new List <Entity>(); scene.UpdateSceneEntities(); }
/// <summary> /// Add Scene to opened scenes /// </summary> static public void AddScene(SubScene subScene, bool active = true) { if (EditorApplication.isPlaying) { SceneManager.LoadSceneAsync(subScene.assetPath, UnityEngine.SceneManagement.LoadSceneMode.Additive); Debug.Log("Add " + SceneManager.GetSceneByPath(subScene.assetPath).name); } else { EditorSceneManager.OpenScene(subScene.assetPath, OpenSceneMode.Additive); if (active) { EditorSceneManager.CloseScene(EditorSceneManager.GetSceneByPath(subScene.assetPath), false); } Debug.Log("Add " + EditorSceneManager.GetSceneByPath(subScene.assetPath).name); } }
IEnumerator Start() { Application.targetFrameRate = 60; // 60欲しい! // アスペクト比いじられてるようならカメラ追加してクリアする if (ScreenSettings.Instance.HasMargin) { var go = new GameObject("DebugClearCamera"); go.transform.SetParent(gameObject.transform, false); var camera = go.AddComponent <Camera>(); camera.depth = -float.MaxValue; camera.cullingMask = 0; // 何も描画しない camera.clearFlags = CameraClearFlags.SolidColor; camera.backgroundColor = Color.black; } yield return(world.CoLoad()); world.ManualStart(); #if DEBUG_ENABLED debugService = new DebugService( world, 8080, mainCamera, debugTextShader, debugTexturedShader, debugFont, debugTapMark, debugServerIndexHtml.text); debugRenderer = new DebugPrimitiveRenderer3D( debugTextShader, debugTexturedShader, debugFont, mainCamera, debugMeshRenderer, debugMeshFilter); // 上書き検出 debugService.OnOverrideFileChanged += world.OnOverrideFileChanged; #endif gameState = new GameState(world); subScene = Instantiate(bootSubScenePrefab, gameObject.transform, false); // カメラ初期設定 world.SetDefaultCamera(convergeNow: true); }
/// <summary> /// For a given Scene Asset object reference, extract its settings data. /// </summary> static public SubScene GetScene(Object sceneObject) { SubScene entry = new SubScene() { buildIndex = -1, assetGUID = new GUID(string.Empty) }; if (sceneObject as SceneAsset == null) { return(entry); } entry.assetPath = AssetDatabase.GetAssetPath(sceneObject); entry.assetGUID = new GUID(AssetDatabase.AssetPathToGUID(entry.assetPath)); return(entry); }
IEnumerator CoLoadSubScene() { var fileName = "SubScenes/" + loadSubSceneName + "SubScene"; var req = Resources.LoadAsync <SubScene>(fileName); yield return(req); Debug.Assert(req.asset != null, "SubScene Load Failed: " + fileName); if (req.asset != null) { var prefab = req.asset as SubScene; var next = Instantiate(prefab, gameObject.transform, false); yield return(next.CoLoad(gameState)); nextSubScene = next; // ロード完了 loadSubSceneCoroutine = null; } }
static bool IsSubsceneImported(SubScene subScene) { foreach (var world in World.All) { var sceneSystem = world.GetExistingSystem <SceneSystem>(); if (sceneSystem is null) { continue; } var hash = EntityScenesPaths.GetSubSceneArtifactHash(subScene.SceneGUID, sceneSystem.BuildConfigurationGUID, ImportMode.NoImport); if (!hash.IsValid) { return(false); } } return(true); }
static void DrawSubsceneBounds(SubScene scene, GizmoType gizmoType) { var isEditing = scene.IsLoaded; var minMax = scene.SceneBoundingVolume; if (!minMax.Equals(MinMaxAABB.Empty)) { AABB aabb = minMax; if (isEditing) { Gizmos.color = Color.green; } else { Gizmos.color = Color.gray; } Gizmos.DrawWireCube(aabb.Center, aabb.Size); } }
protected override void OnUpdate() { var subSceneEntities = Entities.WithAll <SubScene>(); var subSceneControlEntities = Entities.WithAll <SubSceneControlComponent>(); subSceneControlEntities.WithAny <SubSceneLoadComponent, SubSceneUnLoadComponent>() .ForEach((Entity subSceneControlEntity) => { if (EntityManager.HasComponent <SubSceneLoadComponent>(subSceneControlEntity)) { var subSceneLoad = EntityManager.GetComponentData <SubSceneLoadComponent>(subSceneControlEntity); SubScene loadSubScene = GetSubSceneByType(subSceneLoad.type); subSceneEntities.ForEach((Entity entity, SubScene subScene) => { if (loadSubScene == subScene) { EntityManager.AddComponent <RequestSceneLoaded>(entity); } }); EntityManager.RemoveComponent <SubSceneLoadComponent>(subSceneControlEntity); } else if (EntityManager.HasComponent <SubSceneUnLoadComponent>(subSceneControlEntity)) { var subSceneUnload = EntityManager.GetComponentData <SubSceneUnLoadComponent>(subSceneControlEntity); SubScene unloadSubScene = GetSubSceneByType(subSceneUnload.type); subSceneEntities.ForEach((Entity entity, SubScene subScene) => { if (unloadSubScene == subScene) { EntityManager.RemoveComponent <RequestSceneLoaded>(entity); } }); EntityManager.RemoveComponent <SubSceneUnLoadComponent>(subSceneControlEntity); } }); }
// Visualize SubScene using bounding volume when it is selected. public static void DrawSubsceneBounds(SubScene scene) { var isEditing = scene.IsLoaded; var world = World.DefaultGameObjectInjectionWorld; if (world == null) return; var entities = world.EntityManager; foreach (var section in GetActiveWorldSections(World.DefaultGameObjectInjectionWorld, scene.SceneGUID)) { if (!entities.HasComponent<SceneBoundingVolume>(section)) continue; if (isEditing) Gizmos.color = Color.green; else Gizmos.color = Color.gray; AABB aabb = entities.GetComponentData<SceneBoundingVolume>(section).Value; Gizmos.DrawWireCube(aabb.Center, aabb.Size); } }
private void Start() { //reset current level mCurrentLevel = 0; //get scene mScene = GetComponentInParent <SubScene>(); //get current level from data Level currentLevel = mLevels[mCurrentLevel]; //spawn a background for the game mCurrentBackground = ObjectPoolManager.Instance.Spawn(currentLevel.GetBackground().name, mScene.transform.position + new Vector3(0, 0, 10)); //set it to be a child of scene mCurrentBackground.transform.parent = mScene.transform; //spawn a foreground for the game mCurrentForeground = ObjectPoolManager.Instance.Spawn(currentLevel.GetForeground().name, mScene.transform.position + new Vector3(0, -15.68f, 5), mScene.transform); //set it to be a child of scene mCurrentForeground.transform.parent = mScene.transform; mScene.GetServiceManager().CallActionWhenServiceIsLive(ApplicationConstants.SERVICE_LOCAL_LEVEL_BUILDER, () => { SetConfigurationInBuilder(currentLevel); }); //mScene.GetEventManager().ListenToEvent(ApplicationConstants.BUILDER_IS_INITIALIZED, (string arg1, ActionParams arg2) => { // SetConfigurationInBuilder(currentLevel); //}); //mScene.GetEventManager(). mScene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_CHANGE_TO_NEXT_WORLD, ChangeToNextLevel); }
public virtual void Init() { m_Scene = gameObject.GetComponentInParent(typeof(SubScene)) as SubScene; if (m_Scene == null) { throw new System.Exception("Object must be attached to a specific scene!"); } float speed = m_Scene.GetWorldSpeed(); SetWorldSpeed(speed); worldIndex = m_Scene.GetIndex(); LocalPowerUpManager localPowerUpManager = m_Scene.GetLocalPowerUpManager(); PowerUpManager.PowerUpEffect effect = m_Scene.GetLocalPowerUpManager().GetActivatedPowerUp(); ActionParams actionParams = localPowerUpManager.GetActionParams(); if (effect.Equals(PowerUpManager.PowerUpEffect.Speed)) { OnCollectedSpeed("", actionParams); } else if (effect.Equals(PowerUpManager.PowerUpEffect.Freeze)) { //Nothing is supposed to be created during freeze but just in case OnCollectedFreeze("", actionParams); } //mPowerUpHandler = PowerUpHandlerBase.powerUpDefaultHandler; //Listen to events m_Scene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_DIE_BY_HIT, OnGameOver); m_Scene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_COLLECTED_SPEED, OnCollectedSpeed); m_Scene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_COLLECTED_FREEZE, OnCollectedFreeze); }
public static void SetUpOnce() { s_Assets.SetUp(); var assetGuids = new List <GUID>(); try { { string path = s_Assets.GetNextPath(".asset"); AssetDatabase.CreateAsset(s_TempTexture = new Texture2D(64, 64), path); s_TempTextureGuid = new GUID(AssetDatabase.AssetPathToGUID(path)); assetGuids.Add(s_TempTextureGuid); } { string path = s_Assets.GetNextPath(".mat"); AssetDatabase.CreateAsset(s_TempMaterial = new Material(Shader.Find("Standard")), path); s_TempMaterialGuid = new GUID(AssetDatabase.AssetPathToGUID(path)); assetGuids.Add(s_TempMaterialGuid); s_TempMaterial.mainTexture = s_TempTexture; } var tempScenePath = s_Assets.GetNextPath(".unity"); s_TempScene = SubSceneTestsHelper.CreateScene(tempScenePath); s_SubSceneWithSections = SubSceneTestsHelper.CreateSubSceneInSceneFromObjects("SubScene", false, s_TempScene, () => { var go1 = new GameObject(); go1.AddComponent <SceneSectionComponent>().SectionIndex = 0; var go2 = new GameObject(); go2.AddComponent <SceneSectionComponent>().SectionIndex = 2; go2.AddComponent <TestComponentAuthoring>().Material = s_TempMaterial; return(new List <GameObject> { go1, go2 }); }); { var path = s_Assets.GetNextPath("LiveLinkBuildConfig.buildconfiguration"); BuildConfiguration.CreateAsset(path, config => { config.SetComponent(new SceneList { SceneInfos = new List <SceneList.SceneInfo> { new SceneList.SceneInfo { Scene = GlobalObjectId.GetGlobalObjectIdSlow(AssetDatabase.LoadAssetAtPath <SceneAsset>(tempScenePath)) } } }); }); s_LiveLinkBuildConfigGuid = new GUID(AssetDatabase.AssetPathToGUID(path)); } } catch { s_Assets.TearDown(); throw; } // This call ensures that the asset worker is already running and no test times out because we're still // waiting for the asset worker. Effectively this doesn't change the runtime that much since we will have // to wait for the import to finish in most of the tests anyway. GetLiveLinkArtifactHash(s_TempMaterialGuid, ImportMode.Synchronous); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); s_TempAssetGuids = assetGuids.ToArray(); }
void Start() => m_SubScene = GetComponent <SubScene>();
protected void Awake() { m_Scene = gameObject.GetComponentInParent <SubScene>(); }
/// <summary> /// Create a PlaceHolder object for a given Component. We can reference this component later. /// </summary> /// <param name="component"></param> /// <returns></returns> private static Object GetPlaceholder( SubScene subScene, Object originalObj, string hashId ) { string name = string.Format( "Cross-Scene Ref ({0})", hashId ); GameObject newGameObj = null; SceneData sceneData = SceneDataEx.GetSceneData(subScene); // First try searching by name (old behaviour) Transform existsChild = sceneData.transform.FindChild( name ); if ( existsChild ) newGameObj = existsChild.gameObject; if ( !newGameObj ) { newGameObj = EditorUtility.CreateGameObjectWithHideFlags( name, HideFlags.None ); newGameObj.transform.parent = sceneData.transform; newGameObj.SetActive(false); SubSceneEx.SetIsDirty( subScene, true ); } if ( !AdditiveScenePreferences.DebugShowBookkepingObjects ) newGameObj.hideFlags = HideFlags.HideInHierarchy; // Create a new, cloned component on the current GameObject. if ( originalObj is GameObject ) { return newGameObj; } else if ( originalObj is Transform ) { return newGameObj.transform; } else if ( originalObj is Component ) { Component component = (Component)originalObj; Unsupported.CopyComponentToPasteboard( component ); Component newComp = newGameObj.GetComponent( originalObj.GetType() ); if ( !newComp ) { newComp = newGameObj.AddComponent( component.GetType() ); SubSceneEx.SetIsDirty( subScene, true ); } Unsupported.PasteComponentValuesFromPasteboard( newComp ); return newComp; } throw new System.ArgumentException( "Placeholders can only be created for GameObjects or Components", "originalObj" ); }
void ApplyLiveLink(SubScene scene) { //Debug.Log("ApplyLiveLink: " + scene.SceneName); var streamingSystem = World.GetExistingManager <SubSceneStreamingSystem>(); var isFirstTime = scene.LiveLinkShadowWorld == null; if (scene.LiveLinkShadowWorld == null) { scene.LiveLinkShadowWorld = new World("LiveLink"); } using (var cleanConvertedEntityWorld = new World("Clean Entity Conversion World")) { // Unload scene //@TODO: We optimally shouldn't be unloading the scene here. We should simply prime the shadow world with the scene that we originally loaded into the player (Including Entity GUIDs) // This way we can continue the live link, compared to exactly what we loaded into the player. if (isFirstTime) { foreach (var s in scene._SceneEntities) { streamingSystem.UnloadSceneImmediate(s); EntityManager.DestroyEntity(s); } var sceneEntity = EntityManager.CreateEntity(); EntityManager.SetName(sceneEntity, "Scene (LiveLink): " + scene.SceneName); EntityManager.AddComponentObject(sceneEntity, scene); EntityManager.AddComponentData(sceneEntity, new SubSceneStreamingSystem.StreamingState { Status = SubSceneStreamingSystem.StreamingStatus.Loaded }); EntityManager.AddComponentData(sceneEntity, new SubSceneStreamingSystem.IgnoreTag( )); scene._SceneEntities = new List <Entity>(); scene._SceneEntities.Add(sceneEntity); } // Convert scene GameObjectConversionUtility.ConvertScene(scene.LoadedScene, scene.SceneGUID, cleanConvertedEntityWorld, GameObjectConversionUtility.ConversionFlags.AddEntityGUID | GameObjectConversionUtility.ConversionFlags.AssignName); var convertedEntityManager = cleanConvertedEntityWorld.GetOrCreateManager <EntityManager>(); var liveLinkSceneEntity = scene._SceneEntities[0]; /// We want to let the live linked scene be able to reference the already existing Scene Entity (Specifically SceneTag should point to the scene Entity after live link completes) // Add Scene tag to all entities using the convertedSceneEntity that will map to the already existing scene entity. convertedEntityManager.AddSharedComponentData(convertedEntityManager.UniversalGroup, new SceneTag { SceneEntity = liveLinkSceneEntity }); WorldDiffer.DiffAndApply(cleanConvertedEntityWorld, scene.LiveLinkShadowWorld, World); convertedEntityManager.Debug.CheckInternalConsistency(); scene.LiveLinkShadowWorld.GetOrCreateManager <EntityManager>().Debug.CheckInternalConsistency(); var group = EntityManager.CreateComponentGroup(typeof(SceneTag), ComponentType.Exclude <EditorRenderData>()); group.SetFilter(new SceneTag { SceneEntity = liveLinkSceneEntity }); EntityManager.AddSharedComponentData(group, new EditorRenderData() { SceneCullingMask = m_LiveLinkEditGameViewMask, PickableObject = scene.gameObject }); group.Dispose(); scene.LiveLinkDirtyID = GetSceneDirtyID(scene.LoadedScene); EditorUpdateUtility.EditModeQueuePlayerLoopUpdate(); } }
private void Awake() { m_Scene = gameObject.GetComponentInParent(typeof(SubScene)) as SubScene; m_Scene.SetPlayer(this); }
public override void OnInspectorGUI() { var subScene = target as SubScene; var prevSceneAsset = subScene.SceneAsset; var prevColor = subScene.HierarchyColor; base.OnInspectorGUI(); if (subScene.SceneAsset != prevSceneAsset || subScene.HierarchyColor != prevColor) { SceneHierarchyHooks.ReloadAllSceneHierarchies(); } var targetsArray = targets; var subscenes = new SubScene[targetsArray.Length]; targetsArray.CopyTo(subscenes, 0); EditorGUILayout.TextArea("", GUI.skin.horizontalSlider); GUILayout.BeginHorizontal(); if (!SubSceneInspectorUtility.IsEditingAll(subscenes)) { GUI.enabled = SubSceneInspectorUtility.CanEditScene(subscenes); if (GUILayout.Button("Edit")) { SubSceneInspectorUtility.EditScene(subscenes); } } else { GUI.enabled = true; if (GUILayout.Button("Close")) { SubSceneInspectorUtility.CloseAndAskSaveIfUserWantsTo(subscenes); } } GUI.enabled = SubSceneInspectorUtility.IsDirty(subscenes); if (GUILayout.Button("Save")) { SubSceneInspectorUtility.SaveScene(subscenes); } GUI.enabled = true; GUILayout.EndHorizontal(); var scenes = SubSceneInspectorUtility.GetLoadableScenes(subscenes); EditorGUILayout.TextArea("", GUI.skin.horizontalSlider); GUILayout.Space(10); if (World.DefaultGameObjectInjectionWorld != null) { var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager; foreach (var scene in scenes) { if (!entityManager.HasComponent <RequestSceneLoaded>(scene.Scene)) { if (GUILayout.Button($"Load '{scene.Name}'")) { entityManager.AddComponentData(scene.Scene, new RequestSceneLoaded()); EditorUpdateUtility.EditModeQueuePlayerLoopUpdate(); } } else { if (GUILayout.Button($"Unload '{scene.Name}'")) { entityManager.RemoveComponent <RequestSceneLoaded>(scene.Scene); EditorUpdateUtility.EditModeQueuePlayerLoopUpdate(); } } } } #if false // @TODO: TEMP for debugging if (GUILayout.Button("ClearWorld")) { World.DisposeAllWorlds(); DefaultWorldInitialization.Initialize("Default World", !Application.isPlaying); var scenes = FindObjectsOfType <SubScene>(); foreach (var scene in scenes) { var oldEnabled = scene.enabled; scene.enabled = false; scene.enabled = oldEnabled; } EditorUpdateUtility.EditModeQueuePlayerLoopUpdate(); } #endif var uncleanHierarchyObject = SubSceneInspectorUtility.GetUncleanHierarchyObject(subscenes); if (uncleanHierarchyObject != null) { EditorGUILayout.HelpBox($"Scene transform values are not applied to scenes child transforms. But {uncleanHierarchyObject.name} has an offset Transform.", MessageType.Warning, true); if (GUILayout.Button("Clear")) { foreach (var scene in subscenes) { scene.transform.localPosition = Vector3.zero; scene.transform.localRotation = Quaternion.identity; scene.transform.localScale = Vector3.one; } } } if (SubSceneInspectorUtility.HasChildren(subscenes)) { EditorGUILayout.HelpBox($"SubScenes can not have child game objects. Close the scene and delete the child game objects.", MessageType.Warning, true); } if (CheckConversionLog(subScene)) { GUILayout.Space(10); GUILayout.Label("Importing..."); Repaint(); } if (m_ConversionLog.Length != 0) { GUILayout.Space(10); GUILayout.Label("Conversion Log"); GUILayout.TextArea(m_ConversionLog); } }
public void RegisterSceneInGame(SubScene subScene, int index) { m_SubScenes[index] = subScene; }
// // Summary: // Override this method to make your own GUI for the property. public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { // Using BeginProperty / EndProperty on the parent property means that // prefab override logic works on the entire property. EditorGUI.BeginProperty(position, label, property); // Less area needed to display the prefix, more for the variables float oldLabelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = EditorGUIUtility.labelWidth * 0.65f; // Draw label position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); // Indent level reset int oldIndentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; // Find all of the data and grab it so we can start displaying (and calculating using it) var propFromSubScene = property.FindPropertyRelative("fromSubScene"); SubScene fromSubScene = propFromSubScene.objectReferenceValue as SubScene; var propFromObjectHash = property.FindPropertyRelative("fromObjectHash"); string fromObjectHash = propFromObjectHash.stringValue; var propFromPropertyPath = property.FindPropertyRelative("fromPropertyPath"); string fromPropertyPath = propFromPropertyPath.stringValue; var propToSubScene = property.FindPropertyRelative("toSubScene"); SubScene toSubScene = propToSubScene.objectReferenceValue as SubScene; var propToObjectHash = property.FindPropertyRelative("toObjectHash"); string toObjectHash = propToObjectHash.stringValue; // Resolve the actual objects Object fromObject = CrossSceneReferenceProcessor.ResolveObject(fromSubScene, fromObjectHash); Object toObject = CrossSceneReferenceProcessor.ResolveObject(toSubScene, toObjectHash); // If we're missing, maybe it's a deep reference? bool bWasDeepObjRef = false; if (!toObject) { toObject = CrossSceneReferenceProcessor.ResolveGlobalObject(toObjectHash); bWasDeepObjRef = toObject; } bool bIsValidPath = fromObject && new SerializedObject(fromObject).FindProperty(fromPropertyPath) != null; // Calculate rects float lineHeight = EditorGUIUtility.singleLineHeight; Rect fromSubSceneRect = new Rect(position.x, position.y + lineHeight * 0, position.width, lineHeight); Rect fromObjectRect = new Rect(position.x, position.y + lineHeight * 1, position.width, lineHeight); Rect fromPropertyRect = new Rect(position.x, position.y + lineHeight * 2, position.width, lineHeight); Rect toSubSceneRect = new Rect(position.x, position.y + lineHeight * 3, position.width, lineHeight); Rect toObjectRect = new Rect(position.x, position.y + lineHeight * 4, position.width, lineHeight); Color oldColor = GUI.color; // Draw the From Scene EditorGUI.PropertyField(fromSubSceneRect, propFromSubScene); // Draw from Object if (fromObject) { GUI.color = Color.green; EditorGUI.ObjectField(fromObjectRect, "From Object Ref", fromObject, typeof(Object), true); } else { GUI.color = Color.red; EditorGUI.PropertyField(fromObjectRect, propFromObjectHash); } // Draw From Path GUI.color = bIsValidPath ? Color.green : Color.red; EditorGUI.PropertyField(fromPropertyRect, propFromPropertyPath); // Draw the To Data GUIContent content = new GUIContent(propToSubScene.displayName); if (!toSubScene && toObject) { toSubScene = SubSceneEx.GetSubScene(toObject); if (toSubScene) { content = new GUIContent(propToSubScene.displayName, "This value was computed from a deep-search for the Object. It is probably a deep reference"); GUI.color = Color.yellow; } } // To SubScene EditorGUI.ObjectField(toSubSceneRect, content, toSubScene, typeof(SubScene), true); if (toObject) { GUI.color = Color.green; content = new GUIContent("To Object Ref"); if (bWasDeepObjRef) { GUI.color = Color.yellow; content.tooltip = "This value was computed from a deep-search for the Object. It is probably a deep reference"; } EditorGUI.ObjectField(toObjectRect, "To Object Ref", toObject, typeof(Object), true); } else { GUI.color = Color.red; EditorGUI.PropertyField(toObjectRect, propToObjectHash); GUI.color = oldColor; } GUI.color = oldColor; EditorGUIUtility.labelWidth = oldLabelWidth; EditorGUI.indentLevel = oldIndentLevel; EditorGUI.EndProperty(); }
static void DrawSubsceneBounds(SubScene scene, GizmoType gizmoType) { SubSceneInspectorUtility.DrawSubsceneBounds(scene); }
public static void WriteEntityScene(SubScene scene) { Entities.Hash128 guid = new GUID(AssetDatabase.AssetPathToGUID(scene.EditableScenePath)); WriteEntityScene(scene.LoadedScene, guid, 0); }
public static SceneAsset FindSceneAsset(SubScene subScene) { return(AssetDatabase.LoadAssetAtPath <SceneAsset> (GetSceneAssetPath(subScene))); }
public static void SetInstance(int index, SubScene scene) { scenes[index] = scene; }
public static string GetSceneAssetPath(SubScene subScene) { return(AssetDatabase.GUIDToAssetPath(subScene.SceneAssetGuid)); }
public override void OnInspectorGUI() { var subScene = target as SubScene; if (!subScene.IsInMainStage()) { // In Prefab Mode and when selecting a Prefab Asset in the Project Browser we only show the inspector of data of the // SubScene, and not the load/unload/edit/close buttons. base.OnInspectorGUI(); EditorGUILayout.HelpBox($"Only Sub Scenes in the Main Stage can be loaded and unloaded.", MessageType.Info, true); EditorGUILayout.Space(); return; } var prevColor = subScene.HierarchyColor; CachePreviousSceneAssetReferences(); base.OnInspectorGUI(); HandleChangedSceneAssetReferences(); if (subScene.HierarchyColor != prevColor) { SceneHierarchyHooks.ReloadAllSceneHierarchies(); } var targetsArray = targets; var subscenes = new SubScene[targetsArray.Length]; targetsArray.CopyTo(subscenes, 0); GUILayout.BeginHorizontal(); if (!SubSceneInspectorUtility.IsEditingAll(subscenes)) { GUI.enabled = SubSceneInspectorUtility.CanEditScene(subscenes); if (GUILayout.Button("Edit")) { SubSceneInspectorUtility.EditScene(subscenes); } } else { GUI.enabled = true; if (GUILayout.Button("Close")) { SubSceneInspectorUtility.CloseAndAskSaveIfUserWantsTo(subscenes); } } GUI.enabled = SubSceneInspectorUtility.IsDirty(subscenes); if (GUILayout.Button("Save")) { SubSceneInspectorUtility.SaveScene(subscenes); } GUI.enabled = true; GUILayout.EndHorizontal(); var scenes = SubSceneInspectorUtility.GetLoadableScenes(subscenes); GUILayout.Space(10); if (World.DefaultGameObjectInjectionWorld != null) { var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager; foreach (var scene in scenes) { if (!entityManager.HasComponent <RequestSceneLoaded>(scene.Scene)) { if (GUILayout.Button($"Load '{scene.Name}'")) { entityManager.AddComponentData(scene.Scene, new RequestSceneLoaded()); EditorUpdateUtility.EditModeQueuePlayerLoopUpdate(); } } else { if (GUILayout.Button($"Unload '{scene.Name}'")) { entityManager.RemoveComponent <RequestSceneLoaded>(scene.Scene); EditorUpdateUtility.EditModeQueuePlayerLoopUpdate(); } } } } #if false // @TODO: TEMP for debugging if (GUILayout.Button("ClearWorld")) { World.DisposeAllWorlds(); DefaultWorldInitialization.Initialize("Default World", !Application.isPlaying); var scenes = FindObjectsOfType <SubScene>(); foreach (var scene in scenes) { var oldEnabled = scene.enabled; scene.enabled = false; scene.enabled = oldEnabled; } EditorUpdateUtility.EditModeQueuePlayerLoopUpdate(); } #endif bool hasDuplicates = subScene.SceneAsset != null && (SubScene.AllSubScenes.Count(s => (s.SceneAsset == subScene.SceneAsset)) > 1); if (hasDuplicates) { EditorGUILayout.HelpBox($"The Scene Asset '{subScene.EditableScenePath}' is used mutiple times and this is not supported. Clear the reference.", MessageType.Warning, true); if (GUILayout.Button("Clear")) { subScene.SceneAsset = null; SceneHierarchyHooks.ReloadAllSceneHierarchies(); } EditorGUILayout.Space(); } var uncleanHierarchyObject = SubSceneInspectorUtility.GetUncleanHierarchyObject(subscenes); if (uncleanHierarchyObject != null) { EditorGUILayout.HelpBox($"Scene transform values are not applied to scenes child transforms. But {uncleanHierarchyObject.name} has an offset Transform.", MessageType.Warning, true); if (GUILayout.Button("Clear")) { foreach (var scene in subscenes) { scene.transform.localPosition = Vector3.zero; scene.transform.localRotation = Quaternion.identity; scene.transform.localScale = Vector3.one; } } EditorGUILayout.Space(); } if (SubSceneInspectorUtility.HasChildren(subscenes)) { EditorGUILayout.HelpBox($"SubScenes can not have child game objects. Close the scene and delete the child game objects.", MessageType.Warning, true); } GUILayout.Space(10); if (CheckConversionLog(subScene)) { GUILayout.Label("Importing..."); Repaint(); } else { if (!SubSceneInspectorUtility.IsEditingAll(subscenes)) { if (GUILayout.Button("Reimport")) { SubSceneInspectorUtility.ForceReimport(subscenes); } } } if (m_ConversionLog.Length != 0) { GUILayout.Space(10); GUILayout.Label("Conversion Log"); GUILayout.TextArea(m_ConversionLog); } }
private void LoadScene(SubScene subScene) { sceneSystem.LoadSceneAsync(subScene.SceneGUID); }
void StartGameOver() { _subScene = SubScene.GameOver; _titleText.text = "<color=#ff0000>GameOver</color>"; }
private void UnloadScene(SubScene subScene) { sceneSystem.UnloadScene(subScene.SceneGUID); }