Пример #1
0
        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);
        }
Пример #2
0
 public static T ScriptableObjectField <T>(string label, T asset) where T : ScriptableObject
 {
     EditorGUILayout.BeginHorizontal();
     asset = EditorGUILayout.ObjectField(label, asset, typeof(T), false) as T;
     if (asset == null)
     {
         if (GUILayout.Button("New", EditorStyles.miniButton, GUILayout.Width(50)))
         {
             asset      = ScriptableObject.CreateInstance <T>();
             asset.name = string.Format("{0}-{1}", typeof(T).Name, JCommon.GetUniqueID());
             AssetDatabase.CreateAsset(asset, string.Format("Assets/{0}.asset", asset.name));
             AssetDatabase.SaveAssets();
             AssetDatabase.Refresh();
             EditorGUIUtility.PingObject(asset);
         }
     }
     EditorGUILayout.EndHorizontal();
     return(asset);
 }
Пример #3
0
        private void Export()
        {
            JUtilities.EnsureDirectoryExists(Directory);

            Cubemap cube = new Cubemap(Resolution, TextureFormat.ARGB32, false);
            JCubemapRendererArgs args = new JCubemapRendererArgs()
            {
                CameraPosition        = this.CameraPosition,
                CameraNearPlane       = this.CameraNearPlane,
                CameraFarPlane        = this.CameraFarPlane,
                CameraClearFlag       = this.CameraClearFlag,
                CameraBackgroundColor = this.CameraBackgroundColor,
                Resolution            = this.Resolution,
                Cubemap = cube,
                Face    = (CubemapFace)63
            };

            JCubemapRenderer.Render(args);

            string fileName = Path.Combine(Directory, "Cubemap-" + JCommon.GetUniqueID() + ".cubemap");

            AssetDatabase.CreateAsset(cube, fileName);

            if (ExportFaceTextures)
            {
                ExportFace(cube, CubemapFace.PositiveX);
                ExportFace(cube, CubemapFace.NegativeX);
                ExportFace(cube, CubemapFace.PositiveY);
                ExportFace(cube, CubemapFace.NegativeY);
                ExportFace(cube, CubemapFace.PositiveZ);
                ExportFace(cube, CubemapFace.NegativeZ);
            }

            AssetDatabase.Refresh();
            EditorGUIUtility.PingObject(cube);
            Selection.activeObject = cube;
        }