private static void DestroySceneCameras() { List <HvrRender> hvrRenders = new List <HvrRender>(); HvrScene.GetObjects(hvrRenders); foreach (HvrRender render in hvrRenders) { if (EditorHelper.IsSceneViewCamera(render.GetComponent <Camera>()) || EditorHelper.IsPreviewCamera(render.GetComponent <Camera>())) { UnityEngine.Object.DestroyImmediate(render); } } }
private static void Update() { if (!EditorApplication.isPlaying || EditorApplication.isPaused) { // prevent memory keeps going up when in Unity Editor and the HvrActor is inactive HvrPlayerInterface.Update(); } List <HvrActor> actors = new List <HvrActor>(); HvrScene.GetObjects(actors); foreach (HvrActor actor in actors) { actor.EditorUpdate(); } }
private static void Update() { // In the case that the graphics api changes while the editor is running // destroy any hvrrender components that are attached to Editor cameras if (previousGraphicsDeviceType != SystemInfo.graphicsDeviceType) { previousGraphicsDeviceType = SystemInfo.graphicsDeviceType; DestroySceneCameras(); } if (!EditorApplication.isPlaying) { Camera[] sceneCameras = InternalEditorUtility.GetSceneViewCameras(); foreach (Camera camera in sceneCameras) { if (camera.gameObject.GetComponent(Uniforms.componentNames.hvrRender)) { HvrRender render = (HvrRender)camera.gameObject.GetComponent(Uniforms.componentNames.hvrRender); if (!HvrScene.Contains(render)) { HvrScene.Add(render); } } } List <HvrActor> actors = new List <HvrActor>(); HvrScene.GetObjects(actors); // If the asset's CurrentTime is different to the ActualTime, then a frame // has probably begun decoding or has finished decoding. // In order for this the data to be pushed to the renderer, we must force a render to occur bool assetTimeChanged = false; // Because of the async nature of the decoding and rendering we must wait until the voxel count // has changed before rerendering the views int currentVoxelCount = 0; foreach (HvrActor actor in actors) { if (actor != null && actor.assetInterface != null) { if (actor.assetInterface.GetCurrentTime() != actor.assetInterface.GetActualTime()) { assetTimeChanged = true; } currentVoxelCount += actor.assetInterface.GetVoxelCount(); } } if (assetTimeChanged || sLastVoxelCount != currentVoxelCount) { sLastVoxelCount = currentVoxelCount; // Ensures that the HvrActor's mesh is updated List <HvrActor> hvrActors = new List <HvrActor>(); HvrScene.GetObjects(hvrActors); foreach (HvrActor actor in hvrActors) { actor.EditorUpdate(); } // Force HvrScene to allow the PrepareRender stage to occur HvrScene.lastPreparedFrame = -1; // Force all HvrRender cameras to render // Do this last after updating the scene List <HvrRender> hvrRenders = new List <HvrRender>(); HvrScene.GetObjects(hvrRenders); foreach (HvrRender render in hvrRenders) { render.GetComponent <Camera>().Render(); } } } }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { List <string> changedAssets = new List <string>(); changedAssets.AddRange(importedAssets); changedAssets.AddRange(deletedAssets); changedAssets.AddRange(movedAssets); changedAssets.AddRange(movedFromAssetPaths); string projectAssetPath = Application.dataPath; projectAssetPath = projectAssetPath.Substring(0, projectAssetPath.Length - "Assets".Length); List <HvrActor> hvrActors = new List <HvrActor>(); HvrScene.GetObjects(hvrActors); foreach (HvrActor actor in hvrActors) { if (actor.dataMode == HvrActor.eDataMode.reference && !string.IsNullOrEmpty(actor.data)) { // Get the path to the data that the hvrActor wants to load string dataPath = string.Empty; dataPath = HvrHelper.GetDataPathFromGUID(actor.data); bool forceUpdate = false; if (!string.IsNullOrEmpty(dataPath)) { FileInfo fileInfo_hvrActorData = new FileInfo(dataPath); FileAttributes fileAttr_hvrActorData = File.GetAttributes(dataPath); for (int j = 0; j < changedAssets.Count; j++) { FileInfo changedAssetFileInfo = new FileInfo(projectAssetPath + changedAssets[j]); if ((fileAttr_hvrActorData & FileAttributes.Directory) == FileAttributes.Directory) { if (fileInfo_hvrActorData.FullName == changedAssetFileInfo.Directory.FullName) { forceUpdate = true; } } else { if (fileInfo_hvrActorData.FullName == changedAssetFileInfo.FullName) { forceUpdate = true; } } } } else { // Assume that the data has been deleted from the project if the // data path is empty, but the hvrActor has an hvrAsset assigned if (actor.assetInterface != null) { forceUpdate = true; } } if (forceUpdate) { if (string.IsNullOrEmpty(dataPath)) { actor.CreateAsset(string.Empty, actor.dataMode); } else { actor.CreateAsset(actor.data, HvrActor.eDataMode.reference); } } } } }