本文整理汇总了C#中IMyEntity.OnAddedToScene方法的典型用法代码示例。如果您正苦于以下问题:C# IMyEntity.OnAddedToScene方法的具体用法?C# IMyEntity.OnAddedToScene怎么用?C# IMyEntity.OnAddedToScene使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMyEntity
的用法示例。
在下文中一共展示了IMyEntity.OnAddedToScene方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddChild
/// <summary>
/// Adds the child.
/// </summary>
/// <param name="child">The child.</param>
/// <param name="preserveWorldPos">if set to <c>true</c> [preserve absolute position].</param>
public void AddChild(IMyEntity child, bool preserveWorldPos = false, bool insertIntoSceneIfNeeded = true)
{
//MyEntities.Remove(child); // if it's already in the world, remove it
MyHierarchyComponentBase childHierarchy = child.Components.Get<MyHierarchyComponentBase>();
childHierarchy.Parent = this;
if (preserveWorldPos)
{
var tmpWorldMatrix = child.WorldMatrix;
this.Children.Add(childHierarchy);
child.WorldMatrix = tmpWorldMatrix;
}
else
{
this.Children.Add(childHierarchy);
MyPositionComponentBase positionComponent = Container.Get<MyPositionComponentBase>();
MyPositionComponentBase childPositionComponent = child.Components.Get<MyPositionComponentBase>();
var m = positionComponent.WorldMatrix;
childPositionComponent.UpdateWorldMatrix(ref m);
}
if (Container.Entity.InScene && !child.InScene && insertIntoSceneIfNeeded)
child.OnAddedToScene(Container.Entity);
}
示例2: AddChildWithMatrix
public void AddChildWithMatrix(IMyEntity child, ref Matrix childLocalMatrix, bool insertIntoSceneIfNeeded = true)
{
MyHierarchyComponentBase childHierarchy = child.Components.Get<MyHierarchyComponentBase>();
childHierarchy.Parent = this;
Children.Add(childHierarchy);
child.WorldMatrix = (MatrixD)childLocalMatrix * Container.Get<MyPositionComponentBase>().WorldMatrix;
if (Container.Entity.InScene && !child.InScene && insertIntoSceneIfNeeded)
child.OnAddedToScene(this);
}