void ChangeSelection(GameObject newSelection) { interaction = newSelection.GetComponent <InteractionBehaviour>(); // get our interaction sound interactionSound = newSelection.GetComponent <InteractionSound>(); if (interactionSound) { GetInteractionSoundObjectAndProperties(); } else { // clear interaction sound and object properties! interactionSoundObject = null; throwSourceProperty = null; impactSourceProperty = null; grabSourceProperty = null; slideSourceProperty = null; enableImpactSfxProperty = null; enableImpactVfxProperty = null; } // get trail renderer currentTrailRenderer = newSelection.GetComponent <TrailRenderer>(); if (currentTrailRenderer) { GetTrailObjectAndProperties(); } else { // clear trail renderer properties trailRendererObject = null; trailTimeProperty = null; trailMaterialsProperty = null; trailMinVertexDistProperty = null; trailWidthDistProperty = null; trailGradientProperty = null; } // get our sliding effect slideEffect = newSelection.GetComponent <SlideEffect>(); if (slideEffect) { GetSlideEffectObjectAndProperties(); } else { // clear slide effect stuff slideEffectObject = null; slideMaxMagnitudeProperty = null; slideMaxSoundMagnitudeProperty = null; slideMaxEmissionRateProperty = null; slideSoundVolumeProperty = null; slideParticleProperty = null; enableSlideSfx = null; enableAirTrailProperty = null; } selectedObject = newSelection; }
void CreateSlideEffect() { slideEffect = selectedObject.AddComponent <SlideEffect>(); GetSlideEffectObjectAndProperties(); // create smoke object smokeEffect = GameObject.Instantiate(smokePrefab, selectedObject.transform); // set values slideEffectObject.Update(); slideParticleProperty.objectReferenceValue = smokeEffect; slideMaxMagnitudeProperty.floatValue = 0.5f; slideMaxSoundMagnitudeProperty.floatValue = 1f; slideMaxEmissionRateProperty.floatValue = 15; // create a normal curve, then tweak it to be exponential. AnimationCurve volumeCurve = AnimationCurve.Linear(0, 0, 1, 1); volumeCurve.keys[0].outTangent = 0; volumeCurve.keys[1].inTangent = -5; // an attempt was made. slideSoundVolumeProperty.animationCurveValue = volumeCurve; slideEffectObject.ApplyModifiedProperties(); }