public override Hashtable EditorDragDrop(object o)
    {
        if (typeof(Cubemap).IsAssignableFrom(o.GetType()))
        {
            Cubemap ac = (Cubemap)o;

            string path = UnityEditor.AssetDatabase.GetAssetPath(ac.GetInstanceID( ));

            int index = path.IndexOf("Resources/");

            if (index > 0)
            {
                path = path.Substring(index + "Resources/".Length);

                int dot = path.LastIndexOf('.');
                if (dot >= 0)
                {
                    path = path.Substring(0, dot);
                }

                Hashtable hashtable = new Hashtable( );
                hashtable["name"] = path;

                return(hashtable);
            }
        }

        return(null);
    }
Exemple #2
0
 public WXTextureCube(Cubemap cubemap) : base(AssetDatabase.GetAssetPath(cubemap.GetInstanceID()))
 {
     _cubemap = (Cubemap)cubemap;
     if (unityAssetPath == null || unityAssetPath == "")
     {
         ErrorUtil.ExportErrorReporter.create()
         .setResource(this)
         .error(0, "TextureCube文件的unity路径为空");
     }
 }
 public WXEnvironmentMap(Cubemap _envMap) : base(AssetDatabase.GetAssetPath(_envMap.GetInstanceID()))
 {
     envMap = _envMap;
     if (unityAssetPath == null || unityAssetPath == "")
     {
         ErrorUtil.ExportErrorReporter.create()
         .setResource(this)
         .error(0, "EnvironmentMap文件的unity路径为空");
     }
 }
Exemple #4
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUILayout.PropertyField(cubeMapProperty_, new GUIContent(CubemapText, CubemapTooltip));
        EditorGUILayout.HelpBox(cubemapOverwriteWarning, MessageType.Warning);
        EditorGUILayout.Space();
        reflectionLineRotationProperty_.floatValue = EditorGUILayout.Slider(new GUIContent(ReflectionLineRotationText, ReflectionLineRotationTooltip), reflectionLineRotationProperty_.floatValue, 0.0f, 360.0f);
        EditorGUILayout.PropertyField(rotationStepProperty_, new GUIContent(RotationStepText, RotationStepTooltip));
        lineWidthProperty_.intValue = EditorGUILayout.IntSlider(new GUIContent(LineWidthText), lineWidthProperty_.intValue, 1, 100);

        // Allow creating a new Cubemap
        if (cubeMapProperty_.objectReferenceValue == null)
        {
            EditorGUILayout.Space();
            EditorGUILayout.LabelField(new GUIContent("Cubemap Creation"), EditorStyles.boldLabel);

            int textureSize = 512;
            textureSize = EditorGUILayout.IntField(new GUIContent("Size"), textureSize);
            EditorGUILayout.HelpBox(CubemapSizeHelpText, MessageType.Warning, true);

            float result = Mathf.Log(textureSize, 2.0f);
            if ((result % 1.0f) > 0.0f)
            {
                Debug.LogWarning(target.name + ": Only exponents of 2 are supported for size.");
                textureSize = Mathf.ClosestPowerOfTwo((int)result);
            }
            if (textureSize < 16)
            {
                Debug.LogWarning(target.name + ": Texture size needs to be >= 16!");
                textureSize = 16;
            }

            var path = "Assets/Cubemaps";
            path = EditorGUILayout.TextField(new GUIContent("Path"), path);

            if (GUILayout.Button(new GUIContent(GenerateButtonText)))
            {
                var cubeMap = new Cubemap(textureSize, TextureFormat.ARGB32, false);
                CubemapUtil.initCubeMap(cubeMap);

                AssetDatabase.CreateFolder("Assets", "Cubemaps");
                AssetDatabase.CreateAsset(cubeMap, path + "/CubeMap" + cubeMap.GetInstanceID() + ".cubemap");

                cubeMapProperty_.objectReferenceValue = cubeMap;
            }
        }
        serializedObject.ApplyModifiedProperties();
    }
Exemple #5
0
    private void OnWizardCreate()
    {
        if (cubemap == null)
        {
            return;
        }

        int width  = cubemap.width;
        int height = cubemap.height;

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

        string getPath = AssetDatabase.GetAssetPath(cubemap.GetInstanceID());

        string[] cubemapTargetPath = getPath.Split(new string[] { "/" }, System.StringSplitOptions.None);
        string   path = Application.dataPath.Substring(0, Application.dataPath.Length - 6) + getPath.Substring(0, cubemapTargetPath[cubemapTargetPath.Length - 1].Length + 1) + cubemap.name;

        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }

        tex.SetPixels(cubemap.GetPixels(CubemapFace.PositiveX));
        byte[] bytes = tex.EncodeToPNG();
        File.WriteAllBytes(path + "/Right.png", bytes);

        tex.SetPixels(cubemap.GetPixels(CubemapFace.NegativeX));
        bytes = tex.EncodeToPNG();
        File.WriteAllBytes(path + "/Left.png", bytes);

        tex.SetPixels(cubemap.GetPixels(CubemapFace.PositiveY));
        bytes = tex.EncodeToPNG();
        File.WriteAllBytes(path + "/Up.png", bytes);

        tex.SetPixels(cubemap.GetPixels(CubemapFace.NegativeY));
        bytes = tex.EncodeToPNG();
        File.WriteAllBytes(path + "/Down.png", bytes);

        tex.SetPixels(cubemap.GetPixels(CubemapFace.PositiveZ));
        bytes = tex.EncodeToPNG();
        File.WriteAllBytes(path + "/Forward.png", bytes);

        tex.SetPixels(cubemap.GetPixels(CubemapFace.NegativeZ));
        bytes = tex.EncodeToPNG();
        File.WriteAllBytes(path + "/Backward.png", bytes);

        DestroyImmediate(tex);
        AssetDatabase.Refresh();
    }
Exemple #6
0
 static public VFXValue <int> Constant(Cubemap value)
 {
     return(new VFXTextureCubeValue(value.GetInstanceID(), Mode.Constant));
 }
Exemple #7
0
 public WXTextureCube(Cubemap cubemap)
 {
     _cubemap = (Cubemap)cubemap;
     path     = AssetDatabase.GetAssetPath(cubemap.GetInstanceID());
 }