• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Gascoine_17 · Feb 01, 2017 at 09:11 AM · game developmentchess

How do I create dictionary with 3D Objects?

I'm currently trying to convert this 2D code (sprite) to 3D (3D game objects), but I don't know how. Can anyone tell me how to convert these things? This is the code

 void InitializeSpriteDictionary() {
     
     spriteDictionary = new Dictionary<char, Sprite> ();
     spriteDictionary.Add (' ', none);

     spriteDictionary.Add ('r', blackRook);
     spriteDictionary.Add ('n', blackKnight);
     spriteDictionary.Add ('b', blackBishop);
     spriteDictionary.Add ('q', blackQueen);
     spriteDictionary.Add ('k', blackKing);
     spriteDictionary.Add ('p', blackPawn);

     spriteDictionary.Add ('R', whiteRook);
     spriteDictionary.Add ('N', whiteKnight);
     spriteDictionary.Add ('B', whiteBishop);
     spriteDictionary.Add ('Q', whiteQueen);
     spriteDictionary.Add ('K', whiteKing);
     spriteDictionary.Add ('P', whitePawn);
 }
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Cherno · Feb 01, 2017 at 07:15 PM 0
Share

As far as Unity is concerned, "Sprites" are 3d objects, too, meaning they exist in 3d space. The renderer ($$anonymous$$eshRenderer, SpriterRenderer) defines how the object is rendered. So, either the objects have a SpriteRenderer or $$anonymous$$eshRenderer (or Skinned$$anonymous$$eshrenderer). You can't automatically convert from one to the other, it would require removing and adding components and creating new materials.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Glurth · Feb 01, 2017 at 07:24 PM

Regarding the dictionary code, I suspect you will simply want to replace "Sprite" (a flat image) with "Mesh" (a collection of 3D verticies, that makes up a set of triangles, and info about them). Obviously, you will also need to change all those sprite references, like "whiteRook", into Mesh references. e.g.

(dictionary creation)

 meshDictionary = new Dictionary<char, Mesh> ();

(mesh reference declaration)

 public Mesh whiteRook;


A Mesh, just like a sprite, can be stored as "Assets" in your project folder. Usually they are created in another program, and imported.

https://docs.unity3d.com/ScriptReference/Mesh.html

Edit: I think Cherno's comments are referring to the next step, changing the scene objects to render Meshes, rather than sprites, and I agree.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Creating a board and naming each piece. 1 Answer

How do I make a third to first person transition 2 Answers

Floor / ground that you can send a wave through 0 Answers

What should I do after creating a prototype for my game? 1 Answer

How Can I Copy My Gameobject To Other Scene How Can I Copy Gameobject to different scene 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges