I've received this new error and I can't seem to fix it. I figured out that a value is returning null but I can't find a way to fix it.
Here's the code.
[spoiler]public void ChangeSize(ResourceNode parent ,Vector3 scale)
{
FileStream fs = new FileStream(Application.StartupPath + "\\Output\\Output.brres", FileMode.Open);
CHR0EntryNode entry;
foreach (ResourceNode r in parent.Children)
{
if (r is CHR0EntryNode)
{
entry = r as CHR0EntryNode;
entry.SetKeyframeOnlyScale(0, scale);
}
}
fs.Close();
}[/spoiler]
The line in bold is the issue, but it's declared here.
[spoiler]public void ChangeSize(ResourceNode parent ,Vector3 scale)[/spoiler]
So what gives I've been editing for over a hour and it's really irritating.
However you set the array "parent.Children" probably has a mistake in it. To use that foreach loop, each of parent.Children[x] must be a "ResourceNode" object.
Mind posting the function that adds to the Children array?
I'm using the BrawlLib.dll so I didn't make the array, but I checked out some of the source code of a BrawlLib.cs and ResourceNode Children and a different function then it does in my code so I'll add that code into mine.
Hmmmm same error. I'm thinking that I may need to add BrawlLib.cs to the program to see what will fix it.
Here's the function for both mine and BrawlLib.
Mine:
[spoiler]public void ChangeSize(Reference parent,Vector3 scale)
{
FileStream fs = new FileStream(Application.StartupPath + "\\Output\\Output.brres", FileMode.Open);
CHR0EntryNode entry;
foreach (ResourceNode r in parent.Children2)
{
if (r is CHR0EntryNode)
{
entry = r as CHR0EntryNode;
entry.SetKeyframeOnlyScale(0, scale);
}
}
fs.Close();
}
-------------------------------------------
public abstract class Reference
{
internal protected List<ResourceNode> _children = new List<ResourceNode>();
public List<ResourceNode> Children2
{
get
{
if (_children == null)
{
_children = new List<ResourceNode>();
}
return _children;
}
}
}
}[/spoiler]
BrawlLib:
[spoiler]public List<ResourceNode> Children
{
get
{
if (_children == null)
{
_children = new List<ResourceNode>();
if (WorkingSource != DataSource.Empty)
OnPopulate();
}
return _children;
}
}[/spoiler]
I eliminated some of BrawLib's code as to remove unnecessary code and not clutter the form. See any errors?