コード例 #1
0
    public override void OnInspectorGUI()
    {
        this.serializedObject.Update();

        ExplosionReactor reactor = (ExplosionReactor)target;

        GUI.enabled = false;
        EditorGUILayout.PropertyField(script, true, new GUILayoutOption[0]);
        GUI.enabled = true;
        EditorGUILayout.PropertyField(effectRadius, new GUIContent("effectRadius"));
        EditorGUILayout.PropertyField(explosionForce, new GUIContent("explosionForce"));
        EditorGUILayout.PropertyField(oneShotOnly, new GUIContent("oneShotOnly"));
        EditorGUILayout.PropertyField(layerMask, new GUIContent("layerMask"));
        bool useGizmo = EditorGUILayout.Toggle("Use Gizmo", _useGizmo);

        if (useGizmo != _useGizmo)
        {
            _useGizmo = useGizmo;
            SceneView.RepaintAll();
        }

        if (Application.isPlaying && reactor.oneShotOnly)
        {
            if (GUILayout.Button("Reset"))
            {
                reactor.ResetOneShot();
            }
        }

        this.serializedObject.ApplyModifiedProperties();
    }
コード例 #2
0
    void OnSceneGUI()
    {
        if (!_useGizmo)
        {
            return;
        }

        ExplosionReactor reactor = (ExplosionReactor)target;

        Handles.color        = Color.yellow;
        reactor.effectRadius = Handles.RadiusHandle(Quaternion.identity, reactor.transform.position, reactor.effectRadius);
    }