public TypedValue Data(ComponentDataList list, TGIBlockList tgiBlocks) { if (!ComponentDataMap.ContainsKey(element)) { return(null); } if (!list.ContainsKey(ComponentDataMap[element])) { return(null); } ComponentDataType cd = list[ComponentDataMap[element]]; System.Reflection.PropertyInfo pi = cd.GetType().GetProperty("Data"); if (pi == null || !pi.CanRead) { return(null); } if (element == Component.Footprint || element == Component.Model || element == Component.Tree) { return(new TypedValue(typeof(TGIBlock), tgiBlocks[(int)pi.GetValue(cd, null)], "X")); } else { return(new TypedValue(pi.PropertyType, pi.GetValue(cd, null), "X")); } }
private static dynamic GetVertexComponent(ComponentDataType dataType, ushort offset, byte[] rawVertex) { // TODO: files are little-endian, but make this endian-aware (i.e. EndianBinaryReader) regardless? switch (dataType) { case ComponentDataType.UnsignedByte: case ComponentDataType.UnsignedByteN: return(rawVertex[offset]); case ComponentDataType.SignedByte: case ComponentDataType.SignedByteN: return((sbyte)rawVertex[offset]); case ComponentDataType.UnsignedShort: case ComponentDataType.UnsignedShortN: return(BitConverter.ToUInt16(rawVertex, offset)); case ComponentDataType.SignedShort: case ComponentDataType.SignedShortN: return(BitConverter.ToInt16(rawVertex, offset)); case ComponentDataType.Float16: return(Float16toFloat32(BitConverter.ToInt16(rawVertex, offset))); case ComponentDataType.Float32: return(BitConverter.ToSingle(rawVertex, offset)); default: throw new NotImplementedException("Unimplemented/unknown data type"); } }
protected override void OnEnable() { base.OnEnable(); m_SerializedDataList = new ReorderableList(serializedObject, SerializedData); var label = EditorGUIUtility.TrTextContent(m_SerializedDataList.serializedProperty.displayName); m_SerializedDataList.drawHeaderCallback = rect => EditorGUI.LabelField(rect, label); var tempLabel = new GUIContent(); if (ComponentDataType?.GetFields().Length == 1) { m_SerializedDataList.elementHeight = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; m_SerializedDataList.drawElementCallback = (rect, index, active, focused) => { var element = m_SerializedDataList.serializedProperty.GetArrayElementAtIndex(index); tempLabel.text = element.displayName; rect = new Rect(rect) { height = rect.height - EditorGUIUtility.standardVerticalSpacing }; element.Next(true); EditorGUI.PropertyField(rect, element, tempLabel); }; } else { m_SerializedDataList.elementHeightCallback = index => EditorGUI.GetPropertyHeight(m_SerializedDataList.serializedProperty.GetArrayElementAtIndex(index)) + EditorGUIUtility.standardVerticalSpacing; m_SerializedDataList.drawElementCallback = (rect, index, active, focused) => { var hierarchyMode = EditorGUIUtility.hierarchyMode; EditorGUIUtility.hierarchyMode = false; var element = m_SerializedDataList.serializedProperty.GetArrayElementAtIndex(index); tempLabel.text = element.displayName; rect = new Rect(rect) { height = rect.height - EditorGUIUtility.standardVerticalSpacing }; EditorGUI.PropertyField(rect, element, tempLabel, true); EditorGUIUtility.hierarchyMode = hierarchyMode; }; } }
public override int CompareTo(ComponentDataType other) { if (this.GetType() != other.GetType()) { return(-1); } CDTUInt32 oth = (CDTUInt32)other; int res = key.CompareTo(oth.key); if (res != 0) { return(res); } res = controlCode.CompareTo(oth.controlCode); if (res != 0) { return(res); } return(data.CompareTo(oth.data)); }
public override int GetHashCode(ComponentDataType obj) { return((int)(key.GetHashCode() ^ controlCode ^ data)); }