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
  Incorrect mesh alignment after extrusion on curved path Thinkurvy 10 19 04-17-2024, 10:57 AM
Last Post: _Aka_
  Set Volume to the Volume Controller at Runtime pako88 2 10 04-08-2024, 03:26 PM
Last Post: _Aka_
  Adjust radius of generated mesh via script? Shackman 1 4 03-26-2024, 01:12 PM
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_

Forum Jump: