Exemple #1
0
    private void OnEnable()
    {
        _myTarget = (MoveManualRB)target;
        _soTarget = new SerializedObject(target);

        _moveEffect = _soTarget.FindProperty("_moveEffect");
        _runSound   = _soTarget.FindProperty("_runSound");
        _walkSound  = _soTarget.FindProperty("_walkSound");
    }
Exemple #2
0
    public override void OnInspectorGUI()
    {
        _soTarget.Update();
        base.OnInspectorGUI();

        MoveManualRB moveScript = (MoveManualRB)target;

        GUILayout.Label("");
        GUILayout.Label("Effects", EditorStyles.boldLabel);



        // Particle Effects
        if (GUILayout.Toggle(_hasParticleEffect, "Has a Particle Effect?"))
        {
            _hasParticleEffect = true;
        }
        else
        {
            _hasParticleEffect = false;
        }

        if (_hasParticleEffect)
        {
            EditorGUILayout.PropertyField(_moveEffect);
        }



        // Sound Effects
        if (GUILayout.Toggle(_hasSoundEffect, "Has a Sound Effect?"))
        {
            _hasSoundEffect = true;

            if (_myTarget.gameObject.GetComponent <AudioSource>() == null)
            {
                _myTarget.gameObject.AddComponent <AudioSource>();
            }
        }
        else
        {
            _hasSoundEffect = false;
        }

        _soTarget.ApplyModifiedProperties();

        if (_hasSoundEffect)
        {
            EditorGUILayout.PropertyField(_runSound);
            EditorGUILayout.PropertyField(_walkSound);
        }
    }