Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sets amount of prop variations and calculates equal probability.
//----------------------------------------------------------------
// Prop Variation Amount Changer
//Set amount of prop variations.
//If you are increasing the amount, previous variations will be preserved.
//If decreasing, all variations will be removed!
var variations = 12; //CHANGE THIS
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
if(variations!=asset.m_variations.Length)
{
PropInfo.Variation[] temp = new PropInfo.Variation[variations];
if(asset.m_variations.Length<variations) asset.m_variations.CopyTo(temp, 0);
asset.m_variations = temp;
UnityEngine.Object.FindObjectOfType<DecorationPropertiesPanel>().Refresh();
}
else Debug.LogWarning("Amount of variations already is " + variations.ToString());
//----------------------------------------------------------------
// Prop Variation Equal Probability Calculator
//Automatically calculate equal probability for all variations.
//The formula is 100 divided by (variation amount + 1), then rounded down.
//Empty variations can't have probability,
//so run this after you have added all your variations.
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
var variations = asset.m_variations.Length;
var probability = (int)Math.Floor(100f/(variations+1));
for(uint i = 0; i < variations; i++) asset.m_variations[i].m_probability=probability;
UnityEngine.Object.FindObjectOfType<DecorationPropertiesPanel>().Refresh();
@hgb0607

This comment has been minimized.

Copy link

@hgb0607 hgb0607 commented Nov 29, 2020

bug:Can only be random between the main prop and the first variations prop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment