jjzjj

messageObj

全部标签

c# - Unity 给 child 添加 child ,但在顶部

我正在尝试将一个子对象添加到子集合中,但我想确保最新的将是第一个。这是我正在尝试做的事情:GameObject-(Mynewobjecthere)-GameObject-GameObject-GameObject这是我用来实例化预制件的代码:GameObjectmessageObj=Instantiate(storyPrefab)asGameObject;messageObj.name="Story";messageObj.transform.parent=wallGrid.transform;messageObj.transform.localScale=newVector3(1,1

c# - 太多 if (obj is thisObj) 语句

我目前有一种方法试图找出它收到的对象是什么。它知道在某个接口(interface)上,例如IService,但我有代码查看它并试图告诉我它是Service1还是Service2。我目前有很多if(objisthisObj)样式语句,什么是使这段代码漂亮的最佳解决方案?这是我所拥有的示例:publicvoidDoSomething(IServiceservice){if(serviceisService1){//DOsomething}if(serviceisService2){//DOsomethingelse}}现在有两个并不是什么坏事,但我正在考虑可能有20多个这样的东西,使用起来