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

            HelmPatch patch   = target as HelmPatch;
            Object    oldFile = patch.patchObject;

            patch.patchObject = EditorGUILayout.ObjectField("Patch File", oldFile, typeof(Object), false);
            if (oldFile != patch.patchObject)
            {
                Undo.RecordObject(patch, "Change Patch File");
                string path = AssetDatabase.GetAssetPath(patch.patchObject);
                patch.LoadPatchData(path);
            }

            serializedObject.ApplyModifiedProperties();
        }
コード例 #2
0
        /// <summary>
        /// Loads a synthesizer patch at runtime.
        /// </summary>
        /// <param name="patch">Reference to the patch object.</param>
        public void LoadPatch(HelmPatch patch)
        {
            FieldInfo[] fields = typeof(HelmPatchSettings).GetFields();
            Native.HelmClearModulations(channel);

            List <float> values = new List <float>();

            values.Add(0.0f);
            int index = 1;

            foreach (FieldInfo field in fields)
            {
                if (!field.FieldType.IsArray && !field.IsLiteral)
                {
                    float val = (float)field.GetValue(patch.patchData.settings);
                    Native.HelmSetParameterValue(channel, index, val);
                    values.Add(val);
                    index++;
                }
            }

            for (int i = 0; i < synthParameters.Count; ++i)
            {
                SetParameterAtIndex(i, values[(int)synthParameters[i].parameter]);
            }

            int modulationIndex = 0;

            foreach (HelmModulationSetting modulation in patch.patchData.settings.modulations)
            {
                if (modulationIndex >= HelmPatchSettings.kMaxModulations)
                {
                    Debug.LogWarning("Only " + HelmPatchSettings.kMaxModulations +
                                     " modulations are currently supported in the Helm Unity plugin.");
                    break;
                }

                Native.HelmAddModulation(channel, modulationIndex,
                                         modulation.source, modulation.destination, modulation.amount);
                modulationIndex++;
            }
        }