コード例 #1
0
    public static SfxrSoundContainer Create()
    {
#if !UNITY_EDITOR
        if (SfxrSoundContainer.container != null)
        {
            return(SfxrSoundContainer.container);
        }
#endif

        string paramsList = ReadSoundsFile();
        Dictionary <string, string> configurations = new Dictionary <string, string>();

        string[] pairs = paramsList.Split(new string[] { "\n", "\r\n" }, System.StringSplitOptions.RemoveEmptyEntries);
        for (int i = 0; i < pairs.Length; ++i)
        {
            string[] vals       = pairs[i].Split(':');
            string   title      = vals[0];
            string   parameters = vals[1];

            configurations.Add(title, parameters);
        }

        SfxrSoundContainer.container = new SfxrSoundContainer(configurations);
        return(SfxrSoundContainer.container);
    }
コード例 #2
0
ファイル: SfxrSound.cs プロジェクト: argzerotech/ProjectRD
    private void Initialize()
    {
        string parameters = SfxrSoundContainer.Create().GetSound(sound);

        synthesizer.parameters.SetSettingsString(parameters);
        if (cached)
        {
            Cache();
        }

        initialized = true;
    }
コード例 #3
0
ファイル: SfxrSoundContainer.cs プロジェクト: Elideb/usfxr
    public static SfxrSoundContainer Create()
    {
        #if !UNITY_EDITOR
        if (SfxrSoundContainer.container != null)
            return SfxrSoundContainer.container;
        #endif

        string paramsList = ReadSoundsFile();
        Dictionary<string, string> configurations = new Dictionary<string, string>();

        string[] pairs = paramsList.Split(new string[] { "\n", "\r\n" }, System.StringSplitOptions.RemoveEmptyEntries);
        for (int i = 0; i < pairs.Length; ++i) {
            string[] vals = pairs[i].Split(':');
            string title = vals[0];
            string parameters = vals[1];

            configurations.Add(title, parameters);
        }

        SfxrSoundContainer.container = new SfxrSoundContainer(configurations);
        return SfxrSoundContainer.container;
    }
コード例 #4
0
    private void DrawUnfolded(Rect position, SerializedProperty property, GUIContent label)
    {
        Rect labelRect     = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight);
        Rect dropdownRect  = new Rect(position.xMin, labelRect.yMax, position.width, EditorGUIUtility.singleLineHeight);
        Rect cachedRect    = new Rect(position.xMin, dropdownRect.yMax, position.width, EditorGUIUtility.singleLineHeight);
        Rect mutationsRect = new Rect(position.xMin, cachedRect.yMax, position.width, EditorGUIUtility.singleLineHeight);
        Rect factorRect    = new Rect(position.xMin, mutationsRect.yMax, position.width, EditorGUIUtility.singleLineHeight);

        var soundProperty     = property.FindPropertyRelative("sound");
        var cachedProperty    = property.FindPropertyRelative("cached");
        var mutationsProperty = property.FindPropertyRelative("mutations");
        var factorProperty    = property.FindPropertyRelative("mutationFactor");

        var soundContainer = SfxrSoundContainer.Create();

        property.isExpanded = EditorGUI.Foldout(labelRect, property.isExpanded, property.name);

        if (soundContainer.IsEmpty)
        {
            EditorGUI.Popup(dropdownRect, "Sound", 0, new string[] { "[No sounds saved]" });
        }
        else
        {
            string        sound  = soundProperty.stringValue;
            List <string> titles = new List <string>(soundContainer.GetTitles());
            int           newIdx = 0;
            if (!string.IsNullOrEmpty(sound) && titles.Contains(sound))
            {
                int idx = titles.IndexOf(sound);
                newIdx = EditorGUI.Popup(dropdownRect, "Sound", idx, titles.ToArray());
            }
            else
            {
                newIdx = EditorGUI.Popup(dropdownRect, "Sound", 0, titles.ToArray());
            }

            soundProperty.stringValue = titles[newIdx];
        }

        EditorGUI.BeginChangeCheck();
        bool newCached = EditorGUI.Toggle(cachedRect, "Cached", cachedProperty.boolValue);

        if (EditorGUI.EndChangeCheck())
        {
            cachedProperty.boolValue = newCached;
        }

        EditorGUI.BeginChangeCheck();
        int newMutations = EditorGUI.IntField(mutationsRect, "Mutations", mutationsProperty.intValue);

        if (EditorGUI.EndChangeCheck())
        {
            mutationsProperty.intValue = Mathf.Clamp(newMutations, 0, 100);
        }

        EditorGUI.BeginChangeCheck();
        float newFactor = EditorGUI.FloatField(factorRect, "Mutation factor", factorProperty.floatValue);

        if (EditorGUI.EndChangeCheck())
        {
            factorProperty.floatValue = newFactor;
        }
    }