question

vistriter avatar image
vistriter asked

how to covert item to item object in Unity ?

I want to convert Item to Item Object. My class item have atk point and hp point.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Can you provide any more context on this? Do you mean when you get results from the service, or copying elements from an object which is one class to an object which is of a different class? Generally speaking, some form of copy constructor would be used for the latter.

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

vistriter avatar image vistriter commented ·

In my understanding, this method is right?

0 Likes 0 ·
brendan avatar image brendan vistriter commented ·

I'd have to say that I don't think this will work, as I'm seeing a mix of concepts. Can you provide more info on your "Item" class? In the code above, you're mapping CustomData, which is a string containing just the custom data elements of a single item in the catalog to an "Item" - can you provide more details on that class in your project? Generally speaking, an item instance is an instance in a player's inventory - not the generic catalog definition (or, in this case, the custom data of that definition). Also, I'm not sure what ObjectSlug is, or how the ItemDatabase is defined in the project. Can you please clarify these components?

0 Likes 0 ·
vistriter avatar image vistriter commented ·

Thank you for your suggestions. It's work!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.