@@ -33,6 +33,9 @@ public class IsoSurfaceExtractor : MonoBehaviour
33
33
public Cell [ ] Cells ;
34
34
public bool debug = false ;
35
35
public float ChaosMultiplier = 1 ;
36
+ public float HandleSize = 1 ;
37
+ public float3 HandlePosition ;
38
+ public float3 DuplicationExtraPosition ;
36
39
37
40
static readonly int [ ] edgeTable = {
38
41
0x0 , 0x109 , 0x203 , 0x30a , 0x406 , 0x50f , 0x605 , 0x70c ,
@@ -617,16 +620,17 @@ public class IsoSurfaceExtractor : MonoBehaviour
617
620
[ Serializable ]
618
621
public struct Cell
619
622
{
620
- public int Vert0 ;
621
- public int Vert1 ;
622
- public int Vert2 ;
623
- public int Vert3 ;
624
- public int Vert4 ;
625
- public int Vert5 ;
626
- public int Vert6 ;
627
- public int Vert7 ;
623
+ [ NonSerialized ] public int Vert0 ;
624
+ [ NonSerialized ] public int Vert1 ;
625
+ [ NonSerialized ] public int Vert2 ;
626
+ [ NonSerialized ] public int Vert3 ;
627
+ [ NonSerialized ] public int Vert4 ;
628
+ [ NonSerialized ] public int Vert5 ;
629
+ [ NonSerialized ] public int Vert6 ;
630
+ [ NonSerialized ] public int Vert7 ;
628
631
public float3 Pos ;
629
- public int CubeIndex ;
632
+ [ NonSerialized ] public int CubeIndex ;
633
+ //remove all NonSerialized attributes if you need to debug these variables!
630
634
}
631
635
632
636
public MeshFilter MeshRenderer ;
@@ -1004,4 +1008,50 @@ public unsafe void FullCubesEmptiness()
1004
1008
// ContentPosition = EditorGUI.PrefixLabel(position, label);
1005
1009
// EditorGUI.PropertyField(ContentPosition, property.FindPropertyRelative("CubeIndex"));
1006
1010
// }
1007
- //}
1011
+ //}
1012
+
1013
+ #if UNITY_EDITOR
1014
+ [ CustomEditor ( typeof ( IsoSurfaceExtractor ) ) ]
1015
+ public class IsoSurfaceExtractorEditor : Editor
1016
+ {
1017
+ public void OnSceneGUI ( )
1018
+ {
1019
+ //Debug.Log("somethingworking?");
1020
+ var LO = target as IsoSurfaceExtractor ;
1021
+ SerializedProperty SCells = serializedObject . FindProperty ( "Cells" ) ;
1022
+
1023
+ Handles . color = Color . blue ;
1024
+
1025
+ for ( int i = 0 ; i < SCells . arraySize ; i ++ )
1026
+ {
1027
+ float3 CurrentPos = new float3 (
1028
+ SCells . GetArrayElementAtIndex ( i ) . FindPropertyRelative ( "Pos" ) . FindPropertyRelative ( "x" ) . floatValue ,
1029
+ SCells . GetArrayElementAtIndex ( i ) . FindPropertyRelative ( "Pos" ) . FindPropertyRelative ( "y" ) . floatValue ,
1030
+ SCells . GetArrayElementAtIndex ( i ) . FindPropertyRelative ( "Pos" ) . FindPropertyRelative ( "z" ) . floatValue ) ;
1031
+ CurrentPos = Handles . PositionHandle ( CurrentPos , quaternion . identity ) ;
1032
+
1033
+ SCells . GetArrayElementAtIndex ( i ) . FindPropertyRelative ( "Pos" ) . FindPropertyRelative ( "x" ) . floatValue = CurrentPos . x ;
1034
+ SCells . GetArrayElementAtIndex ( i ) . FindPropertyRelative ( "Pos" ) . FindPropertyRelative ( "y" ) . floatValue = CurrentPos . y ;
1035
+ SCells . GetArrayElementAtIndex ( i ) . FindPropertyRelative ( "Pos" ) . FindPropertyRelative ( "z" ) . floatValue = CurrentPos . z ;
1036
+
1037
+ var test = Handles . Button ( CurrentPos + LO . HandlePosition , quaternion . identity , LO . HandleSize , LO . HandleSize * 2 , Handles . SphereHandleCap ) ;
1038
+
1039
+ if ( test )
1040
+ {
1041
+ Debug . Log ( "buttonpressed" ) ;
1042
+
1043
+ //SCells.arraySize++;
1044
+ SCells . InsertArrayElementAtIndex ( i ) ;
1045
+ //SCells.GetArrayElementAtIndex(i+1) = SCells.GetArrayElementAtIndex(i);
1046
+ //SCells.GetArrayElementAtIndex(i + 1).FindPropertyRelative("Pos").vector3Value = SCells.GetArrayElementAtIndex(i).FindPropertyRelative("Pos").vector3Value;
1047
+
1048
+ SCells . GetArrayElementAtIndex ( i + 1 ) . FindPropertyRelative ( "Pos" ) . FindPropertyRelative ( "x" ) . floatValue += LO . DuplicationExtraPosition . x ;
1049
+ SCells . GetArrayElementAtIndex ( i + 1 ) . FindPropertyRelative ( "Pos" ) . FindPropertyRelative ( "y" ) . floatValue += LO . DuplicationExtraPosition . y ;
1050
+ SCells . GetArrayElementAtIndex ( i + 1 ) . FindPropertyRelative ( "Pos" ) . FindPropertyRelative ( "z" ) . floatValue += LO . DuplicationExtraPosition . z ;
1051
+ }
1052
+ }
1053
+ //LinkedObject.Size = Handles.ScaleHandle(LinkedObject.Size, LinkedObject.transform.position, LinkedObject.transform.rotation, HandleUtility.GetHandleSize(LinkedObject.transform.position) * 1.5f);
1054
+ serializedObject . ApplyModifiedProperties ( ) ;
1055
+ }
1056
+ }
1057
+ #endif
0 commit comments