public static SerializableGradientColorKey[] FromGradientColorKeys(GradientColorKey[] ks)
 {
     SerializableGradientColorKey[] keys = new SerializableGradientColorKey[ks.Length];
     for(int i = 0; i < keys.Length; i++)
     keys[i] = new SerializableGradientColorKey(ks[i]);
     return keys;
 }
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.GradientColorKey o;
         UnityEngine.Color            a1;
         checkType(l, 2, out a1);
         System.Single a2;
         checkType(l, 3, out a2);
         o = new UnityEngine.GradientColorKey(a1, a2);
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 public static GradientColorKey[] ToGradientColorKeys(SerializableGradientColorKey[] incoming)
 {
     GradientColorKey[] keys = new GradientColorKey[incoming.Length];
     for(int i = 0; i < keys.Length; i++)
     keys[i] = incoming[i].ToGradientColorKey();
     return keys;
 }
Exemple #4
0
    void SetGradientColorKey()
    {
        GradientColorKey[] sck = new GradientColorKey[7];

        sck [0].color = new Color (0.33f, 0.39f, 0.44f, 1f);
        sck [0].time = 0.25f;
        sck [1].color = new Color (0.96f, 0.6f, 0.15f, 1f);
        sck [1].time = 0.26f;
        sck [2].color = new Color (0.976f, 0.816f, 0.565f, 1f);
        sck [2].time = 0.32f;
        sck [3].color = new Color (0.984f, 0.871f, 0.729f, 1f);
        sck [3].time = 0.50f;
        sck [4].color = new Color (0.976f, 0.816f, 0.565f, 1f);
        sck [4].time = 0.68f;
        sck [5].color = new Color (0.96f, 0.6f, 0.15f, 1f);
        sck [5].time = 0.74f;
        sck [6].color = new Color (0.33f, 0.39f, 0.44f, 1f);
        sck [6].time = 0.75f;

        GradientAlphaKey[] sak = new GradientAlphaKey[2];
        sak [0].alpha = 1f;
        sak [0].time = 0f;
        sak [1].alpha = 1f;
        sak [1].time = 1f;

        LightColor.SetKeys (sck, sak);
    }
Exemple #5
0
 static public int constructor(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         UnityEngine.GradientColorKey o;
         if (argc == 3)
         {
             UnityEngine.Color a1;
             checkType(l, 2, out a1);
             System.Single a2;
             checkType(l, 3, out a2);
             o = new UnityEngine.GradientColorKey(a1, a2);
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         else if (argc <= 2)
         {
             o = new UnityEngine.GradientColorKey();
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         return(error(l, "New object failed."));
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #6
0
    public void ApplyToUnityParticleSystem(UnityEngine.ParticleSystem ups, ParticleSystem ps)
    {
        var colorModule = ups.colorOverLifetime;

        var gradient = new UnityEngine.Gradient();

        gradient.mode = UnityEngine.GradientMode.Blend;
        UnityEngine.GradientColorKey[] gck = new UnityEngine.GradientColorKey[keyFrameLifeTime.Count];

        for (int i = 0; i < keyFrameLifeTime.Count; ++i)
        {
            gck[i].time  = keyFrameLifeTime[i];
            gck[i].color = new Color(r[i] / 255.0f, g[i] / 255.0f, b[i] / 255.0f);
        }
        UnityEngine.GradientAlphaKey[] gak;
        if (colorModule.enabled)
        {
            gak = colorModule.color.gradient.alphaKeys;
        }
        else
        {
            gak          = new UnityEngine.GradientAlphaKey[2];
            gak[0].time  = 0.0f;
            gak[0].alpha = 1.0f;
            gak[1].time  = 1.0f;
            gak[1].alpha = 1.0f;
        }
        gradient.SetKeys(gck, gak);
        colorModule.enabled = true;
        colorModule.color   = new UnityEngine.ParticleSystem.MinMaxGradient(gradient);
    }
Exemple #7
0
        public override object Read <T>(ES3Reader reader)
        {
            var instance = new UnityEngine.GradientColorKey();

            ReadInto <T>(reader, instance);
            return(instance);
        }
    static bool Gradient_SetKeys__GradientColorKey_Array__GradientAlphaKey_Array(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 2)
        {
            UnityEngine.GradientColorKey[] arg0 = JSDataExchangeMgr.GetJSArg <UnityEngine.GradientColorKey[]>(() =>
            {
                int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
                int length  = JSApi.getArrayLength(jsObjID);
                var ret     = new UnityEngine.GradientColorKey[length];
                for (var i = 0; i < length; i++)
                {
                    JSApi.getElement(jsObjID, i);
                    ret[i] = (UnityEngine.GradientColorKey)JSMgr.datax.getObject((int)JSApi.GetType.SaveAndRemove);
                }
                return(ret);
            });
            UnityEngine.GradientAlphaKey[] arg1 = JSDataExchangeMgr.GetJSArg <UnityEngine.GradientAlphaKey[]>(() =>
            {
                int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
                int length  = JSApi.getArrayLength(jsObjID);
                var ret     = new UnityEngine.GradientAlphaKey[length];
                for (var i = 0; i < length; i++)
                {
                    JSApi.getElement(jsObjID, i);
                    ret[i] = (UnityEngine.GradientAlphaKey)JSMgr.datax.getObject((int)JSApi.GetType.SaveAndRemove);
                }
                return(ret);
            });
            ((UnityEngine.Gradient)vc.csObj).SetKeys(arg0, arg1);
        }

        return(true);
    }
// fields

// properties
    static void Gradient_colorKeys(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.Gradient _this = (UnityEngine.Gradient)vc.csObj;
            var result = _this.colorKeys;
            var arrRet = result;
            for (int i = 0; arrRet != null && i < arrRet.Length; i++)
            {
                JSMgr.datax.setObject((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]);
                JSApi.moveSaveID2Arr(i);
            }
            JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true);
        }
        else
        {
            UnityEngine.GradientColorKey[] arg0 = JSDataExchangeMgr.GetJSArg <UnityEngine.GradientColorKey[]>(() =>
            {
                int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
                int length  = JSApi.getArrayLength(jsObjID);
                var ret     = new UnityEngine.GradientColorKey[length];
                for (var i = 0; i < length; i++)
                {
                    JSApi.getElement(jsObjID, i);
                    ret[i] = (UnityEngine.GradientColorKey)JSMgr.datax.getObject((int)JSApi.GetType.SaveAndRemove);
                }
                return(ret);
            });
            UnityEngine.Gradient _this = (UnityEngine.Gradient)vc.csObj;
            _this.colorKeys = arg0;
        }
    }
 static public int set_color(IntPtr l)
 {
     UnityEngine.GradientColorKey o = (UnityEngine.GradientColorKey)checkSelf(l);
     UnityEngine.Color            v;
     checkType(l, 2, out v);
     o.color = v;
     setBack(l, o);
     return(0);
 }
 static public int set_time(IntPtr l)
 {
     UnityEngine.GradientColorKey o = (UnityEngine.GradientColorKey)checkSelf(l);
     System.Single v;
     checkType(l, 2, out v);
     o.time = v;
     setBack(l, o);
     return(0);
 }
Exemple #12
0
        public static Texture2D TextureFromArrayHeight(double[,] data, double minValue, double maxValue)
        {
            var colours = new GradientColorKey[] {
                RGB(176, 243, 190),
                RGB(224, 251, 178),
                RGB(184, 222, 118),
                RGB(39, 165, 42),
                RGB(52, 136, 60),
                RGB(156, 164, 41),
                RGB(248, 176, 4),
                RGB(192, 74, 2),
                RGB(135, 8, 0),
                RGB(116, 24, 5),
                RGB(108, 42, 10),
                RGB(125, 74, 43),
                RGB(156, 129, 112),
                RGB(181, 181, 181),
                RGB(218, 216, 218)
            };

            colours[0].time = 0;
            colours[1].time = 0.001f;

            for (int i = 0; i < colours.Length; i++)
            {
                colours[i].time = (float)i / (float)(colours.Length - 1);
            }

            int width = data.GetLength(0);
            int height = data.GetLength(1);

            Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false);

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    float value = Mathf.Clamp01((float)((data[x, y] - minValue) / (maxValue - minValue)));
                    if (data[x, y] <= 0)
                        tex.SetPixel(x, y, new Color(0, 0, 1));
                    else
                        for(int i = 1; i < colours.Length; i++)
                        {
                            if (value < colours[i].time)
                            {
                                float lambda = (value - colours[i - 1].time) / (colours[i].time - colours[i - 1].time);
                                tex.SetPixel(x, y, Color.Lerp(colours[i - 1].color, colours[i].color, lambda));
                                break;
                            }
                        }
                }
            }

            tex.Apply();
            return tex;
        }
 static public int constructor(IntPtr l)
 {
     UnityEngine.GradientColorKey o;
     UnityEngine.Color            a1;
     checkType(l, 2, out a1);
     System.Single a2;
     checkType(l, 3, out a2);
     o = new UnityEngine.GradientColorKey(a1, a2);
     pushObject(l, o);
     return(1);
 }
Exemple #14
0
	private void InitImpulseGradient ()
	{
		impulseGradient = new Gradient ();
		GradientColorKey[] gck = new GradientColorKey[impulseGradientColors.Length];
		GradientAlphaKey[] gak = new GradientAlphaKey[impulseGradientColors.Length];
		for (int i = 0; i < impulseGradientColors.Length; i++) {
			gck [i].color = impulseGradientColors [i];
			gak [i].alpha = 1.0f;
			gck [i].time = gak [i].time = impulseGradientTimes [i];
		}
		impulseGradient.SetKeys (gck, gak);
	}
 static public int ctor_s(IntPtr l)
 {
     try {
         UnityEngine.GradientColorKey o;
         o = new UnityEngine.GradientColorKey();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        /// <summary>
        /// Returns a gradient that represents a linear interpolation between two colors.
        /// </summary>
        /// <param name="color1"></param>
        /// <param name="color2"></param>
        /// <returns></returns>
        public static Gradient GetLerp(Color color1, Color color2)
        {
            var gradient = new Gradient();

            var leftColorKey = new GradientColorKey(color1, 0);
            var rightColorKey = new GradientColorKey(color2, 1);

            var leftAlphaKey = new GradientAlphaKey(color1.a, 0);
            var rightAlphaKey = new GradientAlphaKey(color1.a, 1);

            gradient.SetKeys(
                new[]{leftColorKey, rightColorKey},
                new[]{leftAlphaKey, rightAlphaKey});

            return gradient;
        }
Exemple #17
0
 static void GradientColorKey_time(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.GradientColorKey _this = (UnityEngine.GradientColorKey)vc.csObj;
         var result = _this.time;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single arg0 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.GradientColorKey _this = (UnityEngine.GradientColorKey)vc.csObj;
         _this.time = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
Exemple #18
0
// fields
    static void GradientColorKey_color(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.GradientColorKey _this = (UnityEngine.GradientColorKey)vc.csObj;
            var result = _this.color;
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
        }
        else
        {
            UnityEngine.Color            arg0  = (UnityEngine.Color)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.GradientColorKey _this = (UnityEngine.GradientColorKey)vc.csObj;
            _this.color = arg0;
            JSMgr.changeJSObj(vc.jsObjID, _this);
        }
    }
Exemple #19
0
 /// <summary>
 /// resets the colors of the Colors gradient with a default white-white color preset if colors parameter is null,
 /// else the color array passed as argument is used to populate it
 /// </summary>
 /// <param name="colors">a color array. The colors are distributed along the gradient timeline at fixed steps</param>
 public void ResetGradientColors(Color[] colors = null)
 {
     if (colors != null)
     {
         if (colors.Length > 0)
         {
             UnityEngine.GradientColorKey[] gradient = new UnityEngine.GradientColorKey[colors.Length];
             for (int i = 0; i < colors.Length; i++)
             {
                 float time = (i == colors.Length - 1) ? 1 : ((float)i / (float)(colors.Length - 1));
                 gradient[i] = new UnityEngine.GradientColorKey(colors[i], time);
             }
             ResetGradientColors(gradient);
         }
     }
 }
        public AmplifyLensFlare()
        {
            m_lensGradient = new UnityEngine.Gradient();

            UnityEngine.GradientColorKey[] colorKeys = new UnityEngine.GradientColorKey[] { new UnityEngine.GradientColorKey(Color.white, 0f),
                                                                                            new UnityEngine.GradientColorKey(Color.blue, 0.25f),
                                                                                            new UnityEngine.GradientColorKey(Color.green, 0.5f),
                                                                                            new UnityEngine.GradientColorKey(Color.yellow, 0.75f),
                                                                                            new UnityEngine.GradientColorKey(Color.red, 1f) };
            UnityEngine.GradientAlphaKey[] alphaKeys = new UnityEngine.GradientAlphaKey[] { new UnityEngine.GradientAlphaKey(1f, 0f),
                                                                                            new UnityEngine.GradientAlphaKey(1f, 0.25f),
                                                                                            new UnityEngine.GradientAlphaKey(1f, 0.5f),
                                                                                            new UnityEngine.GradientAlphaKey(1f, 0.75f),
                                                                                            new UnityEngine.GradientAlphaKey(1f, 1f) };
            m_lensGradient.SetKeys(colorKeys, alphaKeys);
        }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.GradientColorKey o;
			UnityEngine.Color a1;
			checkType(l,2,out a1);
			System.Single a2;
			checkType(l,3,out a2);
			o=new UnityEngine.GradientColorKey(a1,a2);
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
        public AmplifyGlare()
        {
            m_currentGlareIdx = ( int )m_currentGlareType;

            m_cromaticAberrationGrad = new UnityEngine.Gradient();

            UnityEngine.GradientColorKey[] colorKeys = new UnityEngine.GradientColorKey[] { new UnityEngine.GradientColorKey(Color.white, 0f),
                                                                                            new UnityEngine.GradientColorKey(Color.blue, 0.25f),
                                                                                            new UnityEngine.GradientColorKey(Color.green, 0.5f),
                                                                                            new UnityEngine.GradientColorKey(Color.yellow, 0.75f),
                                                                                            new UnityEngine.GradientColorKey(Color.red, 1f) };
            UnityEngine.GradientAlphaKey[] alphaKeys = new UnityEngine.GradientAlphaKey[] { new UnityEngine.GradientAlphaKey(1f, 0f),
                                                                                            new UnityEngine.GradientAlphaKey(1f, 0.25f),
                                                                                            new UnityEngine.GradientAlphaKey(1f, 0.5f),
                                                                                            new UnityEngine.GradientAlphaKey(1f, 0.75f),
                                                                                            new UnityEngine.GradientAlphaKey(1f, 1f) };
            m_cromaticAberrationGrad.SetKeys(colorKeys, alphaKeys);


            _rtBuffer = new RenderTexture[MaxStarLines * MaxPasses];

            m_weigthsMat = new Matrix4x4[4];
            m_offsetsMat = new Matrix4x4[4];

            m_amplifyGlareCache = new AmplifyGlareCache();

            m_whiteReference = new Color(0.63f, 0.63f, 0.63f, 0.0f);
            m_aTanFoV        = Mathf.Atan(Mathf.PI / MaxLineSamples);


            m_starDefArr = new StarDefData[] { new StarDefData(StarLibType.Cross, "Cross", 2, 4, 1.0f, 0.85f, 0.0f, 0.5f, -1.0f, 90.0f),
                                               new StarDefData(StarLibType.Cross_Filter, "CrossFilter", 2, 4, 1.0f, 0.95f, 0.0f, 0.5f, -1.0f, 90.0f),
                                               new StarDefData(StarLibType.Snow_Cross, "snowCross", 3, 4, 1.0f, 0.96f, 0.349f, 0.5f, -1.0f, -1),
                                               new StarDefData(StarLibType.Vertical, "Vertical", 1, 4, 1.0f, 0.96f, 0.0f, 0.0f, -1.0f, -1),
                                               new StarDefData(StarLibType.Sunny_Cross, "SunnyCross", 4, 4, 1.0f, 0.88f, 0.0f, 0.0f, 0.95f, 45.0f) };

            m_glareDefArr = new GlareDefData[] { new GlareDefData(StarLibType.Cross, 0.00f, 0.5f),                        //Cheap Lens
                                                 new GlareDefData(StarLibType.Cross_Filter, 0.44f, 0.5f),                 //Cross Screen
                                                 new GlareDefData(StarLibType.Cross_Filter, 1.22f, 1.5f),                 //Cross Screen Spectral
                                                 new GlareDefData(StarLibType.Snow_Cross, 0.17f, 0.5f),                   //Snow Cross
                                                 new GlareDefData(StarLibType.Snow_Cross, 0.70f, 1.5f),                   //Snow Cross Spectral
                                                 new GlareDefData(StarLibType.Sunny_Cross, 0.00f, 0.5f),                  //Sunny Cross
                                                 new GlareDefData(StarLibType.Sunny_Cross, 0.79f, 1.5f),                  //Sunny Cross Spectral
                                                 new GlareDefData(StarLibType.Vertical, 1.57f, 0.5f),                     //Vertical Slits
                                                 new GlareDefData(StarLibType.Vertical, 0.00f, 0.5f)                      //Horizontal slits
            };
        }
Exemple #23
0
	public void CreateGradTexture(){
		// Create gradient object and assign generic starting colours
		Grad = new Gradient();
		LastGrad = new Gradient();
		GradientColorKey[] gck = new GradientColorKey[2];
		gck[0] = new GradientColorKey(Color.black, 0f);
		gck[1] = new GradientColorKey(Color.white, 1f);
		GradientAlphaKey[] gak = new GradientAlphaKey[2];
		gak[0] = new GradientAlphaKey(1f, 0f);
		gak[1] = new GradientAlphaKey(1f, 1f);
		Grad.SetKeys(gck, gak);
		LastGrad.SetKeys(gck, gak);
		
		outTexture = new Texture2D(_gradientSizeX,_gradientSizeY);
		outTexture.hideFlags = HideFlags.HideAndDontSave;
//		Debug.Log (outTexture);
	}
Exemple #24
0
    public static UnityEngine.Gradient GenerateConstGradient(uint[] colors, float[] colorRatios)
    {
        var gradient = new UnityEngine.Gradient();

        gradient.mode = UnityEngine.GradientMode.Blend;
        UnityEngine.GradientColorKey[] gck = new UnityEngine.GradientColorKey[colors.Length];
        UnityEngine.GradientAlphaKey[] gak = new UnityEngine.GradientAlphaKey[colors.Length];
        for (int i = 0; i < colors.Length; ++i)
        {
            gck[i].time  = colorRatios[i];
            gck[i].color = ValueTypeUtil.GetColor(colors[i]);
            gak[i].time  = colorRatios[i];
            gak[i].alpha = 1.0f;
        }
        gradient.SetKeys(gck, gak);
        return(gradient);
    }
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.GradientColorKey o;
     if (matchType(l, 1, typeof(UnityEngine.Color), typeof(System.Single)))
     {
         UnityEngine.Color a1;
         checkType(l, 1, out a1);
         System.Single a2;
         checkType(l, 2, out a2);
         o = new UnityEngine.GradientColorKey(a1, a2);
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.GradientColorKey o;
         UnityEngine.Color            a1;
         checkType(l, 2, out a1);
         System.Single a2;
         checkType(l, 3, out a2);
         o = new UnityEngine.GradientColorKey(a1, a2);
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int ctor__Color__Single_s(IntPtr l)
 {
     try {
         UnityEngine.GradientColorKey o;
         UnityEngine.Color            a1;
         checkType(l, 1, out a1);
         System.Single a2;
         checkType(l, 2, out a2);
         o = new UnityEngine.GradientColorKey(a1, a2);
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #28
0
        /// <summary>
        /// resets the colors of the Colors gradient with a default white-white color preset if colors parameter is null,
        /// else the GradientColorKey array passed as argument is used to populate it
        /// </summary>
        /// <param name="colors">an array of GradientColorKeys to use for reset of the Colors gradient. If null is passed a preset gradient is used</param>
        public void ResetGradientColors(UnityEngine.GradientColorKey[] colors = null)
        {
            if (colors == null)
            {
                colors = new UnityEngine.GradientColorKey[]
                {
                    new UnityEngine.GradientColorKey(Color.white, 0),
                    new UnityEngine.GradientColorKey(Color.white, 1)
                };
            }

            if (Colors == null)
            {
                Colors = new Gradient();
            }
            Colors.colorKeys = colors;
        }
Exemple #29
0
 public void Init()
 {
     if (m_lensGradient.alphaKeys.Length == 0 && m_lensGradient.colorKeys.Length == 0)
     {
         UnityEngine.GradientColorKey[] colorKeys = new UnityEngine.GradientColorKey[] { new UnityEngine.GradientColorKey(Color.white, 0f),
                                                                                         new UnityEngine.GradientColorKey(Color.blue, 0.25f),
                                                                                         new UnityEngine.GradientColorKey(Color.green, 0.5f),
                                                                                         new UnityEngine.GradientColorKey(Color.yellow, 0.75f),
                                                                                         new UnityEngine.GradientColorKey(Color.red, 1f) };
         UnityEngine.GradientAlphaKey[] alphaKeys = new UnityEngine.GradientAlphaKey[] { new UnityEngine.GradientAlphaKey(1f, 0f),
                                                                                         new UnityEngine.GradientAlphaKey(1f, 0.25f),
                                                                                         new UnityEngine.GradientAlphaKey(1f, 0.5f),
                                                                                         new UnityEngine.GradientAlphaKey(1f, 0.75f),
                                                                                         new UnityEngine.GradientAlphaKey(1f, 1f) };
         m_lensGradient.SetKeys(colorKeys, alphaKeys);
     }
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.GradientColorKey o;
         UnityEngine.Color a1;
         checkType(l,2,out a1);
         System.Single a2;
         checkType(l,3,out a2);
         o=new UnityEngine.GradientColorKey(a1,a2);
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
        /// <summary>
        /// Read the data using the reader.
        /// </summary>
        /// <param name="reader">Reader.</param>
        public override object Read(ISaveGameReader reader)
        {
            UnityEngine.GradientColorKey gradientColorKey = new UnityEngine.GradientColorKey();
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "color":
                    gradientColorKey.color = reader.ReadProperty <UnityEngine.Color> ();
                    break;

                case "time":
                    gradientColorKey.time = reader.ReadProperty <System.Single> ();
                    break;
                }
            }
            return(gradientColorKey);
        }
Exemple #32
0
    void Start () {
        GradientColorKey[] gradColorKey;
        GradientAlphaKey[] gradAlphaKey;

        grad = new Gradient();
        gradColorKey = new GradientColorKey[3];
        gradAlphaKey = new GradientAlphaKey[1];

        gradColorKey[0].color = Color.magenta;
        gradColorKey[0].time = 0.0f;
        gradColorKey[1].color = Color.green;
        gradColorKey[1].time = 0.5f;
        gradColorKey[2].color = Color.magenta;
        gradColorKey[2].time = 1.0f;

        gradAlphaKey[0].alpha = 1.0f;

        grad.SetKeys(gradColorKey,gradAlphaKey);
    }
Exemple #33
0
    public static Color Grad(float x)
    {
        /*
        // Terrain gradient color keys
        List<GradientColorKey> terrainColorKeys = new List<GradientColorKey>
        {
            new GradientColorKey(new Color(0, 0, 0.5f), 0),
            new GradientColorKey(new Color(0.125f, 0.25f, 0.5f), 0.4f),
            new GradientColorKey(new Color(0.25f, 0.375f, 0.75f), 0.48f),
            new GradientColorKey(new Color(0, 0.75f, 0), 0.5f),
            new GradientColorKey(new Color(0.75f, 0.75f, 0), 0.625f),
            new GradientColorKey(new Color(0.625f, 0.375f, 0.25f), 0.75f),
            new GradientColorKey(new Color(0.5f, 1, 1), 0.875f),
            new GradientColorKey(Color.white, 1)
        };

        // Generic gradient alpha keys
        var alphaKeys = new List<GradientAlphaKey> {new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 1)};
        */

        Gradient g = new Gradient();
        GradientColorKey[] gck;
        GradientAlphaKey[] gak;

        // Populate the color keys at the relative time 0 and 1 (0 and 100%)
        gck = new GradientColorKey[2];
        gck[0].color = Color.red;
        gck[0].time = 0.0f;
        gck[1].color = Color.blue;
        gck[1].time = 1.0f;

        // Populate the alpha  keys at relative time 0 and 1  (0 and 100%)
        gak = new GradientAlphaKey[2];
        gak[0].alpha = 1.0f;
        gak[0].time = 0.0f;
        gak[1].alpha = 0.0f;
        gak[1].time = 1.0f;

        //g.SetKeys(terrainColorKeys.ToArray(), alphaKeys.ToArray());
        g.SetKeys(gck,gak);

        return g.Evaluate(x);;
    }
 private void AssignBack()
 {
     this.m_RGBSwatches.Sort((Comparison<Swatch>) ((a, b) => this.SwatchSort(a, b)));
     GradientColorKey[] keyArray = new GradientColorKey[this.m_RGBSwatches.Count];
     for (int i = 0; i < this.m_RGBSwatches.Count; i++)
     {
         keyArray[i].color = this.m_RGBSwatches[i].m_Value;
         keyArray[i].time = this.m_RGBSwatches[i].m_Time;
     }
     this.m_AlphaSwatches.Sort((Comparison<Swatch>) ((a, b) => this.SwatchSort(a, b)));
     GradientAlphaKey[] keyArray2 = new GradientAlphaKey[this.m_AlphaSwatches.Count];
     for (int j = 0; j < this.m_AlphaSwatches.Count; j++)
     {
         keyArray2[j].alpha = this.m_AlphaSwatches[j].m_Value.r;
         keyArray2[j].time = this.m_AlphaSwatches[j].m_Time;
     }
     this.m_Gradient.colorKeys = keyArray;
     this.m_Gradient.alphaKeys = keyArray2;
     this.m_Gradient.mode = this.m_GradientMode;
     GUI.changed = true;
 }
        public override void CreateModel(Transform parent)
        {
            GameObject model = Object.Instantiate(Resources.Load("ParticleSystem")) as GameObject;

            if (model != null)
            {
                var colorOverLifetimeModule = model.GetComponent<ParticleSystem>().colorOverLifetime;
                var gradient = new Gradient();
                var gradientColorKeys = new GradientColorKey[]
                {new GradientColorKey(_startColor, 0f), new GradientColorKey(_endColor, 1f)};
                var gradientAlphaKeys = new GradientAlphaKey[]
                {new GradientAlphaKey(1f, 0f), new GradientAlphaKey(1f, 0.8f), new GradientAlphaKey(0f, 1f)};
                    // only fade out in the last 20% of lifetime
                gradient.SetKeys(gradientColorKeys, gradientAlphaKeys);
                colorOverLifetimeModule.color = new ParticleSystem.MinMaxGradient(gradient);

                model.transform.SetParent(parent);
                model.transform.localPosition = LocalCoinPosition();
                SetModel(model);
            }
        }
Exemple #36
0
    public void ApplyToUnityParticleSystem(UnityEngine.ParticleSystem ups, ParticleSystem ps)
    {
        var colorModule = ups.colorOverLifetime;

        var gradient = new UnityEngine.Gradient();

        gradient.mode = UnityEngine.GradientMode.Blend;
        UnityEngine.GradientColorKey[] gck;

        if (justAlpha)
        {
            gck          = new UnityEngine.GradientColorKey[2];
            gck[0].time  = 0.0f;
            gck[0].color = ps.Emitter.color.getValue(gck[0].time);
            gck[1].time  = 1.0f;
            gck[1].color = ps.Emitter.color.getValue(gck[1].time);
        }
        else
        {
            gck = new UnityEngine.GradientColorKey[colors.Count];

            for (int i = 0; i < colors.Count; ++i)
            {
                gck[i].time  = colorRatios[i] / 255.0f;
                gck[i].color = ValueTypeUtil.GetColor(colors[i]);
            }
        }

        UnityEngine.GradientAlphaKey[] gak = new UnityEngine.GradientAlphaKey[alphaRatios.Count];

        for (int i = 0; i < alphaRatios.Count; ++i)
        {
            gak[i].time  = alphaRatios[i] / 255.0f;
            gak[i].alpha = alphas[i];
        }

        gradient.SetKeys(gck, gak);
        colorModule.enabled = true;
        colorModule.color   = new UnityEngine.ParticleSystem.MinMaxGradient(gradient);
    }
    private static void AddCosmosParticle()
    {
        GameObject cpObj = new GameObject("Cosmos Particle");
        cpObj.transform.parent = Cosmos.instance.transform;
        CosmosParticle cp = cpObj.AddComponent<CosmosParticle>();

        cp.color = new Gradient();

        GradientColorKey[] colork = new GradientColorKey[2];
        colork[0].color = Color.white;
        colork[0].time = 0.0f;

        colork[1].color =  Color.white;;
        colork[1].time = 1f;

        GradientAlphaKey[] alphak = new GradientAlphaKey[2];
        alphak[0].alpha = 1.0f;
        alphak[0].time = 0.0f;

        alphak[1].alpha = 1.0f;
        alphak[1].time = 0.0f;

        cp.color.SetKeys(colork,alphak);
    }
    private GameObject CreateShape(GameObject shape, uint index)
    {
        GameObject newShape =(GameObject)Instantiate (shape, new Vector3 (0, 0, 0), Quaternion.identity);
        newShape.transform.parent = transform;
        newShape.transform.localPosition = Vector3.zero;
        newShape.transform.localRotation = Quaternion.identity;
        newShape.GetComponent<ShapeProperties> ().index = index;

        ColorChanger colorChanger = newShape.AddComponent<ColorChanger> ();
        Gradient gradient = new Gradient ();
        GradientColorKey[] colorKeys = new GradientColorKey[3];
        colorKeys[0].color = Color.red;
        colorKeys[0].time = 0.0f;
        colorKeys[1].color = Color.green;
        colorKeys[1].time = 0.5f;
        colorKeys[2].color = Color.red;
        colorKeys[2].time = 1.0f;
        gradient.colorKeys = colorKeys;
        colorChanger.colors = gradient;

        newShape.AddComponent<ToRandomLocation> ();

        return newShape;
    }
 public SerializableGradientColorKey(GradientColorKey colorKey)
 {
     FromKeyframe(colorKey);
 }
 static public int get_time(IntPtr l)
 {
     UnityEngine.GradientColorKey o = (UnityEngine.GradientColorKey)checkSelf(l);
     pushValue(l, o.time);
     return(1);
 }
    public void UpdateEmitters(float power)
    {
        UpdateInputs(power);

        for (int i = 0; i < persistentEmitters.Count; i++)
        {
            PersistentKSPShurikenEmitter pkpe = persistentEmitters[i];

            if (pkpe.go == null)
                continue;

            float finalScale = fixedScale * specialScale;

            float finalSizeClamp = sizeClamp + sizeClampCurve.Value(inputs);

            float sizePower = size.Value(inputs) * finalScale;
            pkpe.minSize = Mathf.Min(pkpe.minSizeBase * sizePower, finalSizeClamp);
            pkpe.maxSize = Mathf.Min(pkpe.maxSizeBase * sizePower, finalSizeClamp);

            float emissionPower = emission.Value(inputs) * emissionMult;
            pkpe.minEmission = Mathf.FloorToInt(pkpe.minEmissionBase * emissionPower);
            pkpe.maxEmission = Mathf.FloorToInt(pkpe.maxEmissionBase * emissionPower);

            float energyPower = energy.Value(inputs);
            pkpe.minEnergy = pkpe.minEnergyBase * energyPower;
            pkpe.maxEnergy = pkpe.maxEnergyBase * energyPower;

            float velocityPower = speed.Value(inputs) * finalScale;
            pkpe.localVelocity = pkpe.localVelocityBase * velocityPower;
            pkpe.worldVelocity = pkpe.worldVelocityBase * velocityPower;

            float forcePower = force.Value(inputs);
            pkpe.force = pkpe.forceBase * forcePower;

            ParticleSystem.ForceOverLifetimeModule fol = pkpe.pe.forceOverLifetime;
            fol.enabled = pkpe.force.sqrMagnitude > 0 || pkpe.rndForce.sqrMagnitude > 0;
            fol.x = new ParticleSystem.MinMaxCurve(pkpe.forceBase.x, pkpe.force.x + pkpe.rndForce.x);
            fol.y = new ParticleSystem.MinMaxCurve(pkpe.forceBase.y, pkpe.force.y + pkpe.rndForce.y);
            fol.z = new ParticleSystem.MinMaxCurve(pkpe.forceBase.z, pkpe.force.z + pkpe.rndForce.z);

            pkpe.sizeGrow = grow.Value(inputs);

            float currentScale = scale.Value(inputs) * finalScale;
            pkpe.shape1D = pkpe.scale1DBase * currentScale;
            pkpe.shape2D = pkpe.scale2DBase * currentScale;
            pkpe.shape3D = pkpe.scale3DBase * currentScale;

            pkpe.sizeClamp = finalSizeClamp;
            pkpe.randomInitalVelocityOffsetMaxRadius = randomInitalVelocityOffsetMaxRadius + initalVelocityOffsetMaxRadius.Value(inputs);

            pkpe.randConeEmit = randConeEmit.Value(inputs);
            pkpe.xyForce = xyForce.Value(inputs);
            pkpe.zForce = zForce.Value(inputs);

            pkpe.vRandPosOffset = vRandPosOffset.Value(inputs);
            pkpe.vPosOffset = vPosOffset.Value(inputs);

            pkpe.physical = physical && !SmokeScreenConfig.Instance.globalPhysicalDisable;
            pkpe.initialDensity = initialDensity;
            pkpe.dragCoefficient = dragCoefficient;

            pkpe.collide = collide && !SmokeScreenConfig.Instance.globalCollideDisable;
            pkpe.stickiness = stickiness;
            pkpe.collideRatio = collideRatio;

            pkpe.logarithmicGrow = logGrow.Value(inputs);
            pkpe.logarithmicGrowScale = logGrowScale.Value(inputs);

            pkpe.linearGrow = linGrow.Value(inputs);

            if (alpha.Value(inputs) != 1 || linAlphaDecay.Value(inputs) != 0 || logAlphaDecay.Value(inputs) != 0)
            {
                //Color[] cols = new Color[5];

                GradientColorKey[] colorKeys = new GradientColorKey[5];
                GradientAlphaKey[] alphaKeys = new GradientAlphaKey[5];

                for (int t = 0; t < 5; t++)
                {
                    float a =
                        Mathf.Clamp01(alpha.Value(inputs) *
                                      (1 - linAlphaDecay.Value(inputs) * (t / 4f) -
                                       Mathf.Log(logAlphaDecay.Value(inputs) * (t / 4f) + 1)));
                    colorKeys[t] = new GradientColorKey(Color.red, t * 0.25f);
                    alphaKeys[t] = new GradientAlphaKey(a, t * 0.25f);
                }

                ParticleSystem.ColorOverLifetimeModule col = pkpe.pe.colorOverLifetime;
                col.enabled = true;

                Gradient gradient = new Gradient();
                gradient.SetKeys(colorKeys, alphaKeys);

                col.color = new ParticleSystem.MinMaxGradient(gradient);
            }

            pkpe.go.transform.localPosition = localPosition
                                              + offsetDirection.normalized * offset.Value(inputs) * finalScale;

            pkpe.go.transform.localRotation = Quaternion.Euler(localRotation);

            //if (renderMode != lastRenderMode)
            //{
            //    // Bad code is bad
            //    try
            //    {
            //        pkpe.pe.particleRenderMode = (ParticleRenderMode)Enum.Parse(typeof (ParticleRenderMode), renderMode);
            //    }
            //    catch (ArgumentException) { }
            //    lastRenderMode = renderMode;
            //}
        }
    }
 private void AssignBack()
 {
   this.m_RGBSwatches.Sort((Comparison<GradientEditor.Swatch>) ((a, b) => this.SwatchSort(a, b)));
   GradientColorKey[] gradientColorKeyArray = new GradientColorKey[this.m_RGBSwatches.Count];
   for (int index = 0; index < this.m_RGBSwatches.Count; ++index)
   {
     gradientColorKeyArray[index].color = this.m_RGBSwatches[index].m_Value;
     gradientColorKeyArray[index].time = this.m_RGBSwatches[index].m_Time;
   }
   this.m_AlphaSwatches.Sort((Comparison<GradientEditor.Swatch>) ((a, b) => this.SwatchSort(a, b)));
   GradientAlphaKey[] gradientAlphaKeyArray = new GradientAlphaKey[this.m_AlphaSwatches.Count];
   for (int index = 0; index < this.m_AlphaSwatches.Count; ++index)
   {
     gradientAlphaKeyArray[index].alpha = this.m_AlphaSwatches[index].m_Value.r;
     gradientAlphaKeyArray[index].time = this.m_AlphaSwatches[index].m_Time;
   }
   this.m_Gradient.colorKeys = gradientColorKeyArray;
   this.m_Gradient.alphaKeys = gradientAlphaKeyArray;
   this.m_TextureDirty = true;
   GUI.changed = true;
 }
Exemple #43
0
	void Awake()
	{
		if ( velcols == null )
		{
			velcols = new Gradient();

			GradientColorKey[] keys = new GradientColorKey[5];

			for ( int i = 0; i < 5; i++ )
			{
				keys[i].color = Cols[i];
				keys[i].time = (float)i / 4.0f;
			}

			GradientAlphaKey[] akeys = new GradientAlphaKey[2];
			akeys[0].alpha = 1.0f;
			akeys[0].time = 0.0f;
			akeys[1].alpha = 1.0f;
			akeys[1].time = 0.0f;

			velcols.SetKeys(keys, akeys);
		}
	}
		//creating a color gradient, straight from the unity docs, with added alpha component
		public static Gradient GetColorGradient(Color startColor, Color endColor)
		{
			Gradient g = new Gradient();
			
			// Populate the color keys at the relative time 0 and 1 (0 and 100%)
			GradientColorKey[] gck = new GradientColorKey[2];
			gck[0].color = startColor;
			gck[0].time = 0.0f;
			gck[1].color = endColor;
			gck[1].time = 1.0f;
			
			// Populate the alpha  keys at relative time 0 and 1  (0 and 100%)
			GradientAlphaKey[] gak = new GradientAlphaKey[2];
			gak[0].alpha = startColor.a;
			gak[0].time = 0.0f;
			gak[1].alpha = endColor.a;
			gak[1].time = 1.0f;
			
			g.SetKeys(gck, gak);
			return g;
		}
        private void SetupValuesGradient()
        {
            GradientColorKey[] gck = new GradientColorKey[2];
            gck[0].color = Color.blue;
            gck[0].time = 0.0f;
            gck[1].color = new Color(1,0.7f,0,1);
            gck[1].time = 1.0f;

            GradientAlphaKey[] gak = new GradientAlphaKey[2];
            gak[0].alpha = 1.0f;
            gak[0].time = 0.0f;
            gak[1].alpha = 1.0f;
            gak[1].time = 1.0f;

            valueGradient.SetKeys(gck,gak);
        }
Exemple #46
0
	Gradient[] MakeGradients(Color asteroidColor, Color mineralColor) {

		Gradient[] gradients = new Gradient[2];
		gradients[0] = new Gradient();
		GradientColorKey[] gck = new GradientColorKey[5];
		gck[0].color = Color.black;
		gck[0].time = 0;
		gck[1].color = asteroidColor;
		gck[1].time = threshold-blend;
		gck[2].color = asteroidColor*0.5f;
		gck[2].time = threshold;
		gck[3].color = mineralColor*0.8f;
		gck[3].time = threshold+blend;
		gck[4].color = mineralColor;
		gck[4].time = 1;
		GradientAlphaKey[] gak = new GradientAlphaKey[3];
		gak[0].alpha = 0.05f;
		gak[0].time = 0;
		gak[1].alpha = 0.05f;
		gak[1].time = threshold;
		gak[2].alpha = 1;
		gak[2].time = 1;
		gradients[0].SetKeys(gck, gak);
		
		gradients[1] = new Gradient();
		gck[0].color = new Color(0.3f,0.3f,0.3f);
		gck[0].time = 0;
		gck[1].color = new Color(1,1,1);
		gck[1].time = threshold-blend;
		gck[2].color = new Color(0.2f,0.2f,0.2f);
		gck[2].time = threshold;
		gck[3].color = new Color(0.1f,0.1f,0.1f);
		gck[3].time = threshold+blend;
		gck[4].color = new Color(0,0,0);
		gck[4].time = 1;
		gradients[1].SetKeys (gck, gak);

		return gradients;
	}
    public override void OnInitialize()
    {
        //Print("Init");

        // Restore the Curve config from the node content backup
        // Done because I could not get the serialization of MultiInputCurve to work
        if (node_backup != string.Empty)
        {
            Restore();
        }

        List<Transform> transforms = new List<Transform>(hostPart.FindModelTransforms(transformName));
        if (transforms.Count == 0)
        {
            Print("Cannot find transform " + transformName);
            return;
        }
        GameObject model = GameDatabase.Instance.GetModel(modelName);
        if (model == null)
        {
            Print("Cannot find model " + modelName);
            return;
        }
        model.SetActive(true);
        KSPParticleEmitter templateKspParticleEmitter = model.GetComponentInChildren<KSPParticleEmitter>();

        if (templateKspParticleEmitter == null)
        {
            Print("Cannot find particle emitter on " + modelName);
            Destroy(model);
            return;
        }

        if (persistentEmitters == null)
        {
            persistentEmitters = new List<PersistentKSPShurikenEmitter>();
        }

        if (hostPart.Modules.Contains("ProceduralSRB"))
        {
            PartModule pm = hostPart.Modules["ProceduralSRB"];

            specialScale = pm.Fields.GetValue<float>("bellScale");
            Print("Found ProceduralSRB. Rescaling by " + specialScale.ToString("F3") + " final scale " + (fixedScale * specialScale).ToString("F3"));
        }

        for (int i = 0; i < transforms.Count; i++)
        {
            GameObject emitterGameObject = Instantiate(model) as GameObject;
            KSPParticleEmitter childKSPParticleEmitter = emitterGameObject.GetComponentInChildren<KSPParticleEmitter>();

            //if (shader != null)
            //{
            //    childKSPParticleEmitter.material.shader = shader;
            //    childKSPParticleEmitter.pr.material.shader = shader;
            //}

            if (childKSPParticleEmitter != null)
            {
                // Destroy them ?
                childKSPParticleEmitter.pr.enabled = false;
                childKSPParticleEmitter.pe.enabled = false;
                childKSPParticleEmitter.enabled = false;

                ParticleSystem particleSystem = childKSPParticleEmitter.gameObject.AddComponent<ParticleSystem>();
                ParticleSystemRenderer particleSystemRenderer = childKSPParticleEmitter.gameObject.GetComponent<ParticleSystemRenderer>();

                PersistentKSPShurikenEmitter pkpe = new PersistentKSPShurikenEmitter(
                    emitterGameObject,
                    particleSystem,
                    particleSystemRenderer,
                    templateKspParticleEmitter);

                particleSystem.simulationSpace = childKSPParticleEmitter.pe.useWorldSpace
                    ? ParticleSystemSimulationSpace.World
                    : ParticleSystemSimulationSpace.Local;

                particleSystem.maxParticles = particleCountLimit;

                particleSystemRenderer.material = childKSPParticleEmitter.pr.material;

                // TODO Actually copy the mode from childKSPParticleEmitter.particleRenderMode?
                particleSystemRenderer.renderMode = ParticleSystemRenderMode.Billboard;

                try
                {
                    childKSPParticleEmitter.particleRenderMode =
                        (ParticleRenderMode)Enum.Parse(typeof(ParticleRenderMode), renderMode);
                }
                catch (ArgumentException)
                {
                    Print("ModelMultiParticleFXExt: " + renderMode + " is not a valid ParticleRenderMode");
                }

                switch (childKSPParticleEmitter.particleRenderMode)
                {
                    case ParticleRenderMode.Billboard:
                        particleSystemRenderer.renderMode = ParticleSystemRenderMode.Billboard;
                        break;
                    case ParticleRenderMode.Stretch:
                        particleSystemRenderer.renderMode = ParticleSystemRenderMode.Stretch;
                        break;
                    case ParticleRenderMode.SortedBillboard:
                        particleSystemRenderer.renderMode = ParticleSystemRenderMode.Billboard;
                        particleSystemRenderer.sortMode = ParticleSystemSortMode.Distance;
                        break;
                    case ParticleRenderMode.HorizontalBillboard:
                        particleSystemRenderer.renderMode = ParticleSystemRenderMode.HorizontalBillboard;
                        break;
                    case ParticleRenderMode.VerticalBillboard:
                        particleSystemRenderer.renderMode = ParticleSystemRenderMode.VerticalBillboard;
                        break;
                    default:
                        particleSystemRenderer.renderMode = ParticleSystemRenderMode.Billboard;
                        break;
                }

                //particleSystemRenderer.alignment = ParticleSystemRenderSpace.View;

                if (childKSPParticleEmitter.doesAnimateColor)
                {
                    ParticleSystem.ColorOverLifetimeModule col = particleSystem.colorOverLifetime;
                    col.enabled = true;

                    GradientColorKey[] colorKeys = new GradientColorKey[5];
                    GradientAlphaKey[] alphaKeys = new GradientAlphaKey[5];

                    Color[] colors = childKSPParticleEmitter.colorAnimation;

                    float step = 1f / (colors.Length - 1);

                    for (int t = 0; t < colors.Length; t++)
                    {
                        colorKeys[t] = new GradientColorKey(colors[t], t * step);
                        alphaKeys[t] = new GradientAlphaKey(colors[t].a, t * step);
                    }

                    Gradient gradient = new Gradient();
                    gradient.SetKeys(colorKeys, alphaKeys);

                    col.color = new ParticleSystem.MinMaxGradient(gradient);
                }

                //try
                //{
                //    particleSystemRenderer.renderMode =
                //        (ParticleSystemRenderMode)Enum.Parse(typeof (ParticleSystemRenderMode), renderMode);
                //}
                //catch (ArgumentException)
                //{
                //    Print("ModelMultiParticleFXExt: " + renderMode + " is not a valid ParticleSystemRenderMode");
                //}

                persistentEmitters.Add(pkpe);

                DisableCollider(pkpe.go);

                emitterGameObject.transform.SetParent(transforms[i]);

                emitterGameObject.transform.localPosition = localPosition;
                emitterGameObject.transform.localRotation = Quaternion.Euler(localRotation);
                emitterGameObject.SetLayerRecursive(layerId);
            }
        }

        Destroy(model);

        list.Add(this);

        // 1.0 don't seems to properly do this for engines.
        OnEvent(0);
    }
		private void AssignBack()
		{
			this.m_RGBSwatches.Sort((GradientEditor.Swatch a, GradientEditor.Swatch b) => this.SwatchSort(a, b));
			GradientColorKey[] array = new GradientColorKey[this.m_RGBSwatches.Count];
			for (int i = 0; i < this.m_RGBSwatches.Count; i++)
			{
				array[i].color = this.m_RGBSwatches[i].m_Value;
				array[i].time = this.m_RGBSwatches[i].m_Time;
			}
			this.m_AlphaSwatches.Sort((GradientEditor.Swatch a, GradientEditor.Swatch b) => this.SwatchSort(a, b));
			GradientAlphaKey[] array2 = new GradientAlphaKey[this.m_AlphaSwatches.Count];
			for (int j = 0; j < this.m_AlphaSwatches.Count; j++)
			{
				array2[j].alpha = this.m_AlphaSwatches[j].m_Value.r;
				array2[j].time = this.m_AlphaSwatches[j].m_Time;
			}
			this.m_Gradient.colorKeys = array;
			this.m_Gradient.alphaKeys = array2;
			this.m_TextureDirty = true;
			GUI.changed = true;
		}
        protected Gradient ConstructGradient()
        {
            Gradient g = new Gradient();
            GradientColorKey[] gkColor = new GradientColorKey[7];
            GradientAlphaKey[] gkAlpha = new GradientAlphaKey[4];

            gkColor[0].color = Color.white;
            gkColor[1].color = Color.red;
            gkColor[2].color = Color.yellow;
            gkColor[3].color = Color.green;
            gkColor[4].color = Color.blue;
            gkColor[5].color = Color.magenta;
            gkColor[6].color = Color.black;

            gkColor[0].time = 0f;
            gkColor[1].time = 0.166f;
            gkColor[2].time = 0.33f;
            gkColor[3].time = 0.5f;
            gkColor[4].time = 0.66f;
            gkColor[5].time = 0.833f;
            gkColor[6].time = 1f;

            gkAlpha[0].alpha = 0.75f;
            gkAlpha[1].alpha = 0.75f;
            gkAlpha[2].alpha = 0.75f;
            gkAlpha[3].alpha = 0.75f;

            gkAlpha[0].time = 0f;
            gkAlpha[1].time = 0.33f;
            gkAlpha[2].time = 0.66f;
            gkAlpha[3].time = 1f;

            g.SetKeys(gkColor, gkAlpha);

            return g;
        }
 /// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.GradientColorKey gradientColorKey = (UnityEngine.GradientColorKey)value;
     writer.WriteProperty("color", gradientColorKey.color);
     writer.WriteProperty("time", gradientColorKey.time);
 }
    static public void PatchColorGradient(ColorParameter c1, Gradient c2)
    {

        GradientColorKey[] ck = new GradientColorKey[c1.Colors.Count];
        GradientAlphaKey[] ak = new GradientAlphaKey[c1.Colors.Count];

        for (int i = 0; i < c1.Colors.Count; i++)
        {
            ColorKey k = c1.Colors[i];

            ck[i].color = k.Color;
            ck[i].time = k.t;

            ak[i].alpha = k.Color.a;
            ak[i].time = k.t;
        }

        c2.SetKeys(ck, ak);
    }
Exemple #52
0
 public extern void SetKeys(GradientColorKey[] colorKeys, GradientAlphaKey[] alphaKeys);
 public void FromKeyframe(GradientColorKey gck)
 {
     this.time = gck.time;
     this.color = new SerializableColor(gck.color);
 }
Exemple #54
0
	Gradient[] MakeGenericGradients(Color asteroidColor) {
		Gradient[] gradients = new Gradient[2];
		gradients[0] = new Gradient();
		GradientColorKey[] gck = new GradientColorKey[2];
		gck[0].color = Color.black;
		gck[0].time = 0;
		gck[1].color = asteroidColor;
		gck[1].time = 1;
		GradientAlphaKey[] gak = new GradientAlphaKey[2];
		gak[0].alpha = 0.05f;
		gak[0].time = 0;
		gak[1].alpha = 0.05f;
		gak[1].time = 1;
		gradients[0].SetKeys (gck, gak);

		gradients[1] = new Gradient();
		gck[0].color = Color.black;
		gck[0].time = 0;
		gck[1].color = Color.white;
		gck[1].time = 1;
		gradients[1].SetKeys (gck, gak);

		return gradients;
	}
Exemple #55
0
        public void Create()
        {
            // Init
            enable = true;

            threshold =0;
            mixing =0.7f;
            intensity =1;

            smallCount = 0;
            mediumCount = 0;
            largeCount = 0;

            // Color gradient
            gradient = new Gradient();

            GradientColorKey[] colork = new GradientColorKey[4];
            colork[0].color = Color.white;
            colork[0].time = 0.0f;

            colork[1].color = new Color( 1,245f/255f,200f/255f);
            colork[1].time = 0.33f;

            colork[2].color = new Color( 1,190f/255f,190f/255f);
            colork[2].time = 0.66f;

            colork[3].color = new Color( 189f/255f,1,1);
            colork[3].time = 1f;

            GradientAlphaKey[] alphak = new GradientAlphaKey[2];
            alphak[0].alpha = 1.0f;
            alphak[0].time = 0.0f;

            alphak[1].alpha = 1.0f;
            alphak[1].time = 0.0f;

            gradient.SetKeys(colork,alphak);

            // Cluster
            clusterBox = new StarCluster[6];
            for (int i=0;i<6;i++){
            clusterBox[i] = new StarCluster();
            }

            clusterCount = Random.Range(1,50);
            SetupCluster();
        }