public override void OnImportAsset(AssetImportContext ctx) { stage = AnimData.LoadFromFile(ctx.assetPath); if (stage == null) { return; } MeshUtils.SimplifyStage(stage, Settings.SimplifyFactor); savedClips = new Dictionary <AudioDataPool.AudioPoolKey, AudioClip>(); totalVertices = 0; totalLines = 0; HasFades = false; m_Materials.Clear(); PreviewTexture = new Texture2D(1, 1); PreviewTexture.LoadImage(stage.previewFrames[0], false); PreviewTexture.Apply(); if (Settings.Shader == null || Settings.Shader == "AnimVR/Standard") { Debug.Log("Resetting shader"); Settings.Shader = "AnimVR/ImportedLine"; } baseMaterial = new Material(Shader.Find(Settings.Shader)); baseMaterial.SetFloat("_Unlit", Settings.UnlitByDefault ? 1 : 0); baseMaterial.SetFloat("_Gamma", PlayerSettings.colorSpace == ColorSpace.Gamma ? 1.0f : 2.2f); baseMaterial.name = Path.GetFileNameWithoutExtension(ctx.assetPath) + "_BaseMaterial"; needsAudioReimport = false; GenerateUnityObject(stage, ctx); //var externalObjects = GetExternalObjectMap(); ctx.AddObjectToAsset(Path.GetFileNameWithoutExtension(ctx.assetPath) + "_BaseMaterial", baseMaterial); m_Materials.Add(new SerializableIdentifier(baseMaterial)); InfoString = "FPS: " + stage.fps + ", " + stage.timelineLength + " frames \n" + totalVertices + " verts, " + totalLines + " lines"; savedClips = null; stage = null; }
public override void OnImportAsset(AssetImportContext ctx) { stage = AnimData.LoadFromFile(ctx.assetPath); if (stage == null) { return; } MeshUtils.SimplifyStage(stage); savedClips = new Dictionary <AudioDataPool.AudioPoolKey, AudioClip>(); totalVertices = 0; totalLines = 0; PreviewTexture = new Texture2D(1, 1); PreviewTexture.LoadImage(stage.previewFrames[0], false); PreviewTexture.Apply(); if (Settings.Shader == null) { Settings.Shader = "AnimVR/Standard"; } materialToUse = new Material(Shader.Find(Settings.Shader)); materialToUse.SetFloat("_Unlit", Settings.UnlitByDefault ? 1 : 0); materialToUse.name = "BaseMaterial"; ctx.AddSubAsset("BaseMaterial", materialToUse); needsAudioReimport = false; var stageObj = GenerateUnityObject(stage, ctx); ctx.SetMainAsset(stage.name, stageObj, PreviewTexture); InfoString = "FPS: " + stage.fps + ", " + stage.timelineLength + " frames \n" + totalVertices + " verts, " + totalLines + " lines"; savedClips = null; stage = null; }