Exemplo n.º 1
0
        /// <summary>
        /// Change the color of a saber.
        /// </summary>
        /// <param name="_">The saber.</param>
        /// <param name="color">The color to change the saber to.</param>
        /// <param name="smc">The model controller of the saber.</param>
        /// <param name="tintColor">The tint color of the new color.</param>
        /// <param name="setSaberGlowColors">The glow color groups of the saber.</param>
        /// <param name="setSaberFakeGlowColors">The fake glow color groups of the saber.</param>
        /// <param name="light">The light of the saber.</param>
        public static void ChangeColor(this Saber _, Color color, SaberModelController smc, Color tintColor, SetSaberGlowColor[] setSaberGlowColors, SetSaberFakeGlowColor[] setSaberFakeGlowColors, TubeBloomPrePassLight light)
        {
            Accessors.TrailColor(ref Accessors.SaberTrail(ref smc)) = (color * tintColor).linear;

            for (int i = 0; i < setSaberGlowColors.Length; i++)
            {
                setSaberGlowColors[i].OverrideColor(color);
            }
            for (int i = 0; i < setSaberFakeGlowColors.Length; i++)
            {
                setSaberFakeGlowColors[i].OverrideColor(color);
            }
            if (light != null)
            {
                light.color = color;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the color of a saber.
        /// </summary>
        /// <param name="saber">The saber to get the color of.</param>
        /// <returns></returns>
        public static Color GetColor(this Saber saber)
        {
            if (saber is IColorable saberColorable)
            {
                return(saberColorable.Color);
            }
            SaberModelController modelController = saber.gameObject.GetComponentInChildren <SaberModelController>(true);

            if (modelController is IColorable)
            {
                var colorable = modelController as IColorable;
                return(colorable.Color);
            }
            else if (modelController is SaberModelController smc)
            {
                return(Accessors.TrailColor(ref Accessors.SaberTrail(ref smc)).gamma);
            }
            return(Color.white);
        }