本文整理汇总了C#中FlatRedBall.Glue.SaveClasses.NamedObjectSave.GetCustomVariable方法的典型用法代码示例。如果您正苦于以下问题:C# NamedObjectSave.GetCustomVariable方法的具体用法?C# NamedObjectSave.GetCustomVariable怎么用?C# NamedObjectSave.GetCustomVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlatRedBall.Glue.SaveClasses.NamedObjectSave
的用法示例。
在下文中一共展示了NamedObjectSave.GetCustomVariable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReactToTextureAddressMode
private void ReactToTextureAddressMode(NamedObjectSave namedObjectSave, object oldValue)
{
bool isSprite = namedObjectSave.SourceType == SourceType.FlatRedBallType && namedObjectSave.SourceClassType == "Sprite";
if(isSprite)
{
var addressModeVariable = namedObjectSave.GetCustomVariable("TextureAddressMode");
if (addressModeVariable != null && addressModeVariable.Value != null &&
((TextureAddressMode)(addressModeVariable.Value) == TextureAddressMode.Wrap || (TextureAddressMode)(addressModeVariable.Value) == TextureAddressMode.Mirror))
{
// How big is the texture?
var textureVariable = namedObjectSave.GetCustomVariable("Texture");
if (textureVariable != null && textureVariable.Value != null)
{
string value = textureVariable.Value as string;
var rfs = namedObjectSave.GetContainer().GetReferencedFileSaveByInstanceName(value);
if (rfs != null)
{
var width = ImageHeader.GetDimensions(
ProjectManager.MakeAbsolute(rfs.Name)).Width;
var height = ImageHeader.GetDimensions(
ProjectManager.MakeAbsolute(rfs.Name)).Height;
string whatIsWrong = null;
if (FlatRedBall.Math.MathFunctions.IsPowerOfTwo(width) == false)
{
whatIsWrong = "This Sprite's texture (" + textureVariable.Value + ") has a width of " +
width + " but it should be a power of two to use " + addressModeVariable.Value + " TextureAddressMode";
}
if (FlatRedBall.Math.MathFunctions.IsPowerOfTwo(height) == false)
{
whatIsWrong = "This Sprite's texture (" + textureVariable.Value + ") has a height of " +
height + " but it should be a power of two to use " + addressModeVariable.Value + " TextureAddressMode";
}
if(!string.IsNullOrEmpty(whatIsWrong))
{
whatIsWrong += "\nWhat would you like to do?";
MultiButtonMessageBox mbmb = new MultiButtonMessageBox();
mbmb.MessageText = whatIsWrong;
mbmb.AddButton("Undo the change", DialogResult.Cancel);
mbmb.AddButton("Keep the change (May cause runtime crashes)", DialogResult.Yes);
var result = mbmb.ShowDialog();
if(result == DialogResult.Cancel)
{
addressModeVariable.Value = oldValue;
}
}
}
}
}
}
}
示例2: ReactToAnimationChainSet
private void ReactToAnimationChainSet(NamedObjectSave namedObjectSave, object oldValue)
{
AvailableAnimationChainsStringConverter aacsc = new AvailableAnimationChainsStringConverter(
GlueState.Self.CurrentElement, namedObjectSave);
var customVariable = namedObjectSave.GetCustomVariable("CurrentChainName");
string currentChain = null;
if (customVariable != null)
{
currentChain = customVariable.Value as string;
}
if (!aacsc.AvailableChains.Contains(currentChain))
{
if (aacsc.AvailableChains.Length == 0)
{
namedObjectSave.SetPropertyValue("CurrentChainName", null);
}
else
{
namedObjectSave.SetPropertyValue("CurrentChainName", aacsc.AvailableChains[0]);
}
}
}
示例3: ReactToFontSet
private void ReactToFontSet(NamedObjectSave namedObjectSave, object oldValue)
{
string value = namedObjectSave.GetCustomVariable("Font").Value as string;
if (!string.IsNullOrEmpty(value))
{
IElement element = EditorLogic.CurrentElement;
ReferencedFileSave referencedFileSave = element.GetReferencedFileSaveByInstanceNameRecursively(value);
if (referencedFileSave != null)
{
string file = referencedFileSave.GetRelativePath();
file = ProjectManager.MakeAbsolute(file, true);
string contents = FileManager.FromFileText(file);
int size =
StringFunctions.GetIntAfter(
"size=", contents);
float lineHeightInPixels =
StringFunctions.GetIntAfter(
"lineHeight=", contents);
lineHeightInPixels /= 2.0f;
namedObjectSave.SetPropertyValue("Scale", (float)lineHeightInPixels);
namedObjectSave.SetPropertyValue("Spacing", (float)lineHeightInPixels);
namedObjectSave.SetPropertyValue("NewLineDistance", (float)(lineHeightInPixels * 1.5f));
}
}
}
示例4: SetVariableToDefault
public static void SetVariableToDefault(NamedObjectSave currentNamedObject, string variableToSet)
{
// July 13, 2014
// This used to simply set the value to null, but why don't we remove it if it exists?
// This way if an error is introduced by some plugin that sets the type to something invalid
// the user can still remove it through this option and recover the type later.
//currentNamedObject.SetPropertyValue(variableToSet, null);
currentNamedObject.InstructionSaves.RemoveAll(item => item.Member == variableToSet);
if (currentNamedObject.GetCustomVariable(variableToSet) != null)
{
// See if this variable is tunneled into in this element.
// If so, set that value too.
CustomVariableInNamedObject cvino = currentNamedObject.GetCustomVariable(variableToSet);
object value = cvino.Value;
foreach (CustomVariable customVariable in EditorLogic.CurrentElement.CustomVariables)
{
if (customVariable.SourceObject == currentNamedObject.InstanceName &&
customVariable.SourceObjectProperty == variableToSet)
{
customVariable.DefaultValue = value;
break;
}
}
GlueCommands.Self.RefreshCommands.RefreshPropertyGrid();
}
}