Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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.

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

I need help with unity/webgl Canvases 0 Answers

How to make updates? 1 Answer

CharacterController (Unity) not jumping near objects 0 Answers

how to make a procedural broken lane using visual scripting ? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges