Ejemplo n.º 1
0
    public void InitWithEnvelope(EnvelopeModule module)
    {
        if (module == _envelopeModule)
        {
            return;
        }

        if (_envelopeModule != null)
        {
            DiscardEnvelope();
        }

        if (_handles == null)
        {
            SetupHandles();
        }

        _envelopeModule  = module;
        _samplesPerPixel = module.SamplesPerPixel;
        _scrollPos       = new Vector2(module.ScrollXPosition, 0f);

        EnvelopeHandle.MaxSamples = module.MaxSamples;

        UpdateZoom();

        _handles[0].PosInSamples = module.Offset;
        _handles[1].PosInSamples = module.FadeIn + module.Offset;

        _handles[3].PosInSamples = module.Length + module.Offset;
        _handles[2].PosInSamples = _handles[3].PosInSamples - module.FadeOut;

        UpdatePosHandle();

        module.onLengthWasMapped += OnLengthWasMapped;
    }
Ejemplo n.º 2
0
    void PopWindow()
    {
        _envelopeModule = target as EnvelopeModule;

        EnvelopeWindow window = EditorWindow.GetWindow <EnvelopeWindow>(true, "EnvelopeWindow");

        window.InitWithEnvelope(_envelopeModule);
    }
Ejemplo n.º 3
0
    void DiscardEnvelope()
    {
        _envelopeModule.ScrollXPosition = _scrollPos.x;
        _envelopeModule.MaxSamples      = EnvelopeHandle.MaxSamples;
        _envelopeModule.SamplesPerPixel = _samplesPerPixel;

        _envelopeModule.onLengthWasMapped -= OnLengthWasMapped;

        _envelopeModule = null;
    }
Ejemplo n.º 4
0
    void OnGUI()
    {
        bool canCreate = false;

        EditorGUIUtility.fieldWidth = 70f;
        EditorGUIUtility.labelWidth = 80f;

        _sampleBank = ( GATActiveSampleBank )EditorGUILayout.ObjectField("Sample Bank:", _sampleBank, typeof(GATSampleBank), true);

        if (_sampleBank != null)
        {
            if (_sampleBank.SoundBank == null)
            {
                EditorGUILayout.HelpBox("Your SampleBank must refer to a SoundBank!", MessageType.Error);
            }
            else
            {
                canCreate = true;
            }
        }
        else
        {
            EditorGUILayout.HelpBox("Creating a Music System is a shortcut to create and link a MasterPulse, an Envelope, and a Pattern. Creating a Music System requires a SampleBank object in your scene.", MessageType.Info);
        }

        GUI.enabled = canCreate;

        GUI.color = Color.green;

        if (GUILayout.Button("Create", GUILayout.ExpandWidth(false)))
        {
            MasterPulseModule pulse = GATEditorUtilities.NewChildGO <MasterPulseModule>("Music System");

            EnvelopeModule envelope = GATEditorUtilities.NewChildGO <EnvelopeModule>("Envelope", pulse.gameObject);
            envelope.Pulse      = pulse;
            envelope.MaxSamples = _sampleBank.SoundBank.SizeOfShortestSample();

            PulsedPatternModule pattern = GATEditorUtilities.NewChildGO <PulsedPatternModule>("Pattern", pulse.gameObject);
            pattern.Envelope   = envelope;
            pattern.SampleBank = _sampleBank;
            pattern.Pulse      = pulse;

            pattern.AddSample(_sampleBank.SoundBank.SampleInfos[0].Name);

            this.Close();
        }
    }