我在统一复制门时遇到问题 [英] I have a problem on duplicating a door in unity

查看:28
本文介绍了我在统一复制门时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试统一复制我的门.但是,当我尝试这样做时,只有原始门正在执行诸如打开和关闭之类的动画.我有一个 UI 按钮,它使用操作门的 OnClick 功能.当我输入触发器时它会弹出.

I am trying to duplicate my door in unity. but, when I try doing it only the original door is doing the animation like Opening and closing. I have a UI button that uses OnClick function that operates the door. It pops up when I enter the trigger.

这是带有 OnClick 功能的按钮 UI

我已经尝试为每扇门制作一个新的 UI,但我知道有一种方法可以让我只需要为多个门使用一个 UI.我只是不知道如何.

I've tried to make a new UI for each door, but I know that there is a way to make it so that I just need to use one UI for multiple doors. I just don't know how.

     private Animator Animatooor;
     public GameObject DoorCollider;
     public GameObject DoorUI;
     public GameObject DoorUICLose;
     void Start()
     {
         Animatooor = transform.parent.GetComponentInParent<Animator>();
         Animatooor.SetBool("Open", false);
         DoorCollider.SetActive(true);

     }


     public void Open()
     {
         Animatooor.SetBool("Open", true);

     }
     public void Close()
     {
         Animatooor.SetBool("Open", false);
     }
     void OnTriggerEnter(Collider hit)
     {
         if (hit.gameObject.CompareTag("Player"))
         {
             DoorUI.SetActive(true);
             DoorUICLose.SetActive(true);
         }

     }
     void OnTriggerExit(Collider Hit)
     {
         if (Hit.gameObject.CompareTag("Player"))
         {
             DoorUI.SetActive(false);
             DoorUICLose.SetActive(false);
         }
     }

抱歉,如果我粘贴了所有代码,我只是不知道我的问题的解决方案是什么.我想复制门并只使用原始门的 UI 按钮.

Sorry if I paste all of my code, I just don't know what is the solution on my problem. I want to duplicate the door and use just the UI button of the original door.

提前致谢!

推荐答案

在那里按下 On Click () 下的加号,并有另一个类似的条目,但用于第二个门.

Press the plus under On Click () there and have another entry just like that, but for the second door.

目前它连接到附加到门 1 的触发...组件实例.门 2 不知道.Door 2 的触发...组件实例也应该得到类似的通知.因此需要在这里 OnClick 下的第二个条目.

At the moment this is connected to the Trigge... component instance that is attached to door 1. Door 2 has no idea. Door 2's Trigge... component instance should be similarly notified. Hence the need for the second entry under OnClick here.

这篇关于我在统一复制门时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆