I’ve been struggling with this one for months. It has made me stop working on this game altogether (as have other things).

First off, the problem doesn’t make much sense. I’m using equivalent logic to handle the positioning of some elements in one view as I am in another.

The game is the latest iteration of my resource management sim idea. Villagers get assigned to work stations that produce resources the villagers need to survive. Use of resources varies with how the villagers are allocated (more wear and energy used if working, etc), and with events that occur (colder weather means more firewood consumed, etc.).

The amount of villagers, buildings, research, and stocks available expand and contract with unlocks, arrivals, deaths, consumption, production, etc., and positioning needs to be dynamic to handle the display elements properly (we don’t want gaps between the displays).

What I’ve done is created a scroll rect for these objects. The objects are generated and positioned relative to the other objects in the scroll rect, with offsets and container sizes determined by the current amount of objects that exist. I used the same patterns for buildings, research, villagers, and stocks. The class objects all extend the same abstract class that handles the positioning logic. In fact, buildings and research objects use the exact same code. The prefabs are also identical in regards to relative positioning. And yet, these things are not displaying the same way. Buildings show up somewhere in the middle, but at least they’re on the screen. Research objects show up below the screen. Stocks and Villagers have separate but nearly equivalent code, and behave differently from each other: villagers are behaving exactly as I want, showing up in a list extending downward from the top of the view object, but stocks, like research, are below the screen.

I’m going to try to bring Stocks in alignment with Villagers to see if the stocks logic is the source of the problem. I may even be able to combine the prefabs for these.

TEST UPDATE TO MAIN BLOG