public void ActorDataGuidObject(HvrActor target, SerializedObject serializedObject) { string pathToDataObject = AssetDatabase.GUIDToAssetPath(target.data); UnityEngine.Object dataObject = AssetDatabase.LoadAssetAtPath(pathToDataObject, typeof(UnityEngine.Object)); EditorGUI.BeginChangeCheck(); { dataObject = EditorGUILayout.ObjectField("Reference", dataObject, typeof(UnityEngine.Object), false); } string dataPath_relative = string.Empty; string dataGuid = string.Empty; if (dataObject != null) { dataPath_relative = AssetDatabase.GetAssetPath(dataObject); dataGuid = AssetDatabase.AssetPathToGUID(dataPath_relative); } if (EditorGUI.EndChangeCheck()) { foreach (HvrActor actor in serializedObject.targetObjects) { Undo.RecordObject(actor, "Changed DataGuid"); actor.CreateAsset(dataGuid, HvrActor.eDataMode.reference); } } }
private void OnEnable() { targetActor = (HvrActor)target; hvrEditorGUI = new HvrEditorGUI(); EditorApplication.update -= EditorUpdate; EditorApplication.update += EditorUpdate; }
public override void OnInspectorGUI() { //DrawDefaultInspector(); actor = (HvrActor)target; DrawCustomInspector(target); Repaint(); }
static void CreateObject_HVRActor(MenuCommand menuCommand) { HvrActor actor = CreateObject <HvrActor>(menuCommand, "HvrActor").GetComponent <HvrActor>(); // Create default material for the newly created HvrActor Shader shader = Shader.Find(Uniforms.ShaderNames.shader_HvrStandard); Material mat = new Material(shader); mat.name = "HvrStandard"; actor.material = mat; }
public void ReceiveShadows(UnityEngine.Object target, SerializedObject serializedObject) { if (target == null) { return; } bool receiveShadows = false; if (target.GetType() == typeof(HvrActor)) { HvrActor actor = target as HvrActor; receiveShadows = actor.receiveShadows; } else { return; } EditorGUI.BeginChangeCheck(); #if !UNITY_5_6_OR_NEWER receiveShadows = EditorGUILayout.Toggle(new GUIContent("Receive Shadows", "Receiving shadows from a point light source will have known artifacts."), receiveShadows); #else receiveShadows = EditorGUILayout.Toggle("Receive Shadows", receiveShadows); #endif if (EditorGUI.EndChangeCheck()) { foreach (UnityEngine.Object obj in serializedObject.targetObjects) { if (obj.GetType() == target.GetType()) { Undo.RecordObject(obj, "Changed receiveShadows"); if (obj.GetType() == typeof(HvrActor)) { HvrActor actor = (HvrActor)obj; actor.receiveShadows = receiveShadows; } } } ForceRedrawHvrWorldAndRepaintView(); } #if !UNITY_5_6_OR_NEWER if (receiveShadows) { EditorGUILayout.HelpBox("Receiving shadows from a point light source will have known artifacts.", MessageType.None); } #endif }
private Bounds OnGetFrameBounds() { HvrActor actor = target as HvrActor; if (actor.assetInterface != null) { Bounds b = actor.assetInterface.GetBounds(); b.center += actor.transform.position; return(b); } return(new Bounds(actor.transform.position, Vector3.one * 1f)); }
public void RenderMethod(UnityEngine.Object target, SerializedObject serializedObject) { if (target == null) { return; } string renderMethodType = string.Empty; if (target.GetType() == typeof(HvrActor)) { HvrActor actor = target as HvrActor; renderMethodType = actor.renderMethodType; } else { return; } int index = HVR.Interface.HvrPlayerInterface.RenderMethod_GetIndexForType(renderMethodType); EditorGUI.BeginChangeCheck(); index = EditorGUILayout.Popup("Render Method", index, HVR.Interface.HvrPlayerInterface.RenderMethod_GetSupportedTypes()); if (EditorGUI.EndChangeCheck()) { renderMethodType = HVR.Interface.HvrPlayerInterface.RenderMethod_GetSupportedTypes()[index]; foreach (UnityEngine.Object o in serializedObject.targetObjects) { if (o.GetType() == target.GetType()) { HvrActor actor = (HvrActor)o; if (actor.renderMethodInterface == null || actor.renderMethodInterface.type != renderMethodType) { Undo.RecordObject(o, "Changed RenderMethod"); if (o.GetType() == typeof(HvrActor)) { actor.CreateRenderMethod(renderMethodType); } } } } } }
public void ActorDataMode(HvrActor target, SerializedObject serializedObject) { HvrActor.eDataMode dataMode = (HvrActor.eDataMode)EditorGUILayout.Popup("Mode", (int)target.dataMode, actorModeStrings); if (dataMode != target.dataMode) { foreach (HvrActor actor in serializedObject.targetObjects) { if (actor.dataMode != dataMode) { Undo.RecordObject(actor, "Changed DataMode"); actor.CreateAsset(string.Empty, dataMode); } } } }
public void ActorDataPath(HvrActor target, SerializedObject serializedObject) { string dataPath = target.data; EditorGUI.BeginChangeCheck(); { dataPath = EditorGUILayout.TextField("Path", dataPath); } if (EditorGUI.EndChangeCheck()) { foreach (HvrActor actor in serializedObject.targetObjects) { Undo.RecordObject(actor, "Changed HvrActor DataPath"); actor.CreateAsset(dataPath, HvrActor.eDataMode.path); } } }
public bool UseLighting(UnityEngine.Object target, SerializedObject serializedObject) { bool useLighting = false; if (target.GetType() == typeof(HvrActor)) { HvrActor actor = target as HvrActor; useLighting = actor.useLighting; } else { return(useLighting); } EditorGUI.BeginChangeCheck(); useLighting = EditorGUILayout.Toggle(new GUIContent("Use Lighting", "Requires HvrLight component attached to a Light"), useLighting); if (EditorGUI.EndChangeCheck()) { foreach (UnityEngine.Object obj in serializedObject.targetObjects) { if (obj.GetType() == target.GetType()) { Undo.RecordObject(obj, "Changed useLighting"); if (obj.GetType() == typeof(HvrActor)) { HvrActor actor = (HvrActor)obj; actor.useLighting = useLighting; } } } ForceRedrawHvrWorldAndRepaintView(); } if (useLighting) { EditorGUILayout.HelpBox("Lighting requires a HvrLight component attached to a Light", MessageType.None); } return(useLighting); }
public void MaterialField(UnityEngine.Object target, SerializedObject serializedObject) { if (target == null) { return; } UnityEngine.Object materialObject; if (target.GetType() == typeof(HvrActor)) { HvrActor actor = target as HvrActor; materialObject = actor.material; } else { return; } EditorGUI.BeginChangeCheck(); materialObject = EditorGUILayout.ObjectField("Material", materialObject, typeof(Material), false); if (EditorGUI.EndChangeCheck()) { Material material = (Material)materialObject; foreach (UnityEngine.Object obj in serializedObject.targetObjects) { if (obj.GetType() == target.GetType()) { Undo.RecordObject(obj, "Changed material"); if (obj.GetType() == typeof(HvrActor)) { HvrActor actor = (HvrActor)obj; actor.material = material; } } } ForceRedrawHvrWorldAndRepaintView(); } }
public void CastShadows(UnityEngine.Object target, SerializedObject serializedObject) { if (target == null) { return; } bool castShadows = false; if (target.GetType() == typeof(HvrActor)) { HvrActor actor = target as HvrActor; castShadows = actor.castShadows; } else { return; } EditorGUI.BeginChangeCheck(); castShadows = EditorGUILayout.Toggle(new GUIContent("Cast Shadows", "Requires HvrLight component attached to light of interest."), castShadows); if (EditorGUI.EndChangeCheck()) { foreach (UnityEngine.Object obj in serializedObject.targetObjects) { if (obj.GetType() == target.GetType()) { Undo.RecordObject(obj, "Changed castShadows"); if (obj.GetType() == typeof(HvrActor)) { HvrActor actor = (HvrActor)obj; actor.castShadows = castShadows; } } } ForceRedrawHvrWorldAndRepaintView(); } }
public void OcclusionCullingEnabled(UnityEngine.Object target, SerializedObject serializedObject) { if (target == null) { return; } bool occlusionCullingEnabled = false; if (target.GetType() == typeof(HvrActor)) { HvrActor actor = target as HvrActor; occlusionCullingEnabled = actor.occlusionCullingEnabled; } else { return; } EditorGUI.BeginChangeCheck(); occlusionCullingEnabled = EditorGUILayout.Toggle("Use Occlusion Culling", occlusionCullingEnabled); if (EditorGUI.EndChangeCheck()) { foreach (UnityEngine.Object obj in serializedObject.targetObjects) { if (obj.GetType() == target.GetType()) { Undo.RecordObject(obj, "Changed occlusionCullingEnabled"); if (obj.GetType() == typeof(HvrActor)) { HvrActor actor = (HvrActor)obj; actor.occlusionCullingEnabled = occlusionCullingEnabled; } } } } }
public void HvrActorScreenspaceQuad(UnityEngine.Object target, SerializedObject serializedObject) { if (target == null) { return; } bool useScreenspaceQuad = false; if (target.GetType() == typeof(HvrActor)) { HvrActor actor = target as HvrActor; useScreenspaceQuad = actor.useScreenSpaceQuad; } else { return; } EditorGUI.BeginChangeCheck(); useScreenspaceQuad = EditorGUILayout.Toggle("Use ScreenSpace Quad", useScreenspaceQuad); if (EditorGUI.EndChangeCheck()) { foreach (UnityEngine.Object obj in serializedObject.targetObjects) { if (obj.GetType() == target.GetType()) { Undo.RecordObject(obj, "Changed useScreenSpaceQuad"); if (obj.GetType() == typeof(HvrActor)) { HvrActor actor = (HvrActor)obj; actor.useScreenSpaceQuad = useScreenspaceQuad; } } } } }
public void OcclusionCullingMultipler(UnityEngine.Object target, SerializedObject serializedObject) { if (target == null) { return; } float occlusionSizeOffset = 0; if (target.GetType() == typeof(HvrActor)) { HvrActor actor = target as HvrActor; occlusionSizeOffset = actor.occlusionCullingMultipler; } else { return; } EditorGUI.BeginChangeCheck(); occlusionSizeOffset = EditorGUILayout.Slider("Occlusion Radius Multiplier", occlusionSizeOffset, 0.01f, 4f); if (EditorGUI.EndChangeCheck()) { foreach (UnityEngine.Object obj in serializedObject.targetObjects) { if (obj.GetType() == target.GetType()) { Undo.RecordObject(obj, "Changed occlusionCullingMultipler"); if (obj.GetType() == typeof(HvrActor)) { HvrActor actor = (HvrActor)obj; actor.occlusionCullingMultipler = occlusionSizeOffset; } } } } }
public override void ProcessFrame(Playable playable, FrameData info, object playerData) { if (m_Clips == null) { return; } HvrActor actor = playerData as HvrActor; if (actor == null) { return; } // Allow for the previous asset that was assigned to the HvrActor to // be set back when this graph ends if (actor != null && !m_firstFrameHappened) { m_firstFrameHappened = true; m_trackBindingActor = actor; m_originalAssetInterface = actor.assetInterface; m_originalActorRenderMethodType = actor.renderMethodType; } Interface.AssetInterface current_asset = null; float greatestWeight = 0; int inputPort = 0; foreach (TimelineClip clip in m_Clips) { float inputWeight = playable.GetInputWeight(inputPort); ScriptPlayable <HvrActor_AssetBehavior> scriptPlayable = (ScriptPlayable <HvrActor_AssetBehavior>)playable.GetInput(inputPort); HvrActor_AssetBehavior hvrAssetBehavior = scriptPlayable.GetBehaviour(); if (hvrAssetBehavior != null) { double preloadTime = Math.Max(0.0, hvrAssetBehavior.preloadTime); if (m_Director.time >= clip.start + clip.duration || m_Director.time <= clip.start - preloadTime) { hvrAssetBehavior.StopAsset(); } else if (m_Director.time > clip.start - preloadTime) { hvrAssetBehavior.PrepareAsset(); } // If this behavior is within the range of the clip, then take it's asset and // overwrite the activeAsset in order to ensure that only one asset is assigned per // evaluation to the target HvrActor // this assumes that the order of clips remain in a consistent order between frames if (m_Director.time >= clip.start && m_Director.time <= clip.end) { if (inputWeight >= greatestWeight) { greatestWeight = inputWeight; current_asset = hvrAssetBehavior.asset; } } } ++inputPort; } if (!string.IsNullOrEmpty(m_originalActorRenderMethodType) && m_originalActorRenderMethodType != actor.renderMethodType) { // TODO Remove this warning once this bug is fixed - Tom Debug.LogError("HvrActor RenderMethod changed while a Timeline Clip was playing. This behavior is unsupported"); return; } if (actor.actorInterface != null && actor.assetInterface != current_asset) { actor.SetAssetInterface(current_asset); } }
private bool HasFrameBounds() { HvrActor actor = target as HvrActor; return(actor.assetInterface != null); }
private List <string> GetGuidsForDataToExport(string[] scenes) { List <string> guids = new List <string>(); for (int i = 0; i < scenes.Length; i++) { Scene scene = EditorSceneManager.OpenScene(scenes[i], OpenSceneMode.Single); GameObject[] sceneRootObjects = scene.GetRootGameObjects(); List <GameObject> everyObjectInScene = new List <GameObject>(); foreach (GameObject go in sceneRootObjects) { everyObjectInScene.Add(go); everyObjectInScene.AddRange(Helper.GetGameObjectChildrenRecursive(go)); } for (int o = 0; o < everyObjectInScene.Count; o++) { HvrActor[] allHvrActors = everyObjectInScene[o].GetComponents <HvrActor>(); for (int p = 0; p < allHvrActors.Length; p++) { HvrActor actor = allHvrActors[p]; if (actor != null && actor.dataMode == HvrActor.eDataMode.reference && actor.data != null) { // Early exit if the actor does not have any data assigned if (actor.data == string.Empty) { continue; } // Do not copy the same data twice if (guids.Contains(actor.data)) { continue; } guids.Add(actor.data); } } HvrDataBuildInclude[] includes = everyObjectInScene[o].GetComponents <HvrDataBuildInclude>(); for (int p = 0; p < includes.Length; p++) { HvrDataBuildInclude include = includes[p]; if (include != null && include.dataReference != null) { for (int d = 0; d < include.dataReference.data.Count; d++) { string guid = include.dataReference.data[d].guid; // Early exit if the actor does not have any data assigned if (guid == "") { continue; } // Do not copy the same data twice if (guids.Contains(guid)) { continue; } guids.Add(guid); } } } } } return(guids); }
public void MaterialEditor(UnityEngine.Object target, Material material, SerializedObject serializedObject) { if (target == null || material == null) { return; } HashSet <Material> mats = new HashSet <Material>(); foreach (UnityEngine.Object obj in serializedObject.targetObjects) { if (obj.GetType() == target.GetType()) { if (obj.GetType() == typeof(HvrActor)) { HvrActor actor = (HvrActor)obj; mats.Add(actor.material); } } } if (materialEditor == null) { materialEditor = (MaterialEditor)UnityEditor.Editor.CreateEditor(material); } else { if (materialEditor.target != material) { materialEditor = (MaterialEditor)UnityEditor.Editor.CreateEditor(material); } } if (mats.Count > 1) { EditorGUILayout.HelpBox("Material properties on selected components with different materials cannot be multi-edited", MessageType.Warning); } MaterialProperty[] properties_previous = UnityEditor.MaterialEditor.GetMaterialProperties(new UnityEngine.Object[1] { materialEditor.target }); EditorGUI.BeginChangeCheck(); { EditorGUI.BeginDisabledGroup(mats.Count > 1); { // Draw the material's foldout and the material shader field // Required to call _materialEditor.OnInspectorGUI (); materialEditor.DrawHeader(); // Draw the material properties // Works only if the foldout of _materialEditor.DrawHeader () is open materialEditor.OnInspectorGUI(); } EditorGUI.EndDisabledGroup(); } if (EditorGUI.EndChangeCheck()) { MaterialProperty[] properties_new = UnityEditor.MaterialEditor.GetMaterialProperties(new UnityEngine.Object[1] { materialEditor.target }); foreach (MaterialProperty prop_new in properties_new) { MaterialProperty match = properties_previous.First(x => (x.name == prop_new.name) && (x.type == prop_new.type)); if (match != null) { foreach (Material mat in mats) { switch (prop_new.type) { case MaterialProperty.PropType.Color: if (prop_new.colorValue != match.colorValue) { mat.SetColor(prop_new.name, prop_new.colorValue); } break; case MaterialProperty.PropType.Float: if (prop_new.floatValue != match.floatValue) { mat.SetFloat(prop_new.name, prop_new.floatValue); } break; case MaterialProperty.PropType.Range: if (prop_new.floatValue != match.floatValue) { mat.SetFloat(prop_new.name, prop_new.floatValue); } break; case MaterialProperty.PropType.Texture: if (prop_new.textureValue != match.textureValue) { mat.SetTexture(prop_new.name, prop_new.textureValue); } break; case MaterialProperty.PropType.Vector: if (prop_new.vectorValue != match.vectorValue) { mat.SetVector(prop_new.name, prop_new.vectorValue); } break; } } } } } }