/// <summary> /// Applies a random bone skin and color from the given color collection to the given renderer /// based on the given randomseed. /// </summary> public void ApplyRandom( SpriteRenderer renderer, ColorCollection[] colors, int randomSeed ) { #if UNITY_EDITOR Assert.NotNullOrEmpty( boneSkins, "ApplyRandom to an empty boneSkinSet ("+ name +")."); Assert.NotNullOrEmpty( colors, "ApplyRandom with an empty or null color set to " + name ); #endif Random.seed = randomSeed; boneSkins[ Random.Range( 0, boneSkins.Length ) ].Apply( renderer, colors, randomSeed ); }
/// <summary> /// Apply the configuration to the specified renderer and picks a random color /// from the provided colorSet. If the colorSet property of the BoneConfiguration /// is not defined, the default color will be assigned. /// </summary> public void Apply( SpriteRenderer renderer, ColorCollection[] colors, int randomSeed ) { renderer.sprite = spriteAsset; renderer.gameObject.transform.localPosition = translation; renderer.gameObject.transform.localScale = scale; renderer.gameObject.transform.rotation = Quaternion.Euler( rotation ); if ( colorSet >= 0 ) { renderer.color = colors[ colorSet ].SelectRandomColor( randomSeed ); } else { renderer.color = defaultColor; } }