public static JSky CreateStarryNightSky(MenuCommand cmd)
        {
            GameObject g = new GameObject("Starry Night Sky");

            if (cmd != null && cmd.context != null)
            {
                GameObject root = cmd.context as GameObject;
                GameObjectUtility.SetParentAndAlign(g, root);
            }

            JSky        skyComponent = g.AddComponent <JSky>();
            JSkyProfile profile      = JSkyProfile.CreateInstance <JSkyProfile>();
            string      fileName     = "SkyProfile-" + JCommon.GetUniqueID();
            string      filePath     = string.Format("Assets/{0}.asset", fileName);

            AssetDatabase.CreateAsset(profile, filePath);

            profile.CopyFrom(JJupiterSettings.Instance.DefaultProfileStarryNight);
            skyComponent.Profile        = profile;
            skyComponent.SunLightSource = null;

            Light[] lights = Object.FindObjectsOfType <Light>();
            for (int i = 0; i < lights.Length; ++i)
            {
                if (lights[i].type == LightType.Directional)
                {
                    skyComponent.MoonLightSource = lights[i];
                    break;
                }
            }

            return(skyComponent);
        }
        public void Animate(JSky sky, float t)
        {
            CheckDefaultProfileAndThrow(sky.Profile);

            for (int i = 0; i < AnimatedProperties.Count; ++i)
            {
                JAnimatedProperty aProp = AnimatedProperties[i];
                for (int p = 0; p < PropertiesInfo.Count; ++p)
                {
                    if (aProp.Name.Equals(PropertiesInfo[p].Name))
                    {
                        if (aProp.CurveOrGradient == JCurveOrGradient.Curve)
                        {
                            PropertiesInfo[p].SetValue(sky.Profile, aProp.EvaluateFloat(t));
                        }
                        else
                        {
                            PropertiesInfo[p].SetValue(sky.Profile, aProp.EvaluateColor(t));
                        }
                        break;
                    }
                }
            }

            sky.Profile.UpdateMaterialProperties();
        }
        public void Animate(JSky sky, float t)
        {
            CheckDefaultProfileAndThrow(sky.Profile);

            for (int i = 0; i < AnimatedProperties.Count; ++i)
            {
                JAnimatedProperty aProp = AnimatedProperties[i];
                int id = 0;
                if (!PropertyRemap.TryGetValue(aProp.Name, out id))
                {
                    continue;
                }

                if (aProp.CurveOrGradient == JCurveOrGradient.Curve)
                {
                    sky.Profile.Material.SetFloat(id, aProp.EvaluateFloat(t));
                }
                else
                {
                    sky.Profile.Material.SetColor(id, aProp.EvaluateColor(t));
                }
            }
        }
 private void OnEnable()
 {
     sky     = target as JSky;
     profile = sky.Profile;
 }