Unity-Technologies / BoatAttack

Demo Project using the Universal RP from Unity3D
Other
2.56k stars 957 forks source link

Something wrong in water system #162

Open OtakuAndFitness opened 2 years ago

OtakuAndFitness commented 2 years ago

In WaterSurfaceDataEditor.cs,the code waveOrig.vector2Value = EditorGUI.Vector2Field(dirRect, "Point of Origin", waveOrig.vector2Value); shows error if I call it.

Mismatched types in GetValue - return value is junk
UnityEditor.SerializedProperty:get_vector2Value ()
WaterSystem.Data.WaterSurfaceDataEditor/<>c__DisplayClass1_0:<OnValidate>b__0 (UnityEngine.Rect,int,bool,bool) (at Assets/GameMain/3rdParty/com.verasl.water-system/Editor/WaterSurfaceDataEditor.cs:71)
UnityEditorInternal.ReorderableList:DoListElements (UnityEngine.Rect,UnityEngine.Rect)
UnityEditorInternal.ReorderableList:DoLayoutList ()
WaterSystem.Data.WaterSurfaceDataEditor:OnInspectorGUI () (at Assets/GameMain/3rdParty/com.verasl.water-system/Editor/WaterSurfaceDataEditor.cs:236)
WaterSystem.WaterEditor:OnInspectorGUI () (at Assets/GameMain/3rdParty/com.verasl.water-system/Editor/WaterEditor.cs:29)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Mismatched types in SetValue
UnityEditor.SerializedProperty:set_vector2Value (UnityEngine.Vector2)
WaterSystem.Data.WaterSurfaceDataEditor/<>c__DisplayClass1_0:<OnValidate>b__0 (UnityEngine.Rect,int,bool,bool) (at Assets/GameMain/3rdParty/com.verasl.water-system/Editor/WaterSurfaceDataEditor.cs:71)
UnityEditorInternal.ReorderableList:DoListElements (UnityEngine.Rect,UnityEngine.Rect)
UnityEditorInternal.ReorderableList:DoLayoutList ()
WaterSystem.Data.WaterSurfaceDataEditor:OnInspectorGUI () (at Assets/GameMain/3rdParty/com.verasl.water-system/Editor/WaterSurfaceDataEditor.cs:236)
WaterSystem.WaterEditor:OnInspectorGUI () (at Assets/GameMain/3rdParty/com.verasl.water-system/Editor/WaterEditor.cs:29)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

And even I comment it, there is nothing showing on the board if I click Customized button, Any help?

无标题

MAyaghmay commented 2 years ago

Add this class somewhere in you codes.

public static class SerializedPropertyExtensions
{
    public static Vector2 GetFloat2AsVector(this SerializedProperty property)
    {
        Vector2 output;
        var p = property.Copy();
        p.Next(true);
        output.x = p.floatValue;
        p.Next(true);
        output.y = p.floatValue;
        return output;
    }

    public static void SetFloat2FromVector(this SerializedProperty property, Vector2 value)
    {
        var p = property.Copy();
        p.Next(true);
        p.floatValue = value.x;
        p.Next(true);
        p.floatValue = value.y;
    }
}

And then replace Vector2Field property with function from the class. Although there is another problem with Omnidirectional wave too try not to choose that type for waves.