Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Quick Reply
Search this Thread
Field Researcher
Original Poster
#1 Old 30th Jun 2022 at 8:03 AM
Default Setting an object to a preset by code
Hi everyone,
I am trying to set a gameobject to a BuildBuy preset, but I can't figure out how it is done.
I can't really imagine there is no way, somehow the game loads the presets when in build buy and applies them when clicking, right?
From what I can understand the presets are in the OBJD under Materials numbered from Materials[0] to Materials[7], they have to get loaded into the game as something.
If anyone can share any insights into this and if it just explaining how presets are build from an objects creators perspective so I can better understand I would be so happy.
Thank you and have a nice day
Snow
Advertisement
Virtual gardener
staff: administrator
#2 Old 30th Jun 2022 at 1:00 PM
Hey!

Zoe and I at sopme point went through this as well it's really not an easy one to figure out, but the sleeping bag does have a way to "select" presets in code (Assuming you mean like the pre-made colour items)

bascially, it's something like so:

Code:
				SortedList<string, bool> sortedList = new SortedList<string, bool>();
				SortedList<string, Complate> originalPatterns = Complate.ExtractPatterns(base.Target.ObjectId, sortedList);
				SleepingBag sleepingBag = base.Target as SleepingBag;
				if (sleepingBag != null)
				{
					sleepingBag.SetComplates(sortedList, originalPatterns);
				}

// then just add this to your project:

public void SetComplates(SortedList<string, bool> originalStencils, SortedList<string, Complate> originalPatterns)
	{
		bool flag = true;
		ResourceKey resourceKey = base.GetResourceKey();
		ContentSourceType contentSource = DownloadContent.GetContentSource(resourceKey);
		if (contentSource == ContentSourceType.kContentType_Download)
		{
			string presetString = UserToolUtils.GetPresetString(resourceKey);
			ObjectDesigner.SetPresetInfo(base.ObjectId, presetString);
			flag = false;
		}
		if (flag)
		{
			ObjectDesigner.ClearObjectDesignPreset(base.ObjectId);
		}
		DesignModeSwap designModeSwap = Complate.SetupDesignSwap(base.ObjectId, originalPatterns, false, originalStencils);
		if (designModeSwap != null)
		{
			designModeSwap.ApplyToObject();
		}
	}


I'm not 100% sure how it works, but this should give you a base to work with though
Field Researcher
Original Poster
#3 Old 30th Jun 2022 at 1:22 PM
Ah so I was at the right class this morning when I was looking through designModeSwap. But I dismissed it for some reason. THANK YOU!!!!
Field Researcher
Original Poster
#4 Old 30th Jun 2022 at 1:36 PM
One more question: how do i select which preset?
Field Researcher
Original Poster
#5 Old 30th Jun 2022 at 3:24 PM
i have figured out everything except how to get a list of all presets ingame. So here is my a bit hacky method:


Field Researcher
Original Poster
#6 Old 30th Jun 2022 at 6:01 PM
So I figured out the not hacky method and it is pretty simple:


Back to top