/// <summary> /// Retrieves the value of an import parameter for the specified <see cref="Resource"/>. /// If the parameter was undefined, it will be (persistently) initialized with the specified default value. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="env"></param> /// <param name="resource">A reference to the <see cref="Duality.Resource"/> that is parameterized.</param> /// <param name="parameterName">The name of the parameter.</param> /// <param name="defaultValue">If the value wasn't defined for the given Resource, the default value will be used instead.</param> /// <returns>The retrieved value, or the default value that was specified.</returns> public static T GetOrInitParameter <T>(this IAssetImportEnvironment env, IContentRef resource, string parameterName, T defaultValue) { T value; if (env.GetParameter <T>(resource, parameterName, out value)) { return(value); } env.SetParameter <T>(resource, parameterName, defaultValue); return(defaultValue); }