public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor editor) { var guid = HDUtilsEx.ConvertVector4ToGUID(prop.vectorValue); var profile = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), DiffusionProfileSettingsEx.Type); EditorGUI.BeginChangeCheck(); profile = EditorGUI.ObjectField(position, new GUIContent(label), profile, DiffusionProfileSettingsEx.Type, false); if (EditorGUI.EndChangeCheck()) { Vector4 newGuid = Vector4.zero; float hash = 0; if (profile != null) { var guid2 = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(profile)); newGuid = HDUtilsEx.ConvertGUIDToVector4(guid2); hash = HDShadowUtilsEx.Asfloat(DiffusionProfileSettingsEx.Hash(profile)); } prop.vectorValue = newGuid; var hashField = MaterialEditor.GetMaterialProperty(new UnityEngine.Object[] { editor.target }, m_hashField); if (hashField != null) { hashField.floatValue = hash; } } if (profile == null) { prop.vectorValue = Vector4.zero; } DiffusionProfileMaterialUIEx.DrawDiffusionProfileWarning(profile); }
public override void ForceUpdateFromMaterial(Material material) { string propertyAsset = m_propertyName + "_asset"; if (m_defaultInspector) { propertyAsset = "_DiffusionProfileAsset"; } if (UIUtils.IsProperty(m_currentParameterType) && material.HasProperty(propertyAsset)) { var guid = HDUtilsEx.ConvertVector4ToGUID(material.GetVector(propertyAsset)); var profile = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), DiffusionProfileSettingsEx.Type); if (profile != null) { m_materialValue = profile; } } }