Esempio n. 1
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        GUILayout.BeginVertical();
        EditorGUI.BeginChangeCheck();
        GUI.skin.label.wordWrap = true;


        GUILayout.BeginHorizontal();
        GUILayout.Label("New HitBox Name:");
        addScriptableObjectName = GUILayout.TextField(addScriptableObjectName);
        GUILayout.EndHorizontal();
        if (addScriptableObjectName != "" && GUILayout.Button("Create And Add"))
        {
            if (addScriptableObjectName == "")
            {
                Debug.Log("Don't set empty name");
            }
            else
            {
                var newhitbox = CreateInstance <HitBoxes>();
                targetComponents.hitboxes = newhitbox;
                var path = AssetDatabase.GenerateUniqueAssetPath("Assets/" + addScriptableObjectName + ".asset");
                AssetDatabase.CreateAsset(newhitbox, path);
                addScriptableObjectName = "";
                targetComponents.SyncKeyFramesWithSimpleAnimator();
            }
        }
        ;


        EditorGUI.BeginChangeCheck();
        var prehitbox = targetComponents.hitboxes;
        var proph     = serializedObject.FindProperty("hitboxes");

        EditorGUILayout.PropertyField(proph, true);

        if (EditorGUI.EndChangeCheck())
        {
            if (proph.objectReferenceValue == null || targetComponents.IsStructureSame((HitBoxes)proph.objectReferenceValue) || EditorUtility.DisplayDialog("", "this operation will break the hitboxdata you selected now. really do this?", "do", "cancel"))
            {
                serializedObject.ApplyModifiedProperties();
                targetComponents.SyncKeyFramesWithSimpleAnimator();
            }
            else
            {
                return;
            }
        }

        if (targetComponents.hitboxes == null)
        {
            GUILayout.EndVertical();
            return;
        }

        targetComponents.gizmoController.drawGizmoData.Clear();

        //var curframe = AnimationHelper.GetCurrentFrame();


        EditorGUI.BeginChangeCheck();
        if (targetComponents.hitboxes != null)
        {
            DrawHitboxes();
        }
        GUILayout.EndVertical();

        serializedObject.ApplyModifiedProperties();


        SetGizmoControllerParam();
    }