-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from Algoryx/fix-import-agx-file
Fixed import of agx files.
- Loading branch information
Showing
24 changed files
with
1,047 additions
and
438 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace AGXUnity.IO | ||
{ | ||
public class RestoredAssetsRoot : ScriptableObject | ||
{ | ||
public enum ContainingType | ||
{ | ||
ShapeMaterial, | ||
ContactMaterial, | ||
FrictionModel, | ||
CableProperties, | ||
RenderMaterial, | ||
Mesh, | ||
Unknown // This is last - add entries before this. | ||
} | ||
|
||
public static RestoredAssetsRoot Create( string prefixName, ContainingType type ) | ||
{ | ||
var instance = ScriptableObject.CreateInstance<RestoredAssetsRoot>(); | ||
instance.Type = type; | ||
instance.name = FindName( prefixName, type ); | ||
|
||
return instance; | ||
} | ||
|
||
public static string FindName( string prefixName, ContainingType type ) | ||
{ | ||
return $"{prefixName}_{type}"; | ||
} | ||
|
||
public static ContainingType FindAssetType( System.Type type ) | ||
{ | ||
var index = System.Array.IndexOf( s_fileAssetTypeToTypeMap, type ); | ||
return index < 0 ? ContainingType.Unknown : (ContainingType)index; | ||
} | ||
|
||
public static ContainingType FindAssetType<T>() | ||
{ | ||
return FindAssetType( typeof( T ) ); | ||
} | ||
|
||
public static int FindAssetTypeIndex<T>() | ||
{ | ||
return (int)FindAssetType<T>(); | ||
} | ||
|
||
public static IEnumerable<ContainingType> Types | ||
{ | ||
get | ||
{ | ||
foreach ( ContainingType type in System.Enum.GetValues( typeof( ContainingType ) ) ) | ||
yield return type; | ||
} | ||
} | ||
|
||
public static System.Type GetType( ContainingType type ) | ||
{ | ||
return s_fileAssetTypeToTypeMap[ (int)type ]; | ||
} | ||
|
||
[SerializeField] | ||
private ContainingType m_type = ContainingType.Unknown; | ||
|
||
[HideInInspector] | ||
public ContainingType Type | ||
{ | ||
get { return m_type; } | ||
private set { m_type = value; } | ||
} | ||
|
||
private static System.Type[] s_fileAssetTypeToTypeMap = new System.Type[] | ||
{ | ||
typeof( ShapeMaterial ), | ||
typeof( ContactMaterial ), | ||
typeof( FrictionModel ), | ||
typeof( CableProperties ), | ||
typeof( Material ), | ||
typeof( Mesh ), | ||
null // Unknown assets, the only one valid to be null. | ||
}; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.