Esempio n. 1
0
    private void OnEnable()
    {
        if (hitboxBackgroundStyle == null)
        {
            hitboxBackgroundStyle = new GUIStyle();
            hitboxBackgroundStyle.normal.background = MakeTexture(1, 1, new Color(0f, 0f, 0f, 0.2f));
        }
        //When changing scenes the background is deleted
        else if (hitboxBackgroundStyle.normal.background == null)
        {
            hitboxBackgroundStyle.normal.background = MakeTexture(1, 1, new Color(0f, 0f, 0f, 0.2f));
        }

        targetComponents = target as HitBoxComponent;
        AnimationHelper.init();

        targetComponents.SyncKeyFramesWithSimpleAnimator();

        if (targetComponents.inspectorTemp != null)
        {
            var state = targetComponents.GetState(targetComponents.GetStateNames()[targetComponents.inspectorTemp.animationindex]);
            AnimationHelper.SetCurrentClip(state.clip);
            traceAnimMode = (TraceAnimMode)targetComponents.inspectorTemp.traceAnimMode;
        }
    }
Esempio n. 2
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();
    }