如何获得对象例如眼睛的屏幕位置

问题描述

是否可以获取场景中对象的像素位置?很明显,SparkAR内部知道在哪里绘制对象,因此它们是否提供使用此信息的界面?

解决方法

我认为您可以为此使用override fun onMessageReceived(remoteMessage: RemoteMessage) { super.onMessageReceived(remoteMessage) val soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION) val textStyle = NotificationCompat.BigTextStyle() val title: String val body: String if (remoteMessage.data.isNullOrEmpty()) { title = remoteMessage.notification?.title ?: "" body = remoteMessage.notification?.body ?: "" } else { title = remoteMessage.data["title"] ?: "" body = remoteMessage.data["message"] ?: "" } val notificationBuilder = NotificationCompat.Builder(this,getString(R.string.default_notification_channel_id)) .setContentTitle(title) .setContentText(body) .setPriority(NotificationCompat.PRIORITY_DEFAULT) .setStyle(textStyle) .setSound(soundUri) .setSmallIcon(R.drawable.ic_notification_icon) .setAutoCancel(true) // Dismiss the notification on click. val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager // Since android Oreo notification channel is needed. setupChannels(notificationManager,notificationBuilder) // Create pending intent,mention the Activity which needs to be triggered // when user clicks on notification. val notificationId = Random.nextInt() navigateToScreen(notificationBuilder,notificationId,remoteMessage) val notification = notificationBuilder.build() notificationManager.notify(notificationId,notification) } private fun setupChannels(notificationManager: NotificationManager,notificationBuilder: NotificationCompat.Builder) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val channelId = getString(R.string.default_notification_channel_id) val channel = NotificationChannel(channelId,"title",NotificationManager.IMPORTANCE_DEFAULT).apply { description = "body" enableLights(true) enableVibration(true) lightColor = Color.CYAN lockscreenVisibility = Notification.VISIBILITY_PUBLIC canShowBadge() setShowBadge(true) } notificationManager.createNotificationChannel(channel) notificationBuilder.setChannelId(channelId) } } private fun navigateToScreen(notificationBuilder: NotificationCompat.Builder,notificationId: Int,remoteMessage: RemoteMessage) { val intent = getNavigationIntent(remoteMessage) val pendingIntent = PendingIntent.getActivity(this,intent,PendingIntent.FLAG_UPDATE_CURRENT) notificationBuilder.setContentIntent(pendingIntent) } private fun getNavigationIntent(remoteMessage: RemoteMessage): Intent { val intent = Intent(this,MainActivity::class.java) intent.putExtra("screen",remoteMessage.data["screen"]) return intent }