/// <summary> /// /// Material definitions /// /// Parse material definitions data /// Starts material definition node parsing. /// If a new material has been created this function will go through stored meshes /// and check if it can create new mesh with this material available. /// </summary> public static void ParseMaterialDefinitionData(System.IntPtr materialDefinitionDataPtr) { try { var materialDefinitionData = (MaterialDefinitionData)System.Runtime.InteropServices.Marshal.PtrToStructure(materialDefinitionDataPtr, typeof(MaterialDefinitionData)); // If all dependants are here, parse object data bool dependencySuccess = MaterialDefinitionHandler.DependencyCheck(materialDefinitionData); if (dependencySuccess) { ParseMaterialDefinitionData(materialDefinitionData); // Delete object data ImportMenu.stpUnityDeleteMaterialDefinitionData(materialDefinitionDataPtr); } // If we are missing dependants store the object data else { materialDefinitionDataStore.Add(materialDefinitionDataPtr); } } catch (System.Exception e) { Debug.LogException(e); // Delete object data ImportMenu.stpUnityDeleteMaterialDefinitionData(materialDefinitionDataPtr); } }
// Iterate through material store that were missing dependants and check if we can create new material objects // or update existing material objects public static void IterateMaterialDefinitionStore() { for (int i = materialDefinitionDataStore.Count - 1; i >= 0; i--) { MaterialDefinitionData materialDefinitionData = (MaterialDefinitionData)System.Runtime.InteropServices.Marshal.PtrToStructure(materialDefinitionDataStore[i], typeof(MaterialDefinitionData)); // If all dependants are here, create the material bool dependencySuccess = MaterialDefinitionHandler.DependencyCheck(materialDefinitionData); if (dependencySuccess) { ParseMaterialDefinitionData(materialDefinitionData); // Delete object data ImportMenu.stpUnityDeleteMaterialDefinitionData(materialDefinitionDataStore[i]); // Remove from the store materialDefinitionDataStore.RemoveAt(i); } } }