Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

EffectParameter Class

Represents an Effect parameter.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework.Graphics (in microsoft.xna.framework.graphics.dll)

public sealed class EffectParameter
Creating and assigning a EffectParameter instance for each technique in your Effect is significantly faster than using the Parameters indexed property on Effect.

To use a EffectParameter you must:

  1. Create a EffectParameter for each parameter in your Effect that you will be setting in Draw or Update.

    public EffectParameter mWorld;
    public EffectParameter mCameraView;
    public EffectParameter CameraPos;
    public EffectParameter mCameraProj;
    
  2. Assign an Effect parameter to your EffectParameter.

    mWorld = effect.Parameters["g_mWorld"];
    mCameraView = effect.Parameters["g_mCameraView"];
    CameraPos = effect.Parameters["g_CameraPos"];
    mCameraProj = effect.Parameters["g_mCameraProj"];
    
  3. Call SetValue on your EffectParameter to change the parameter value.

    MyEffect.CameraPos.SetValue(CameraPos);
    MyEffect.mCameraView.SetValue(view);
    MyEffect.mCameraProj.SetValue(projection);
    MyEffect.LightPos.SetValue(LightPos);
    MyEffect.mLightView.SetValue(Matrix.CreateLookAt(LightPos,
        bounds.Center, Vector3.Up));
    
Xbox 360, Windows 7, Windows Vista, Windows XP

Community Additions

Show:
© 2014 Microsoft. All rights reserved.