I have a prefab of a store. This store has a count integer in it to signify how many things the store is holding. But this prefab populates many stores with different int values. So store one could have 3 items while store 2 has 40 items and so forth. I need a way to add all of those up and use it in another script. I don't even know where to start. An answer would be ideal but if not just a nudge in the right direction would be greatly appreciated. Thank you in advance.
How do you get an int from a prefab?
295 Views Asked by giff1 At
1
There are 1 best solutions below
Related Questions in C#
- Passing arguments to main in C using Eclipse
- kernel module does not print packet info
- error C2016 (C requires that a struct or union has at least one member) and structs typedefs
- Drawing with ncurses, sockets and fork
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- Configured TTL for A record(s) backing CNAME records
- Allocating memory for pointers inside structures in functions
- Finding articulation point of undirected graph by DFS
- C first fgets() is being skipped while the second runs
- C std library don't appear to be linked in object file
- gcc static library compilation
- How to do a case-insensitive string comparison?
- C programming: Create and write 2D array of files as function
- How to read a file then store to array and then print?
- Function timeouts in C and thread
Related Questions in UNITY-GAME-ENGINE
- Using arrow keys to rotate an object
- know object behind another object is fully visible
- Unity3d AudioSource not creatable
- Unity3d - Input.GetKey returns true more than once
- Flurry Ads on Unity3D with Prime31 plugin
- Make screenshot of DirectX window that is hidden and doesn't have focus
- Coroutine being detected as inactive despite being active
- Unity3D: Adding charged force in relation to position
- Unity - Particles emitting non-random
- 3d mouse aim camera 3rd person vertical C#
- Unity: How would I go about creating a power up system?
- Unity - Gui Button issues (Android)
- Unity3d strange Collider behaviour
- Start() function doesn't work properly after Application.LoadLevel
- Gravity works weird
Related Questions in PREFAB
- Using purchased prefabs in Unity's UI Toolkit (ui builder)
- broken material and shader graph settings after I combined prefabs from different projects
- How to load a prefab with Resources.Load() in unity?
- Rigidbody 2D doesn't stop
- prevent an Instantiated prefab to be re-Instantiate if it exist 2D Game in C#
- How can I export prefab or an object in Unity runtime as FBX files? I want to select objects and export as FBX in runtime. I need the way(script)
- Why more balls are instantiating?
- How do you get an int from a prefab?
- How do I restrict one random prefab to be used only once but placed randomly with a whole bunch of prefabs of arrays on top of other object?
- Bold text in prefab info in inspector - Unity
- How to duplicate, reuse, and dispose of dynamically generated addressable objects
- Unity instantiate object at a certain direction based of a spatial anchor
- Layer or hierarchy problem for GameObject
- How to scale instantiated prefab objects in unity to fit different screen sizes
- How to click on instantiated objects and get points, then link points to score text?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Fill in the
YourScriptHerewith the class name of the script you are trying to find. It will grab all occurrences of the prefab in the scene then add the value you have set. Replace thetheValueHerewith whatever the integer field you have setup. If you are looking to add up editor objects, that is a different approach which I can edit the answer if that is the case.The other approach is having a manager that has all references to each of these objects so you do not need to call
FindObjectsOfTypeAll. If these values change during runtime and you want to recalculate it, I would either assign the references in the inspector or store the references. In case some of these objects are destroyed or new ones are instantiated, I would consider using aHashSetwhen storing the references.