يوضّح هذا الدليل كيفية نقل لعبتك على Unity لاستخدام أحدث إصدار من حزمة تطوير البرامج (SDK) الخاصة بأداة Input. تتضمّن حزمة تطوير البرامج (SDK) 1.0.0-beta تحسينات كبيرة مقارنةً بالنسخة الحصرية السابقة 0.0.4. ننصحك بنقل البيانات من الإصدارات التجريبية السابقة في أقرب وقت ممكن. سيستمر عمل حزمة تطوير البرامج (SDK) 0.0.4 حتى مارس 2023.
تعديل المراجع
تمت إضافة البادئة Play إلى الفئات لتجنُّب تعارض الأسماء مع Unity.
عندما تظهر لك رسالة خطأ مشابهة لما يلي:
error CS0246: The type or namespace name 'InputMappingProvider' could not be found (are you missing a using directive or an assembly reference?)
يجب إضافة البادئة Play إلى اسم الفئة. على سبيل المثال، يصبح InputMappingProvider هو PlayInputMappingProvider.
تعديل كل InputAction
يتم الآن إنشاء InputAction من خلال طلب PlayInputAction.Create بدلاً من إنشاء struct جديد مع حقول مسماة.
ابحث عن أي رمز يستدعي new InputAction:
var driveAction = new InputAction
{
ActionLabel = "Drive",
UniqueId = (int)InputEventIds.DRIVE,
InputControls = new InputControls
{
AndroidKeycodes = new[] { AndroidKeyCode.KEYCODE_SPACE }
}
};
واستبدِلها بمكالمة إلى PlayInputAction.Create:
var driveAction = PlayInputAction.Create(
"Drive",
(int)InputEventIds.DRIVE,
PlayInputControls.Create(
new[] { AndroidKeyCode.KEYCODE_SPACE },
null
)
);
تعديل كل InputGroup
مثل InputAction، أصبح بإمكان InputGroup إجراء مكالمة PlayInputGroup.Create بدلاً من طلب ملء struct يدويًا.
يعني ذلك أنّه عليك تحديد أي طلبات إلى new InputGroup:
var gameInputGroup = new InputGroup
{
GroupLabel = "Game controls",
InputActions = new List<InputAction>
{
driveAction,
turboAction,
openGarageAction,
openStoreAction
}
};
واستبداله بمكالمة إلى PlayInputGroup.Create:
var gameInputGroup = PlayInputGroup.Create(
"Game controls",
new List<PlayInputAction>
{
driveAction,
turboAction,
openGarageAction,
openStoreAction
}
);
تعديل InputMap
تستخدِم InputMap PlayInputMap.Create أيضًا بدلاً من إنشاء بنية جديدة.
تحديد موقع أي مكالمات إلى new InputMap:
return new InputMap
{
InputGroups = new List<InputGroup>
{
gameInputGroup,
menuInputGroup
},
MouseSettings = new MouseSettings
{
AllowMouseSensitivityAdjustment = false,
InvertMouseMovement = false
}
};
واستبدِلها بمكالمة إلى PlayInputMap.Create:
return PlayInputMap.Create(
new List<PlayInputGroup>
{
gameInputGroup,
menuInputGroup
},
PlayMouseSettings.Create(false, false)
);
إعادة تسمية طرق PlayInputMappingClient
تم تغيير اسم RegisterInputMappingProvider إلى SetInputMappingProvider في PlayInputMappingClient.
لذا، ابحث عن أي مكالمات إلى RegisterInputMappingProvider:
Input.GetInputMappingClient().RegisterInputMappingProvider(_inputMappingProvider);
واستبدِلها بطلب إجراء مكالمة إلى SetInputMappingProvider:
PlayInputMappingClient inputMappingClient =
Google.Play.InputMapping.PlayInput.GetInputMappingClient();
inputMappingClient.SetInputMappingProvider(_inputMapProvider);
تمّت أيضًا إعادة تسمية UnregisterInputMappingProvider إلى ClearInputMappingProvider، ولم يعُد يتطلّب InputMappingProvider الذي سبق أن سجّلته كمعلّمة.
تحديد موقع أي مكالمات إلى UnregisterInputMappingProvider:
Input.GetInputMappingClient().UnregisterInputMappingProvider(_inputMapProvider);
واستبدِلها بـ ClearInputMappingProvider:
PlayInput.GetInputMappingClient().ClearInputMappingProvider();