Exemple #1
0
    public void OnSceneGUI()
    {
        FmodEventAudioSource source = target as FmodEventAudioSource;

        source.CheckForOldFormat();
        if (source != null && source.getSource() != null && source.getSourceType() == FmodEvent.SourceType.SOURCE_3D)
        {
            float prevVal;
            float val;
            SerializedProperty minRangeProp;
            SerializedProperty maxRangeProp;

            if (m_source == null)
            {
                m_source = new SerializedObject(source.getSource());
            }
            minRangeProp = m_source.FindProperty("m_minRange");
            maxRangeProp = m_source.FindProperty("m_maxRange");

            prevVal = source.getMinRange();
            val     = Handles.RadiusHandle(source.transform.rotation, source.transform.position, prevVal);
            minRangeProp.floatValue = val;
            if (val != prevVal)
            {
                source.setMinRange(val);
            }
            prevVal = source.getMaxRange();
            val     = Handles.RadiusHandle(source.transform.rotation, source.transform.position, prevVal);
            maxRangeProp.floatValue = val;
            if (val != prevVal)
            {
                source.setMaxRange(val);
            }
            if (m_source.ApplyModifiedProperties())
            {
                source.setMinRange(source.getMinRange());
                source.setMaxRange(source.getMaxRange());
            }
            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
            }
        }
    }