void Start() { Decal decal = DecalSystem.CreateDecalDirect(decalData); decal.SetTransform(location.position, location.rotation, Vector2.one); decal.SetData(decalData); decal.transform.localScale = Vector3.one; }
public void SetUp() { // Ensure Pools are set up if (!DecalSystem.HasDecalPool(decalDataPooled)) { DecalSystem.CreateDecalPool(decalDataPooled); } }
public void CanCreateDecalPool() { // Execution var hasPool = DecalSystem.HasDecalPool(decalDataPooled); // Result Assert.IsTrue(hasPool); LogAssert.NoUnexpectedReceived(); }
public void CanDestroyDecalPool() { // Execution DecalSystem.DestroyDecalPool(decalDataPooled); var hasPool = DecalSystem.HasDecalPool(decalDataPooled); // Result Assert.IsFalse(hasPool); LogAssert.NoUnexpectedReceived(); }
public void CanRegisterDecal() { // Execution var decal = DecalSystem.GetDecal(decalDataPooled); var registered = DecalSystem.decals.Contains(decal); // Result Assert.IsTrue(registered); LogAssert.NoUnexpectedReceived(); }
public void CanGetDecalPooled() { // Execution var hasPool = DecalSystem.HasDecalPool(decalDataPooled); var decal = DecalSystem.GetDecal(decalDataPooled); // Result Assert.IsTrue(hasPool); Assert.IsNotNull(decal); LogAssert.NoUnexpectedReceived(); }
public void CanGetDecal() { // Execution var decal = DecalSystem.GetDecal(decalData); var hasPool = PoolingSystem.HasPool <DecalData>(decalData); // Result Assert.IsFalse(hasPool); Assert.IsNotNull(decal); LogAssert.NoUnexpectedReceived(); }
// Start is called before the first frame update private void Awake() { if (instance == null) { instance = this; } else if (instance != null) { Destroy(gameObject); } }
public void CanRemoveDecal() { // Execution var decal = DecalSystem.GetDecal(decalData); var obj = decal.gameObject; DecalSystem.RemoveDecal(decal); // Result LogAssert.NoUnexpectedReceived(); }
private void CheckPlacement() { if (Input.GetMouseButtonUp(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { DecalSystem.GetDecal(hit.point, -hit.normal, decalData, true); } } }
public void CanRemoveDecalPooled() { // Execution var decal = DecalSystem.GetDecal(decalDataPooled); DecalSystem.RemoveDecal(decal); var isRemoved = !decal.gameObject.activeSelf; // Result Assert.IsTrue(isRemoved); Assert.IsNotNull(decal); LogAssert.NoUnexpectedReceived(); }
void SpawnDecal() { DecalSystem.GetDecal(locations[m_CurrentLocationIndex].position, locations[m_CurrentLocationIndex].rotation, decalData, true); if (m_CurrentLocationIndex < locations.Length - 1) { m_CurrentLocationIndex++; } else { m_CurrentLocationIndex = 0; } }
public override void OnInspectorGUI() { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_IsCropModeEnabledProperty, new GUIContent("Crop Decal with Gizmo")); EditorGUILayout.PropertyField(m_Size); EditorGUILayout.PropertyField(m_MaterialProperty); EditorGUILayout.PropertyField(m_DrawDistanceProperty); EditorGUILayout.Slider(m_FadeScaleProperty, 0.0f, 1.0f, new GUIContent("Distance fade scale")); EditorGUILayout.PropertyField(m_UVScaleProperty); EditorGUILayout.PropertyField(m_UVBiasProperty); EditorGUILayout.Slider(m_FadeFactor, 0.0f, 1.0f); // only display the affects transparent property if material is HDRP/decal if (DecalSystem.IsHDRenderPipelineDecal(m_DecalProjectorComponent.Mat.shader.name)) { EditorGUILayout.PropertyField(m_AffectsTransparencyProperty, new GUIContent("Affects Transparent Material")); } if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } if (m_LayerMask != m_DecalProjectorComponent.gameObject.layer) { m_DecalProjectorComponent.OnValidate(); } if (m_MaterialEditor != null) { // Draw the material's foldout and the material shader field // Required to call m_MaterialEditor.OnInspectorGUI (); m_MaterialEditor.DrawHeader(); // We need to prevent the user to edit default decal materials bool isDefaultMaterial = false; var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset; if (hdrp != null) { isDefaultMaterial = m_DecalProjectorComponent.Mat == hdrp.GetDefaultDecalMaterial(); } using (new EditorGUI.DisabledGroupScope(isDefaultMaterial)) { // Draw the material properties // Works only if the foldout of m_MaterialEditor.DrawHeader () is open m_MaterialEditor.OnInspectorGUI(); } } }
public void CanSetTransform() { // Execution var positon = Vector3.one; var direction = new Vector3(0, 0, 1); var scale = Vector2.one; var decal = DecalSystem.GetDecal(decalDataPooled, positon, direction, scale); var forward = Vector3.zero; // Result Assert.AreEqual(positon, decal.transform.position); Assert.AreEqual(forward, decal.transform.eulerAngles); Assert.AreEqual(scale, new Vector2(decal.transform.localScale.x, decal.transform.localScale.y)); LogAssert.NoUnexpectedReceived(); }
public override void OnInspectorGUI() { serializedObject.Update(); if (m_RequireUpdateMaterialEditor) { UpdateMaterialEditor(); m_RequireUpdateMaterialEditor = false; } EditorGUI.BeginChangeCheck(); { EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); DoInspectorToolbar(k_EditVolumeModes, editVolumeLabels, GetBoundsGetter(target as DecalProjector), this); DoInspectorToolbar(k_EditUVAndPivotModes, editPivotLabels, GetBoundsGetter(target as DecalProjector), this); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); Rect rect = EditorGUILayout.GetControlRect(true, EditorGUI.GetPropertyHeight(SerializedPropertyType.Vector2, k_SizeContent)); EditorGUI.BeginProperty(rect, k_SizeSubContent[0], m_SizeValues[0]); EditorGUI.BeginProperty(rect, k_SizeSubContent[1], m_SizeValues[1]); float[] size = new float[2] { m_SizeValues[0].floatValue, m_SizeValues[1].floatValue }; EditorGUI.BeginChangeCheck(); EditorGUI.MultiFloatField(rect, k_SizeContent, k_SizeSubContent, size); if (EditorGUI.EndChangeCheck()) { for (int i = 0; i < 2; ++i) { UpdateSize(i, Mathf.Max(0, size[i]), m_SizeValues[i].floatValue); } } EditorGUI.EndProperty(); EditorGUI.EndProperty(); EditorGUI.BeginChangeCheck(); float oldSizeZ = m_SizeValues[2].floatValue; EditorGUILayout.PropertyField(m_SizeValues[2], k_ProjectionDepthContent); if (EditorGUI.EndChangeCheck()) { UpdateSize(2, Mathf.Max(0, m_SizeValues[2].floatValue), oldSizeZ); } EditorGUILayout.PropertyField(m_Offset, k_Offset); EditorGUILayout.PropertyField(m_MaterialProperty, k_MaterialContent); bool decalLayerEnabled = false; HDRenderPipelineAsset hdrp = HDRenderPipeline.currentAsset; if (hdrp != null) { decalLayerEnabled = hdrp.currentPlatformRenderPipelineSettings.supportDecals && hdrp.currentPlatformRenderPipelineSettings.supportDecalLayers; using (new EditorGUI.DisabledScope(!decalLayerEnabled)) { EditorGUILayout.PropertyField(m_DecalLayerMask, k_DecalLayerMaskContent); } } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_DrawDistanceProperty, k_DistanceContent); if (EditorGUI.EndChangeCheck() && m_DrawDistanceProperty.floatValue < 0f) { m_DrawDistanceProperty.floatValue = 0f; } EditorGUILayout.PropertyField(m_FadeScaleProperty, k_FadeScaleContent); using (new EditorGUI.DisabledScope(!decalLayerEnabled)) { float angleFadeMinValue = m_StartAngleFadeProperty.floatValue; float angleFadeMaxValue = m_EndAngleFadeProperty.floatValue; EditorGUI.BeginChangeCheck(); EditorGUILayout.MinMaxSlider(k_AngleFadeContent, ref angleFadeMinValue, ref angleFadeMaxValue, 0.0f, 180.0f); if (EditorGUI.EndChangeCheck()) { m_StartAngleFadeProperty.floatValue = angleFadeMinValue; m_EndAngleFadeProperty.floatValue = angleFadeMaxValue; } } if (!decalLayerEnabled) { EditorGUILayout.HelpBox("Enable 'Decal Layers' in your HDRP Asset if you want to control the Angle Fade. There is a performance cost of enabling this option.", MessageType.Info); } EditorGUILayout.PropertyField(m_UVScaleProperty, k_UVScaleContent); EditorGUILayout.PropertyField(m_UVBiasProperty, k_UVBiasContent); EditorGUILayout.PropertyField(m_FadeFactor, k_FadeFactorContent); // only display the affects transparent property if material is HDRP/decal if (showAffectTransparencyHaveMultipleDifferentValue) { using (new EditorGUI.DisabledScope(true)) EditorGUILayout.LabelField(EditorGUIUtility.TrTextContent("Multiple material type in selection")); } else if (showAffectTransparency) { EditorGUILayout.PropertyField(m_AffectsTransparencyProperty, k_AffectTransparentContent); } } if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } if (layerMaskHasMultipleValue || layerMask != (target as Component).gameObject.layer) { foreach (var decalProjector in targets) { (decalProjector as DecalProjector).OnValidate(); } } if (m_MaterialEditor != null) { // We need to prevent the user to edit default decal materials bool isDefaultMaterial = false; bool isValidDecalMaterial = true; var hdrp = HDRenderPipeline.currentAsset; if (hdrp != null) { foreach (var decalProjector in targets) { var mat = (decalProjector as DecalProjector).material; isDefaultMaterial |= mat == hdrp.GetDefaultDecalMaterial(); isValidDecalMaterial &= mat != null && DecalSystem.IsDecalMaterial(mat); } } if (isValidDecalMaterial) { // Draw the material's foldout and the material shader field // Required to call m_MaterialEditor.OnInspectorGUI (); m_MaterialEditor.DrawHeader(); using (new EditorGUI.DisabledGroupScope(isDefaultMaterial)) { // Draw the material properties // Works only if the foldout of m_MaterialEditor.DrawHeader () is open m_MaterialEditor.OnInspectorGUI(); } } else { EditorGUILayout.HelpBox("Decal only work with Decal Material. Decal Material can be selected in the shader list HDRP/Decal or can be created from a Decal Master Node.", MessageType.Error); } } }
public override void OnInspectorGUI() { serializedObject.Update(); if (m_RequireUpdateMaterialEditor) { UpdateMaterialEditor(); m_RequireUpdateMaterialEditor = false; } EditorGUI.BeginChangeCheck(); { EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); DoInspectorToolbar(k_EditVolumeModes, editVolumeLabels, GetBoundsGetter, this); //[TODO: add editable pivot. Uncomment this when ready] //DoInspectorToolbar(k_EditPivotModes, editPivotLabels, GetBoundsGetter, this); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_Size, k_SizeContent); EditorGUILayout.PropertyField(m_MaterialProperty, k_MaterialContent); bool decalLayerEnabled = false; HDRenderPipelineAsset hdrp = HDRenderPipeline.currentAsset; if (hdrp != null) { decalLayerEnabled = hdrp.currentPlatformRenderPipelineSettings.supportDecals && hdrp.currentPlatformRenderPipelineSettings.supportDecalLayers; using (new EditorGUI.DisabledScope(!decalLayerEnabled)) { EditorGUILayout.PropertyField(m_DecalLayerMask, k_DecalLayerMaskContent); } } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_DrawDistanceProperty, k_DistanceContent); if (EditorGUI.EndChangeCheck() && m_DrawDistanceProperty.floatValue < 0f) { m_DrawDistanceProperty.floatValue = 0f; } EditorGUILayout.PropertyField(m_FadeScaleProperty, k_FadeScaleContent); using (new EditorGUI.DisabledScope(!decalLayerEnabled)) { EditorGUILayout.PropertyField(m_StartAngleFadeProperty, k_StartAngleFadeContent); if (EditorGUI.EndChangeCheck() && m_StartAngleFadeProperty.floatValue > m_EndAngleFadeProperty.floatValue) { m_EndAngleFadeProperty.floatValue = m_StartAngleFadeProperty.floatValue; } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_EndAngleFadeProperty, k_EndAngleFadeContent); if (EditorGUI.EndChangeCheck() && m_EndAngleFadeProperty.floatValue < m_StartAngleFadeProperty.floatValue) { m_StartAngleFadeProperty.floatValue = m_EndAngleFadeProperty.floatValue; } } if (!decalLayerEnabled) { EditorGUILayout.HelpBox("Enable 'Decal Layers' in your HDRP Asset if you want to control the Angle Fade. There is a performance cost of enabling this option.", MessageType.Info); } EditorGUILayout.PropertyField(m_UVScaleProperty, k_UVScaleContent); EditorGUILayout.PropertyField(m_UVBiasProperty, k_UVBiasContent); EditorGUILayout.PropertyField(m_FadeFactor, k_FadeFactorContent); // only display the affects transparent property if material is HDRP/decal if (showAffectTransparencyHaveMultipleDifferentValue) { using (new EditorGUI.DisabledScope(true)) EditorGUILayout.LabelField(EditorGUIUtility.TrTextContent("Multiple material type in selection")); } else if (showAffectTransparency) { EditorGUILayout.PropertyField(m_AffectsTransparencyProperty, k_AffectTransparentContent); } } if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } if (layerMaskHasMultipleValue || layerMask != (target as Component).gameObject.layer) { foreach (var decalProjector in targets) { (decalProjector as DecalProjector).OnValidate(); } } if (m_MaterialEditor != null) { // We need to prevent the user to edit default decal materials bool isDefaultMaterial = false; bool isValidDecalMaterial = true; var hdrp = HDRenderPipeline.currentAsset; if (hdrp != null) { foreach (var decalProjector in targets) { var mat = (decalProjector as DecalProjector).material; isDefaultMaterial |= mat == hdrp.GetDefaultDecalMaterial(); isValidDecalMaterial = isValidDecalMaterial && DecalSystem.IsDecalMaterial(mat); } } if (isValidDecalMaterial) { // Draw the material's foldout and the material shader field // Required to call m_MaterialEditor.OnInspectorGUI (); m_MaterialEditor.DrawHeader(); using (new EditorGUI.DisabledGroupScope(isDefaultMaterial)) { // Draw the material properties // Works only if the foldout of m_MaterialEditor.DrawHeader () is open m_MaterialEditor.OnInspectorGUI(); } } else { EditorGUILayout.HelpBox("Decal only work with Decal Material. Decal Material can be selected in the shader list HDRP/Decal or can be created from a Decal Master Node.", MessageType.Error); } } }
void SpawnDecal(Transform t) { DecalSystem.GetDecal(t.position, t.rotation, decalData, false); }
void Start() { m_Decal = DecalSystem.GetDecal(location.position, location.rotation, decalDatas[m_CurrentDataIndex], false); m_CurrentDataIndex++; }