/// <summary> /// 获取属性值 /// </summary> /// <param name="suEntityRef"></param> /// <param name="attributeName"></param> /// <param name="propertyName"></param> /// <returns></returns> public static bool GetAttribute(SUEntityRef suEntityRef, string attributeName, string propertyName, out string defaultValue) { if (suEntityRef.ptr == IntPtr.Zero) { defaultValue = null; return(false); } SUAttributeDictionaryRef dictionaryRef = default(SUAttributeDictionaryRef); if (SKPCExport.SUEntityGetAttributeDictionary(suEntityRef, attributeName, ref dictionaryRef) == SUResult.SU_ERROR_NONE) { SUTypedValueRef propertyValueRef = default(SUTypedValueRef); if (SKPCExport.SUAttributeDictionaryGetValue(dictionaryRef, attributeName, ref propertyValueRef) == SUResult.SU_ERROR_NONE) { SUStringRef temp = default; SKPCExport.SUStringCreate(ref temp); SKPCExport.SUTypedValueGetString(propertyValueRef, ref temp); defaultValue = Utilities.GetString(temp); SKPCExport.SUStringRelease(ref temp); return(true); } } defaultValue = null; return(false); }
/// <summary> /// 构造函数 /// </summary> /// <param name="value"></param> public SkpDataValue(SUTypedValueRef value) { SUTypedValueType type = SUTypedValueType.SUTypedValueType_Empty; SKPCExport.SUTypedValueGetType(value, ref type); m_dataType = (DataType)type; switch (type) { case SUTypedValueType.SUTypedValueType_Empty: { m_value = null; break; } case SUTypedValueType.SUTypedValueType_Byte: { byte temp = default; SKPCExport.SUTypedValueGetByte(value, ref temp); m_value = temp; break; } case SUTypedValueType.SUTypedValueType_Short: { short temp = default; SKPCExport.SUTypedValueGetInt16(value, ref temp); m_value = temp; break; } case SUTypedValueType.SUTypedValueType_Int32: { int temp = default; SKPCExport.SUTypedValueGetInt32(value, ref temp); m_value = temp; break; } case SUTypedValueType.SUTypedValueType_Float: { float temp = default; SKPCExport.SUTypedValueGetFloat(value, ref temp); m_value = temp; break; } case SUTypedValueType.SUTypedValueType_Double: { double temp = default; SKPCExport.SUTypedValueGetDouble(value, ref temp); m_value = temp; break; } case SUTypedValueType.SUTypedValueType_Bool: { bool temp = default; SKPCExport.SUTypedValueGetBool(value, ref temp); m_value = temp; break; } case SUTypedValueType.SUTypedValueType_Color: { SUColor temp = default; SKPCExport.SUTypedValueGetColor(value, ref temp); m_value = /*new SkpColor(temp)*/ temp; break; } case SUTypedValueType.SUTypedValueType_Time: { long temp = default; SKPCExport.SUTypedValueGetTime(value, ref temp); m_value = new System.DateTime(1970, 1, 1).AddSeconds(temp); break; } case SUTypedValueType.SUTypedValueType_String: { SUStringRef temp = default; SKPCExport.SUStringCreate(ref temp); SKPCExport.SUTypedValueGetString(value, ref temp); m_value = Utilities.GetString(temp); SKPCExport.SUStringRelease(ref temp); break; } case SUTypedValueType.SUTypedValueType_Vector3D: { double[] temp = new double[3]; SKPCExport.SUTypedValueGetVector3d(value, temp); m_value = new SUVector3D { x = temp[0], y = temp[1], z = temp[2] }; break; } case SUTypedValueType.SUTypedValueType_Array: { long count = default; SKPCExport.SUTypedValueGetNumArrayItems(value, ref count); SUTypedValueRef[] values = new SUTypedValueRef[count]; SKPCExport.SUTypedValueGetArrayItems(value, count, values, ref count); SkpDataValue[] temp = new SkpDataValue[count]; for (int i = 0; i < count; i++) { temp[i] = new SkpDataValue(values[i]); } m_value = temp; break; } default: break; } }