void DisplayVec3Field(MaterialEditor materialEditor, string displayName, CSProperty _xProp, CSProperty _yProp, CSProperty _zProp)
    {
        MaterialProperty xProp = _xProp.prop;
        MaterialProperty yProp = _yProp.prop;
        MaterialProperty zProp = _zProp.prop;

        materialEditor.BeginAnimatedCheck(xProp);
        materialEditor.BeginAnimatedCheck(yProp);
        materialEditor.BeginAnimatedCheck(zProp);
        EditorGUI.BeginChangeCheck();
        EditorGUI.showMixedValue = xProp.hasMixedValue || yProp.hasMixedValue || zProp.hasMixedValue;

        var oldLabelWidth = EditorGUIUtility.labelWidth;

        EditorGUIUtility.labelWidth = 0f;

        Vector3 v = EditorGUILayout.Vector3Field(displayName, new Vector3(xProp.floatValue, yProp.floatValue, zProp.floatValue));

        EditorGUIUtility.labelWidth = oldLabelWidth;

        EditorGUI.showMixedValue = false;

        if (EditorGUI.EndChangeCheck())
        {
            xProp.floatValue = v.x;
            yProp.floatValue = v.y;
            zProp.floatValue = v.z;
        }

        materialEditor.EndAnimatedCheck();
        materialEditor.EndAnimatedCheck();
        materialEditor.EndAnimatedCheck();
    }
        public static void TextureScaleOffsetVector4Property(MaterialEditor matEditor, MaterialProperty scaleOffsetProp)
        {
            //matEditor.BeginAnimatedCheck(GetControlRectForSingleLine(), scaleOffsetProp);
            matEditor.BeginAnimatedCheck(scaleOffsetProp);

            EditorGUI.showMixedValue = scaleOffsetProp.hasMixedValue;
            EditorGUI.BeginChangeCheck();

            Vector4 scaleOffsetVector = scaleOffsetProp.vectorValue;

            var textureScale = new Vector2(scaleOffsetVector.x, scaleOffsetVector.y);

            textureScale = EditorGUILayout.Vector2Field(Styles.scale, textureScale);

            var textureOffset = new Vector2(scaleOffsetVector.z, scaleOffsetVector.w);

            textureOffset = EditorGUILayout.Vector2Field(Styles.offset, textureOffset);

            if (EditorGUI.EndChangeCheck())
            {
                scaleOffsetProp.vectorValue = new Vector4(textureScale.x, textureScale.y, textureOffset.x, textureOffset.y);
            }

            EditorGUI.showMixedValue = false;

            matEditor.EndAnimatedCheck();
        }
예제 #3
0
        public static void TextureScaleOffsetVector4Property(MaterialEditor matEditor, GUIContent label, MaterialProperty scaleOffsetProp)
        {
            //matEditor.BeginAnimatedCheck(scaleOffsetProp);

            EditorGUI.showMixedValue = scaleOffsetProp.hasMixedValue;
            EditorGUI.BeginChangeCheck();

            Vector4 scaleOffsetVector = scaleOffsetProp.vectorValue;

            Vector2 textureScale = new Vector2(scaleOffsetVector.x, scaleOffsetVector.y);

            textureScale = EditorGUILayout.Vector2Field(Styles.scale, textureScale, new GUILayoutOption[0]);

            Vector2 textureOffset = new Vector2(scaleOffsetVector.z, scaleOffsetVector.w);

            textureOffset = EditorGUILayout.Vector2Field(Styles.offset, textureOffset, new GUILayoutOption[0]);

            if (EditorGUI.EndChangeCheck())
            {
                scaleOffsetProp.vectorValue = new Vector4(textureScale.x, textureScale.y, textureOffset.x, textureOffset.y);
            }
            EditorGUI.showMixedValue = false;

            matEditor.EndAnimatedCheck();
        }
예제 #4
0
    protected bool EndMaterialProperty()
    {
        bool change = EditorGUI.EndChangeCheck();

        MatEditor.EndAnimatedCheck();
        EditorGUI.showMixedValue = false;
        return(change);
    }
예제 #5
0
        bool EndProperty()

        {
            editor.EndAnimatedCheck();

            EditorGUI.showMixedValue = false;

            return(EditorGUI.EndChangeCheck());
        }
예제 #6
0
    //光照贴图纹理
    void Lightmap()
    {
        GUILayout.Label("自 定 义 光 照 贴 图", EditorStyles.boldLabel);

        LightMap light = LightMap.unityLightMap;

        if (IsKeywordEnabled("_OHR_LIGHTMAP_UNITY"))
        {
            light = LightMap.unityLightMap;
        }
        else if (IsKeywordEnabled("_OHR_LIGHTMAP_INNER"))
        {
            light = LightMap.innerLightMap;
        }

        editor.EndAnimatedCheck();
        light = (LightMap)EditorGUILayout.EnumPopup(MakeLabel("Light Map"), light);

        if (EditorGUI.EndChangeCheck())
        {
            RecordAction("Light Map");
            SetKeyword("_OHR_LIGHTMAP_UNITY", light == LightMap.unityLightMap);
            SetKeyword("_OHR_LIGHTMAP_INNER", light == LightMap.innerLightMap);
        }

        MaterialProperty lightmap = FindProperty("_LightMap");
        Texture          tex      = lightmap.textureValue;

        EditorGUI.BeginChangeCheck();

        if (light == LightMap.innerLightMap)
        {
            editor.TexturePropertySingleLine(SetLabel(lightmap, "光照贴图,带ARBG,支持shadowmask,A通道为mask通道,如果为空,自动获取系统自带关照贴图信息"), lightmap, null);

            if (EditorGUI.EndChangeCheck())
            {
                if (tex != lightmap.textureValue)
                {
                    SetDefineInfo("_LightMap", lightmap.textureValue);
                }
                if (lightmap.textureValue == null)
                {
                    SetDefineInfo("CF_LIGHTMAP", false);
                }
                else
                {
                    SetDefineInfo("CF_LIGHTMAP", true);
                }
            }
            editor.TextureScaleOffsetProperty(lightmap);
        }
    }