本文整理汇总了C#中ContentRef.As方法的典型用法代码示例。如果您正苦于以下问题:C# ContentRef.As方法的具体用法?C# ContentRef.As怎么用?C# ContentRef.As使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentRef
的用法示例。
在下文中一共展示了ContentRef.As方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsUsingSrcFile
public bool IsUsingSrcFile(ContentRef<Resource> r, string srcFile)
{
ContentRef<Font> f = r.As<Font>();
return f != null && f.Res.CustomFamilyData != null && f.Res.SourcePath == srcFile;
}
示例2: OnResourceModified
private void OnResourceModified(ContentRef<Resource> resRef)
{
List<object> changedObj = null;
// If a font has been modified, reload it and update all TextRenderers
if (resRef.Is<Font>())
{
if (resRef.IsLoaded)
{
Font fnt = resRef.As<Font>().Res;
if (fnt.NeedsReload)
fnt.ReloadData();
}
foreach (Duality.Components.Renderers.TextRenderer r in Scene.Current.AllObjects.GetComponents<Duality.Components.Renderers.TextRenderer>())
{
r.Text.ApplySource();
if (changedObj == null) changedObj = new List<object>();
changedObj.Add(r);
}
}
// If its a Pixmap, reload all associated Textures
else if (resRef.Is<Pixmap>())
{
ContentRef<Pixmap> pixRef = resRef.As<Pixmap>();
foreach (ContentRef<Texture> tex in ContentProvider.GetLoadedContent<Texture>())
{
if (!tex.IsAvailable) continue;
if (tex.Res.BasePixmap == pixRef)
{
tex.Res.ReloadData();
if (changedObj == null) changedObj = new List<object>();
changedObj.Add(tex.Res);
}
}
}
// If its a Texture, update all associated RenderTargets
else if (resRef.Is<Texture>())
{
if (resRef.IsLoaded)
{
Texture tex = resRef.As<Texture>().Res;
if (tex.NeedsReload)
tex.ReloadData();
}
ContentRef<Texture> texRef = resRef.As<Texture>();
foreach (ContentRef<RenderTarget> rt in ContentProvider.GetLoadedContent<RenderTarget>())
{
if (!rt.IsAvailable) continue;
if (rt.Res.Targets.Contains(texRef))
{
rt.Res.SetupOpenGLRes();
if (changedObj == null) changedObj = new List<object>();
changedObj.Add(rt.Res);
}
}
}
// If its some kind of shader, update all associated ShaderPrograms
else if (resRef.Is<AbstractShader>())
{
ContentRef<FragmentShader> fragRef = resRef.As<FragmentShader>();
ContentRef<VertexShader> vertRef = resRef.As<VertexShader>();
foreach (ContentRef<ShaderProgram> sp in ContentProvider.GetLoadedContent<ShaderProgram>())
{
if (!sp.IsAvailable) continue;
if (sp.Res.Fragment == fragRef ||
sp.Res.Vertex == vertRef)
{
bool wasCompiled = sp.Res.Compiled;
sp.Res.AttachShaders();
if (wasCompiled) sp.Res.Compile();
if (changedObj == null) changedObj = new List<object>();
changedObj.Add(sp.Res);
}
}
}
// Notify a change that isn't critical regarding persistence (don't flag stuff unsaved)
if (changedObj != null)
DualityEditorApp.NotifyObjPropChanged(this, new ObjectSelection(changedObj as IEnumerable<object>), false);
}
示例3: IsUsingSrcFile
public bool IsUsingSrcFile(ContentRef<Resource> r, string srcFile)
{
ContentRef<AbstractShader> s = r.As<AbstractShader>();
return s != null && s.Res.SourcePath == srcFile;
}
示例4: IsUsingSrcFile
public bool IsUsingSrcFile(ContentRef<Resource> r, string srcFile)
{
ContentRef<Font> f = r.As<Font>();
return f != null && f.Res.EmbeddedTrueTypeFont != null && f.Res.SourcePath == srcFile;
}
示例5: IsUsingSrcFile
public bool IsUsingSrcFile(ContentRef<Resource> r, string srcFile)
{
ContentRef<Pixmap> p = r.As<Pixmap>();
return p != null && p.Res.SourcePath == srcFile;
}
示例6: IsUsingSrcFile
public bool IsUsingSrcFile(ContentRef<Resource> r, string srcFile)
{
ContentRef<AudioData> a = r.As<AudioData>();
return a != null && a.Res.SourcePath == srcFile;
}