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); }