本文整理汇总了C#中Fish.GetComponents方法的典型用法代码示例。如果您正苦于以下问题:C# Fish.GetComponents方法的具体用法?C# Fish.GetComponents怎么用?C# Fish.GetComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fish
的用法示例。
在下文中一共展示了Fish.GetComponents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertToFishGenerateWhenEnterWorld
static void ConvertToFishGenerateWhenEnterWorld(Fish fishInScene)
{
if (AssetDatabase.Contains(fishInScene))
return;
//ɾ���Ӷ���
//int a = fishInScene.transform.childCount;
int fishChildCount = fishInScene.transform.GetChildCount();
for (int i = 0; i != fishChildCount; ++i)
DestroyImmediate(fishInScene.transform.GetChild(0).gameObject);
//����gameobject���ֲ�����prefab
Fish f = (Fish)AssetDatabase.LoadAssetAtPath("assets/prefab/fish/" + fishInScene.gameObject.name + ".prefab", typeof(Fish));
if (f == null)
f = (Fish)AssetDatabase.LoadAssetAtPath("assets/prefab/FishQueue/" + fishInScene.gameObject.name + ".prefab", typeof(Fish));
//����FishGenerateWhenEnterWorld
FishGenerateWhenEnterWorld fishGenerate = fishInScene.gameObject.AddComponent<FishGenerateWhenEnterWorld>();
if (f != null)
{
fishGenerate.Prefab_Fish = f;
}
else
{
Debug.LogWarning("[����]����ԴĿ¼���Ҳ�������prefab,���ֶ������ϷŽ�prefab_Fish������.", fishInScene.gameObject);
}
//���������
Component[] cmps = fishInScene.GetComponents<Component>();
foreach (Component c in cmps)
{
if (c.GetType() != typeof(Transform) && c.GetType() != typeof(FishGenerateWhenEnterWorld))
{
DestroyImmediate(c);
}
}
}