コード例 #1
0
 //! Fill Cubemap with black again.
 public void OnDisable()
 {
     if (cubeMap_ != null)
     {
         CubemapUtil.initCubeMap(cubeMap_);
     }
 }
コード例 #2
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();
    }
コード例 #3
0
 //! Update the cubemap texture. Adds the Line in the specified rotation.
 private void updateLineInCubemap()
 {
     CubemapUtil.initCubeMapFace(cubeMap_, CubemapFace.PositiveY);
     CubemapUtil.addReflectionlineToCubemap(cubeMap_, reflectionLineRotation_, lineWidth_, CubemapFace.PositiveY);
 }