1.0.0-बीटा इनपुट SDK टूल पर माइग्रेट करें

इस गाइड में, Unity गेम को माइग्रेट करके, उसमें Input SDK का नया वर्शन इस्तेमाल करने का तरीका बताया गया है. 1.0.0-beta SDK, पिछले 0.0.4 वर्शन से बेहतर है. इसलिए, आपको जल्द से जल्द पिछले वर्शन से माइग्रेट कर लेना चाहिए. 0.0.4 SDK, मार्च 2023 तक काम करता रहेगा.

रेफ़रंस अपडेट करना

Unity के साथ नाम टकराने से बचाने के लिए, क्लास के नामों में Play प्रीफ़िक्स जोड़ा गया है. अगर आपको इस तरह का गड़बड़ी वाला मैसेज दिखता है, तो:

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 को भी नया struct बनाने के बजाय, 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 के तरीकों के नाम बदलना

PlayInputMappingClient के लिए, RegisterInputMappingProvider का नाम बदलकर SetInputMappingProvider कर दिया गया है.

इसलिए, 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();