コード例 #1
0
    public MM RangeField(string label, MM range, float scale)
    {
        MM v = new MM(range.ToString());

        BeginHorizontal("box");
        FixedLabel(label);
        v.min = EditorGUILayout.FloatField(range.min, Width(fieldWidth * scale / 2f));
        FixedLabel("-");
        v.max = EditorGUILayout.FloatField(range.max, Width(fieldWidth * scale / 2f));
        EndHorizontal();

        changed = changed || (checkChanges && (!v.Equals(range)));

        return(v);
    }
コード例 #2
0
        /// <summary>
        /// The role of IComparable is to provide a method of comparing two objects of a particular type. This is necessary if you want to provide any ordering capability for your object.
        /// </summary>
        public int CompareTo(object obj)
        {
            IshTypeFieldDefinition b = (IshTypeFieldDefinition)obj;

            if (!Key.Equals(b.Key, StringComparison.InvariantCulture))
            {
                return(string.Compare(Key, b.Key));
            }
            // Keys match, now check the properties that matter
            if (!Type.Equals(b.Type, StringComparison.InvariantCulture))
            {
                _logger.WriteVerbose($"IshTypeFieldDefinition.CompareTo a.Key[{Key}] a.Type[{Type}] b.Type[{b.Type}]");
                return(string.Compare(Type, b.Type));
            }
            if (!MM.Equals(b.MM, StringComparison.InvariantCulture))
            {
                _logger.WriteVerbose($"IshTypeFieldDefinition.CompareTo a.Key[{Key}] a.MM[{MM}] b.MM[{b.MM}]");
                return(string.Compare(MM, b.MM, StringComparison.InvariantCulture));
            }
            if (!CRUS.Equals(b.CRUS, StringComparison.InvariantCulture))
            {
                _logger.WriteVerbose($"IshTypeFieldDefinition.CompareTo a.Key[{Key}] a.CRUS[{CRUS}] b.CRUS[{b.CRUS}]");
                return(string.Compare(CRUS, b.CRUS, StringComparison.InvariantCulture));
            }
            if (!SDB.Equals(b.SDB, StringComparison.InvariantCulture))
            {
                _logger.WriteVerbose($"IshTypeFieldDefinition.CompareTo a.Key[{Key}] a.SDB[{SDB}] b.SDB[{b.SDB}]");
                return(string.Compare(SDB, b.SDB, StringComparison.InvariantCulture));
            }
            if (!Description.Equals(b.Description, StringComparison.InvariantCulture))
            {
                _logger.WriteDebug($"IshTypeFieldDefinition.CompareTo a.Key[{Key}] a.Description[{Description}] b.Description[{b.Description}]");
                return(0);  // Difference in description is nice-to-know but considered equal
            }
            return(0);
        }
コード例 #3
0
	public MM RangeField(string label, MM range, float scale) {
		MM v = new MM(range.ToString());
		
		BeginHorizontal("box");
			FixedLabel(label);
			v.min = EditorGUILayout.FloatField(range.min, Width(fieldWidth * scale/2f));
			FixedLabel("-");
			v.max = EditorGUILayout.FloatField(range.max, Width(fieldWidth * scale/2f));
		EndHorizontal();
		
		changed = changed || (checkChanges && (!v.Equals(range)));
		
		return v;
	}