summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/AdvancedInspector/Examples/CSharp/AIExample11_ReadOnlyDynamic.cs
blob: a70b6c96824490cb444cc8dc9231b7721e513eb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using UnityEngine;
using System.Collections;

using AdvancedInspector;

[AdvancedInspector]
public class AIExample11_ReadOnlyDynamic : MonoBehaviour 
{
    // The ReadOnly attribute can also be dynamic and change at run time.
    [Inspect, ReadOnly("IsReadOnly")]
    public bool myVariable;

    // The function can be private or public, it doesn't matter.
    private bool IsReadOnly()
    {
        return isReadOnly;
    }

    private bool isReadOnly = true;

    // In this example, the button toggle on/off the read only attribute of "myVariable".
    [Inspect]
    public void PressMe()
    {
        isReadOnly = !isReadOnly;
    }
}