我看到unity按钮具有似乎是OnClick事件。我试图用这样的OnClick创建自己的自定义按钮:
dependencies {
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.google.android.gms:play-services-plus:15.0.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.github.Hitomis:CircleMenu:v1.1.0'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.mindorks:placeholderview:0.2.7'
implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.github.amlcurran.showcaseview:library:5.4.3'
implementation 'com.pacioianu.david:ink-page-indicator:1.2.0'
implementation 'com.github.zcweng:switch-button:0.0.3@aar'
// Google
implementation 'com.google.android.gms:play-services-auth:15.0.1'
// Firebase
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.firebaseui:firebase-ui-database:1.2.0'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'de.hdodenhof:circleimageview:1.3.0'
implementation 'com.codemybrainsout.onboarding:onboarder:1.0.4'
implementation 'com.google.android.gms:play-services-vision:15.0.2'
implementation 'com.huxq17.android:SwipeCardsView:1.3.5'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.airbnb.android:lottie:2.5.4'
}
apply plugin: 'com.google.gms.google-services'
但是当我这样做时,这些属性不会显示在Unity UI中。我该怎么做才能创建自己的自定义控件,该控件具有这样的事件属性,可以通过UI类似于Button来对其进行操作?
答案 0 :(得分:0)
您不太可能能够轻松地复制Unity内置UI.Button
类的行为。
让我们看一下the documentation。
UnityEngine.UI
中的类
继承自:UI.Selectable
实现接口:IEventSystemHandler
,IPointerClickHandler
,ISubmitHandler
那是相当的等级!
您可能需要扩展并实现所有这些方法您自己,或者您可以直接扩展UI.Button
并利用已经完成的所有工作来使按钮变得纽扣
答案 1 :(得分:-1)
我大胆地猜测,并尝试了以下方法,该方法有效:
public UnityEvent OnClick;