Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
EffectParameterExtensions.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
6 using System.Text;
7 using System.Runtime.InteropServices;
8 
9 namespace SiliconStudio.Paradox.Effects
10 {
11  /// <summary>
12  /// Various extension methods to quickly get and set values in EffectVariable.
13  /// </summary>
14  public static class EffectParameterExtensions
15  {
16  public static void RegisterParameter(this ParameterCollection parameterCollection, ParameterKey parameterKey, bool addDependencies = true)
17  {
18  var metaData = parameterKey.Metadatas.OfType<ParameterKeyMetadata>().FirstOrDefault();
19 
20  if (metaData == null)
21  throw new ArgumentException("ParameterKey must be declared with metadata", "parameterKey");
22 
23  if (!parameterCollection.ContainsKey(parameterKey))
24  {
25  metaData.SetupDefaultValue(parameterCollection, parameterKey, addDependencies);
26  }
27  }
28  }
29 }
Various extension methods to quickly get and set values in EffectVariable.
Key of an effect parameter.
Definition: ParameterKey.cs:15
static void RegisterParameter(this ParameterCollection parameterCollection, ParameterKey parameterKey, bool addDependencies=true)
bool ContainsKey(ParameterKey key)
Determines whether the specified instance contains a parameter key.
A container to handle a hierarchical collection of effect variables.