本文整理汇总了C#中GameObject.RemoveComponent方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.RemoveComponent方法的具体用法?C# GameObject.RemoveComponent怎么用?C# GameObject.RemoveComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameObject
的用法示例。
在下文中一共展示了GameObject.RemoveComponent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.parent = this.gameObject.transform;
cube.transform.localPosition = new Vector3(0, 3f, 0);
cube.transform.localScale = new Vector3(1, .25f, 0f);
cube.RemoveComponent<BoxCollider>();
cube.GetComponent<MeshRenderer>().material.color = new Color(.6f, 0f, 0f, .5f);
cube.GetComponent<MeshRenderer>().material.shader = Shader.Find("Transparent/Cutout/Soft Edge Unlit");
cube.transform.localRotation = new Quaternion();
cube.EnsureComponent<LookAtCamera>();
}
示例2: HarvestHarvestable
private static bool HarvestHarvestable(HarvestPlant ths, GameObject harvestable, Sim actor, BurglarSituation burglarSituation)
{
if (harvestable == null)
{
return false;
}
harvestable.SetOwnerLot(actor.LotHome);
harvestable.UnParent();
harvestable.RemoveFromWorld();
bool flag = false;
if (burglarSituation == null)
{
if (actor.Inventory.TryToAdd(harvestable, false))
{
flag = true;
}
}
else
{
burglarSituation.StolenObjects.Add(harvestable);
burglarSituation.CurrentValue += harvestable.Value;
flag = true;
}
if (flag)
{
harvestable.AddFlags(GameObject.FlagField.WasHarvested);
harvestable.RemoveComponent<HarvestableComponent>();
ths.PostHarvestHarvestable(actor, harvestable);
return flag;
}
harvestable.Destroy();
return flag;
}
示例3: WhenComponentIsRemovedThenExecutionOrderIsUpdated
public void WhenComponentIsRemovedThenExecutionOrderIsUpdated()
{
var updateOrder = new List<int>();
DualityApp.AppData = new DualityAppData();
Scene.SetComponentExecutionOrder(typeof(ComponentTwo), typeof(ComponentOne), typeof(ComponentThree));
var gameObject = new GameObject();
gameObject.AddComponent(new ComponentOne(updateOrder));
gameObject.AddComponent(new ComponentTwo(updateOrder));
gameObject.AddComponent(new ComponentFour(updateOrder));
Scene.Current.AddObject(gameObject);
gameObject.RemoveComponent<ComponentOne>();
Scene.Current.Update();
Assert.True(updateOrder.SequenceEqual(new[] { 2, 4 }));
}