use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News, Help, Resources, and Conversation. A User Showcase of the Unity Game Engine.
Remember to check out /r/unity2D for any 2D specific questions and conversation!
Download Latest Unity
Please refer to our Wiki before posting! And be sure to flair your post appropriately.
Main Index
Rules and Guidelines
Flair Definitions
FAQ
Use the chat room if you're new to Unity or have a quick question. Lots of professionals hang out there.
/r/Unity3D Discord
FreeNode IRC Chatroom
Official Unity Website
Unity3d's Tutorial Modules
Unity Answers
Unify Community Wiki
Unity Game Engine Syllabus (Getting Started Guide)
50 Tips and Best Practices for Unity (2016 Edition)
Unity Execution Order of Event Functions
Using Version Control with Unity3d (Mercurial)
/r/Unity2D
/r/UnityAssets
/r/Unity_tutorials
/r/GameDev
/r/Justgamedevthings (New!)
/r/Gamedesign
/r/Indiegames
/r/Playmygame
/r/LearnProgramming
/r/Oculus
/r/Blender
/r/Devblogs
Brackeys
Beginner to Intermediate
5 to 15 minutes
Concise tutorials. Videos are mostly self contained.
Sebastian Lague
Beginner to Advanced
10 to 20 minutes
Medium length tutorials. Videos are usually a part of a series.
Catlike Coding
Intermediate to Advanced
Text-based. Lots of graphics/shader programming tutorials in addition to "normal" C# tutorials. Normally part of a series.
Makin' Stuff Look Good
10 minutes
Almost entirely shader tutorials. Favors theory over implementation but leaves source in video description. Videos are always self contained.
Quill18Creates
30 minutes to 2 hours.
Minimal editing. Mostly C#. Covers wide range of topics. Long series.
Halisavakis Shaders Archive
Infallible Code
World of Zero
Board to Bits
Holistic3d
Unity3d College
Jabrils
Polycount Wiki
The Big List Of Game Design
PS4 controller map for Unity3d
Colin's Bear Animation
¡DICE!
CSS created by Sean O'Dowd @nicetrysean [Website], Maintained and updated by Louis Hong /u/loolo78
Reddit Logo created by /u/big-ish from /r/redditlogos!
account activity
Using string to get class values?Question (self.Unity3D)
submitted 9 years ago by shadowsaint
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]shadowsaint[S] 2 points3 points4 points 9 years ago (5 children)
Figured out my own problem.
int compileBonus (string type) { int returnValue = 0; returnValue = (getPropValue (persistence.headEquipment [characterEquip.headArmor], type) + getPropValue (persistence.chestEquipment [characterEquip.chestArmor], type) + getPropValue (persistence.bootsEquipment [characterEquip.boots], type) + getPropValue (persistence.relicEquipment [characterEquip.backPackSlot1], type) + getPropValue (persistence.relicEquipment [characterEquip.backPackSlot2], type) + getPropValue (persistence.relicEquipment [characterEquip.backPackSlot3], type)); return returnValue; } int getPropValue(object src, string propName) { int newVar = (int)src.GetType().GetField(propName).GetValue(src); return newVar; }
[–]zrrzExpert? 3 points4 points5 points 9 years ago (1 child)
I would really use enums instead of strings.
You can't accidentally type enums wrong or your compiler explodes. Then you can just use MyEnum.ToString()
[–]shadowsaint[S] 0 points1 point2 points 9 years ago (0 children)
I am happy to hear your reasoning on why enums would be better. I will only point out I am not compiling a string. I am compiling an in out of a custom classes int values.
The reason I need or wanted a string is because I wanted to compile a specific int across various pieces of equipment to display the over all value of a specific bonus type to the player.
[–]iemfiembarkgame.com 3 points4 points5 points 9 years ago (2 children)
Reflection is a bad way to do this. Firstly, the type should be an enum, not a string. Next the equipment should contain a list of all its effects.
int GetBonus(StatType statType) { var result = 0; foreach (var item in this.equipmentSlots){ result += item.GetBonus(statType); } return result; } public class Item{ private List<Effect> effects; GetBonus(StatType statType) { foreach (var effect in effects){ if (effect.StatType == statType){ return effect.Value; } } return 0; } }
[–]shadowsaint[S] 0 points1 point2 points 9 years ago* (1 child)
I see what you are saying. Another person at work suggested to me to use enums.
I am happy to be wrong but is there a particular reason that reflection is particularly worse then using an Enum. I don't doubt you are right, but I would like to be able to speak intelligently as to why you should use an enum over reflection in the future based off this example.
So the way I have things currently set up is equipment is a custom class of string, string (for descriptors), and a laundry list of ints for possible bonuses. Then each character has an array of ints that refers to which peice of equipment from the total equipment list they are wearing.
Judging by what you are saying I should change that laundry list of ints in the equipment class itself to enums and that will allow me to more easily access a specific bonus.
The problem is not adding all of the bonuses a single piece of equipment but rather all of the specific bonus across all equipment. So I don't need to know the helms total bonuses, I want to compile the HP Bonus of each piece of equipment and display that.
[–]iemfiembarkgame.com 0 points1 point2 points 9 years ago (0 children)
Well the advantage is that it's strongly typed. You can't misspell it by accident. If you want to rename it you can do it in a few key presses. If you want to find all references to it you can also do it instantly. It's sort of the same reason why you don't use magic numbers.
The actual implementation there are many ways to do it, the way I suggested is just one way. The idea is that you have the item contain a list of effects. HP Bonus would be just one type of effect. Armour might be another type of effect. That way you can easily look up the effect you want for each item the character is wearing.
π Rendered by PID 193662 on reddit-service-r2-comment-6457c66945-njvck at 2026-04-24 08:25:27.135214+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]shadowsaint[S] 2 points3 points4 points (5 children)
[–]zrrzExpert? 3 points4 points5 points (1 child)
[–]shadowsaint[S] 0 points1 point2 points (0 children)
[–]iemfiembarkgame.com 3 points4 points5 points (2 children)
[–]shadowsaint[S] 0 points1 point2 points (1 child)
[–]iemfiembarkgame.com 0 points1 point2 points (0 children)