Beispiel #1
0
    private static string GetTypeName(PropType type)
    {
        string typeName = "";

        switch (type)
        {
        case PropType.Color:
            typeName = "color";
            break;

        case PropType.Range:
        case PropType.Float:
            typeName = "float";
            break;

        case PropType.Texture:
            typeName = "tex";
            break;

        case PropType.Vector:
            typeName = "color";
            break;
        }

        return(typeName);
    }
Beispiel #2
0
    public void PropField(PropType type, string varName, string displayName,
                          params GUILayoutOption[] options)
    {
        SerializedProperty prop = GetProperty(type, varName);

        if (prop != null)
        {
            EditorGUILayout.PropertyField(prop, GetDispName(displayName, varName), true, options);
        }
    }
Beispiel #3
0
    private void AddProperty(string propName, PropType type, SerializedProperty prop)
    {
        string prefix = GetTypeName(type) + "_";

        if (MaterialPropNames.ContainsKey(propName) &&
            (MaterialPropNames[propName].type == type ||
             (MaterialPropNames[propName].type == PropType.Vector && type == PropType.Color)))
        {
            m_properties.Add(prefix + propName, prop);
        }
    }
Beispiel #4
0
    //base API functions
    public SerializedProperty GetProperty(PropType type, string varName)
    {
        string prop = GetPropertyName(type, varName);


        if (!m_properties.ContainsKey(prop))
        {
            if (MaterialPropNames.ContainsKey(varName))
            {
                IsValid = false;
            }

            return(null);
        }
        return(m_properties[prop]);
    }
Beispiel #5
0
    void ClearMaterialArray(PropType type, SerializedProperty props)
    {
        for (int i = 0; i < props.arraySize; ++i)
        {
            var    prop     = props.GetArrayElementAtIndex(i);
            var    nameProp = prop.FindPropertyRelative("first.name");
            string propName = nameProp.stringValue;

            if (!MaterialPropNames.ContainsKey(propName) || MaterialPropNames[propName].type != type)
            {
                props.DeleteArrayElementAtIndex(i);
                --i;
            }
        }

        MatEditor.OnEnable();
    }
Beispiel #6
0
    void ClearMaterialArray(PropType type, SerializedProperty props, MaterialProperty[] properties)
    {
        for (int i = 0; i < props.arraySize; ++i)
        {
            var    prop     = props.GetArrayElementAtIndex(i);
            var    nameProp = prop.FindPropertyRelative("first");
            string propName = nameProp.stringValue;

            MaterialProperty matProp = FindProperty(propName, properties, false);

            if (matProp == null || matProp.type != type)
            {
                props.DeleteArrayElementAtIndex(i);
                --i;
            }
        }

        MatEditor.OnEnable();
    }
Beispiel #7
0
    private void AddPropsFromArray(PropType type, SerializedProperty props)
    {
        string original = props.propertyPath;

        props.Next(true);
        props.Next(true);
        props.Next(true);

        do
        {
            var valueProp = props.FindPropertyRelative("second");
            var nameProp  = props.FindPropertyRelative("first.name");



            string propName = nameProp.stringValue;

            AddProperty(propName, type, valueProp);
        } while (props.NextVisible(false) && props.propertyPath.Contains(original));
    }
	public void PropField(PropType type, string varName, string displayName,
		params GUILayoutOption[] options) {
		SerializedProperty prop = GetProperty(type, varName);

		if (prop != null) {
			EditorGUILayout.PropertyField(prop, GetDispName(displayName, varName), true, options);
		}
	}
	private void AddProperty(string propName, PropType type, SerializedProperty prop) {
		string prefix = GetTypeName(type) + "_";

		if (MaterialPropNames.ContainsKey(propName)
			&& (MaterialPropNames[propName].type == type
				|| (MaterialPropNames[propName].type == PropType.Vector && type == PropType.Color))) {
			m_properties.Add(prefix + propName, prop);
		}
	}
	private void AddPropsFromArray(PropType type, SerializedProperty props) {
		string original = props.propertyPath;

		props.Next(true);
		props.Next(true);
		props.Next(true);

		do {
			var valueProp = props.FindPropertyRelative("second");
			var nameProp = props.FindPropertyRelative("first.name");



			string propName = nameProp.stringValue;

			AddProperty(propName, type, valueProp);
		} while (props.NextVisible(false) && props.propertyPath.Contains(original));
	}
	void ClearMaterialArray(PropType type, SerializedProperty props) {
		for (int i = 0; i < props.arraySize; ++i) {
			var prop = props.GetArrayElementAtIndex(i);
			var nameProp = prop.FindPropertyRelative("first.name");
			string propName = nameProp.stringValue;

			if (!MaterialPropNames.ContainsKey(propName) || MaterialPropNames[propName].type != type) {
				props.DeleteArrayElementAtIndex(i);
				--i;
			}
		}

		MatEditor.OnEnable();
	}
	//base API functions
	public SerializedProperty GetProperty(PropType type, string varName) {
		string prop = GetPropertyName(type, varName);


		if (!m_properties.ContainsKey(prop)) {

			if (MaterialPropNames.ContainsKey(varName)) {
				IsValid = false;
			}

			return null;
		}
		return m_properties[prop];
	}
	private static string GetTypeName(PropType type) {
		string typeName = "";

		switch (type) {
			case PropType.Color:
				typeName = "color";
				break;

			case PropType.Range:
			case PropType.Float:
				typeName = "float";
				break;

			case PropType.Texture:
				typeName = "tex";
				break;

			case PropType.Vector:
				typeName = "color";
				break;
		}

		return typeName;
	}
	private string GetPropertyName(PropType type, string varName) {
		var typeName = GetTypeName(type);
		return typeName + "_" + varName;
	}
Beispiel #15
0
    private string GetPropertyName(PropType type, string varName)
    {
        var typeName = GetTypeName(type);

        return(typeName + "_" + varName);
    }