Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing Volume Mesh UV
#4
Hey there,

I use this script on Build Volume Mesh of generator:

Code:
public class VolumeMeshController : MonoBehaviour
{
   [SerializeField] private float _referenceUVScaleY = 0.07f;
   [SerializeField] private bool _flip = false;
}

Code:
[CustomEditor(typeof(VolumeMeshController))]
public class VolumeMeshControllerEditor : UnityEditor.Editor
{
   private SerializedProperty _referenceUVScaleYProperty;
   private SerializedProperty _flipProperty;
   private Transform _transform;
   private BuildVolumeMesh _buildVolumeMesh;

   void OnEnable()
   {
       _transform = (target as VolumeMeshController).transform;

       _buildVolumeMesh = _transform.GetComponent<BuildVolumeMesh>();

       GetSerialiezedProperties();
   }

   public override void OnInspectorGUI()
   {
       base.OnInspectorGUI();

       // Update the serializedProperty - always do this in the beginning of OnInspectorGUI.
       serializedObject.Update();

       UpdateUV();

       // Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI.
       serializedObject.ApplyModifiedProperties();
   }

   private void GetSerialiezedProperties()
   {
       _referenceUVScaleYProperty = serializedObject.FindProperty("_referenceUVScaleY");
       _flipProperty = serializedObject.FindProperty("_flip");
   }

   private void UpdateUVScale()
   {
       int flip = !_flipProperty.boolValue ? 1 : -1;
       CGVolume data = _buildVolumeMesh.InVolume.GetData<CGVolume>();
       _buildVolumeMesh.MaterialSetttings[0].UVScale.x = flip;
       _buildVolumeMesh.MaterialSetttings[0].UVScale.y = data.Length * flip * _referenceUVScaleYProperty.floatValue;
       _buildVolumeMesh.Refresh();
   }
}

The problem is although I put that Refresh at the end of UpdateUVScale but still after changing _referenceUVScaleY value, there is no effect on the texture in the scene but in its generator the values are changed. (As you noticed I want this functionality in edit mode)

Where the problem is ? Any idea ?
Reply


Messages In This Thread
Changing Volume Mesh UV - by ATHellboy - 02-19-2020, 10:42 AM
RE: Changing Volume Mesh UV - by _Aka_ - 02-20-2020, 01:25 AM
RE: Changing Volume Mesh UV - by ATHellboy - 02-20-2020, 05:43 AM
RE: Changing Volume Mesh UV - by ATHellboy - 03-02-2020, 08:05 AM
RE: Changing Volume Mesh UV - by _Aka_ - 03-08-2020, 01:55 PM
RE: Changing Volume Mesh UV - by ATHellboy - 03-08-2020, 02:19 PM
RE: Changing Volume Mesh UV - by ATHellboy - 03-10-2020, 01:34 PM
RE: Changing Volume Mesh UV - by _Aka_ - 03-10-2020, 10:37 PM
RE: Changing Volume Mesh UV - by ATHellboy - 03-11-2020, 05:46 AM
RE: Changing Volume Mesh UV - by _Aka_ - 03-13-2020, 11:23 PM
RE: Changing Volume Mesh UV - by ATHellboy - 03-14-2020, 08:17 AM
RE: Changing Volume Mesh UV - by _Aka_ - 03-14-2020, 01:55 PM
RE: Changing Volume Mesh UV - by ATHellboy - 03-14-2020, 05:04 PM
RE: Changing Volume Mesh UV - by ATHellboy - 03-17-2020, 10:51 AM
RE: Changing Volume Mesh UV - by _Aka_ - 03-18-2020, 11:36 PM
RE: Changing Volume Mesh UV - by ATHellboy - 03-19-2020, 05:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a way to generate UVs along deformed and copied mesh? kubak 1 788 03-18-2026, 08:34 PM
Last Post: _Aka_
  Replace deform mesh on volume spots Kokoriko49 1 2,718 06-09-2025, 06:49 PM
Last Post: _Aka_
  Mesh Generation between two splines vatan 4 4,408 02-14-2025, 07:11 AM
Last Post: vatan
  Create Mesh Node, Make Static Options rickgplus 1 2,183 01-23-2025, 10:12 AM
Last Post: _Aka_

Forum Jump: