public SceneObject Create(int id, Vector3 pos) { ResActor data = DataReader <ResActor> .Get(id); if (data == null) { return(null); } Object cPrefab; GameObject model; SceneObject obj = null; switch ((EActorType)data.type) { case EActorType.Hero: cPrefab = CResourceSys.Instance.LoadRole(data.prefab); if (cPrefab == null) { return(null); } model = ObjectPoolSys.Instance.Create(cPrefab); obj = model.AddUniqueComponent <Hero>(); obj.transform.parent = HeroRoot; (obj as Hero).position = pos; (obj as Hero).Data = data; obj.EnterScene(); break; case EActorType.Monster: cPrefab = CResourceSys.Instance.LoadRole(data.prefab); if (cPrefab == null) { return(null); } model = ObjectPoolSys.Instance.Create(cPrefab); obj = model.AddUniqueComponent <Monster>(); obj.transform.parent = MonsterRoot; (obj as Monster).position = pos; (obj as Monster).Data = data; obj.EnterScene(); break; case EActorType.GunItem: cPrefab = CResourceSys.Instance.LoadItem(data.prefab); if (cPrefab == null) { return(null); } model = ObjectPoolSys.Instance.Create(cPrefab); obj = model.AddUniqueComponent <GunItem>(); obj.transform.parent = ItemRoot; obj.transform.position = pos; (obj as GunItem).SetSkill(data.skills[0]); obj.EnterScene(); break; case EActorType.ExpendItem: cPrefab = CResourceSys.Instance.LoadItem(data.prefab); if (cPrefab == null) { return(null); } model = ObjectPoolSys.Instance.Create(cPrefab); obj = model.AddUniqueComponent <ExpendItem>(); obj.transform.parent = ItemRoot; obj.transform.position = pos; (obj as ExpendItem).SetSkill(data.skills[0]); obj.EnterScene(); break; } return(obj); }