diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b06755a --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +/[Ll]ibrary/ +/[Tt]emp/ +/[Oo]bj/ +/[Bb]uild/ +/[Bb]uilds/ +/Assets/AssetStoreTools* +/Logs/ +/Packages/ +/.vs/ +# Autogenerated VS/MD solution and project files +ExportedObj/ +*.csproj +*.unityproj +*.sln +*.suo +*.tmp +*.user +*.userprefs +*.pidb +*.booproj +*.svd + + +# Unity3D generated meta files +*.pidb.meta + +# Unity3D Generated File On Crash Reports +sysinfo.txt + +# Builds +*.apk +*.unitypackage \ No newline at end of file diff --git a/Assets/uAdventure.meta b/Assets/uAdventure.meta new file mode 100644 index 0000000..a0c5e4e --- /dev/null +++ b/Assets/uAdventure.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ba0dbab258a9b604587e0e151191380c +folderAsset: yes +timeCreated: 1526790590 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Animations.meta b/Assets/uAdventure/Animations.meta new file mode 100644 index 0000000..ca3375a --- /dev/null +++ b/Assets/uAdventure/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1f68577136d796c46a2c0dc571e2b64d +folderAsset: yes +timeCreated: 1521428845 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Animations/Inventory.meta b/Assets/uAdventure/Animations/Inventory.meta new file mode 100644 index 0000000..4610279 --- /dev/null +++ b/Assets/uAdventure/Animations/Inventory.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 80984ee423ab27a41adf92e515be25d6 +folderAsset: yes +timeCreated: 1521428853 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Animations/Inventory/Highlight.anim b/Assets/uAdventure/Animations/Inventory/Highlight.anim new file mode 100644 index 0000000..7a0a36f --- /dev/null +++ b/Assets/uAdventure/Animations/Inventory/Highlight.anim @@ -0,0 +1,483 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!74 &7400000 +AnimationClip: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: Highlight + serializedVersion: 6 + m_Legacy: 0 + m_Compressed: 0 + m_UseHighQualityCurve: 1 + m_RotationCurves: [] + m_CompressedRotationCurves: [] + m_EulerCurves: + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: {x: 0, y: 0, z: 0} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + - serializedVersion: 2 + time: 0.33333334 + value: {x: 0, y: 0, z: 0} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + - serializedVersion: 2 + time: 0.5 + value: {x: 0, y: 0, z: 25} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + - serializedVersion: 2 + time: 0.8333333 + value: {x: 0, y: 0, z: -25} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + - serializedVersion: 2 + time: 1 + value: {x: 0, y: 0, z: 0} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + path: + m_PositionCurves: [] + m_ScaleCurves: + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: {x: 1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + - serializedVersion: 2 + time: 0.33333334 + value: {x: 1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + - serializedVersion: 2 + time: 0.44444445 + value: {x: 1.1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + - serializedVersion: 2 + time: 0.5555556 + value: {x: 1, y: 1.1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + - serializedVersion: 2 + time: 0.6666667 + value: {x: 1.1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + - serializedVersion: 2 + time: 0.7777778 + value: {x: 1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + - serializedVersion: 2 + time: 0.8888889 + value: {x: 1, y: 1.1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + - serializedVersion: 2 + time: 1 + value: {x: 1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + path: + m_FloatCurves: [] + m_PPtrCurves: [] + m_SampleRate: 90 + m_WrapMode: 0 + m_Bounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0, y: 0, z: 0} + m_ClipBindingConstant: + genericBindings: + - serializedVersion: 2 + path: 0 + attribute: 4 + script: {fileID: 0} + typeID: 4 + customType: 4 + isPPtrCurve: 0 + - serializedVersion: 2 + path: 0 + attribute: 3 + script: {fileID: 0} + typeID: 4 + customType: 0 + isPPtrCurve: 0 + pptrCurveMapping: [] + m_AnimationClipSettings: + serializedVersion: 2 + m_AdditiveReferencePoseClip: {fileID: 0} + m_AdditiveReferencePoseTime: 0 + m_StartTime: 0 + m_StopTime: 1 + m_OrientationOffsetY: 0 + m_Level: 0 + m_CycleOffset: 0 + m_HasAdditiveReferencePose: 0 + m_LoopTime: 0 + m_LoopBlend: 0 + m_LoopBlendOrientation: 0 + m_LoopBlendPositionY: 0 + m_LoopBlendPositionXZ: 0 + m_KeepOriginalOrientation: 0 + m_KeepOriginalPositionY: 1 + m_KeepOriginalPositionXZ: 0 + m_HeightFromFeet: 0 + m_Mirror: 0 + m_EditorCurves: + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.33333334 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.5 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.8333333 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: localEulerAnglesRaw.x + path: + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.33333334 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.5 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.8333333 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: localEulerAnglesRaw.y + path: + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.33333334 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.5 + value: 25 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.8333333 + value: -25 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: localEulerAnglesRaw.z + path: + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.33333334 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.44444445 + value: 1.1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.5555556 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.6666667 + value: 1.1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.7777778 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.8888889 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.x + path: + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.33333334 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.44444445 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.5555556 + value: 1.1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.6666667 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.7777778 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.8888889 + value: 1.1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.y + path: + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.33333334 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.44444445 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.5555556 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.6666667 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.7777778 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.8888889 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.z + path: + classID: 224 + script: {fileID: 0} + m_EulerEditorCurves: + - curve: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalEulerAngles.x + path: + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalEulerAngles.y + path: + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalEulerAngles.z + path: + classID: 224 + script: {fileID: 0} + m_HasGenericRootTransform: 1 + m_HasMotionFloatCurves: 0 + m_GenerateMotionCurves: 0 + m_Events: [] diff --git a/Assets/uAdventure/Animations/Inventory/Highlight.anim.meta b/Assets/uAdventure/Animations/Inventory/Highlight.anim.meta new file mode 100644 index 0000000..1d99090 --- /dev/null +++ b/Assets/uAdventure/Animations/Inventory/Highlight.anim.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c709baece99c709418da2565d41e200b +timeCreated: 1521428892 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 7400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Animations/Inventory/Insert.anim b/Assets/uAdventure/Animations/Inventory/Insert.anim new file mode 100644 index 0000000..c2d3bd1 --- /dev/null +++ b/Assets/uAdventure/Animations/Inventory/Insert.anim @@ -0,0 +1,353 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!74 &7400000 +AnimationClip: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: Insert + serializedVersion: 6 + m_Legacy: 0 + m_Compressed: 0 + m_UseHighQualityCurve: 1 + m_RotationCurves: [] + m_CompressedRotationCurves: [] + m_EulerCurves: [] + m_PositionCurves: [] + m_ScaleCurves: + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0.73333335 + value: {x: 1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + - serializedVersion: 2 + time: 1 + value: {x: 0.6, y: 0.6, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + path: + m_FloatCurves: + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: -168.6 + inSlope: 6.34893 + outSlope: 6.34893 + tangentMode: 0 + - serializedVersion: 2 + time: 0.36666667 + value: -91.93028 + inSlope: 140.105 + outSlope: 140.105 + tangentMode: 0 + - serializedVersion: 2 + time: 1 + value: -64.99997 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_AnchoredPosition.x + path: + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 105.8 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.73333335 + value: 120.43473 + inSlope: -134.45409 + outSlope: -134.45409 + tangentMode: 0 + - serializedVersion: 2 + time: 1 + value: 81.0264 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_AnchoredPosition.y + path: + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.16666667 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.73333335 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_Color.a + path: + classID: 114 + script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_PPtrCurves: [] + m_SampleRate: 60 + m_WrapMode: 0 + m_Bounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0, y: 0, z: 0} + m_ClipBindingConstant: + genericBindings: + - serializedVersion: 2 + path: 0 + attribute: 3 + script: {fileID: 0} + typeID: 4 + customType: 0 + isPPtrCurve: 0 + - serializedVersion: 2 + path: 0 + attribute: 1460864421 + script: {fileID: 0} + typeID: 224 + customType: 0 + isPPtrCurve: 0 + - serializedVersion: 2 + path: 0 + attribute: 538195251 + script: {fileID: 0} + typeID: 224 + customType: 0 + isPPtrCurve: 0 + - serializedVersion: 2 + path: 0 + attribute: 304273561 + script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + typeID: 114 + customType: 0 + isPPtrCurve: 0 + pptrCurveMapping: [] + m_AnimationClipSettings: + serializedVersion: 2 + m_AdditiveReferencePoseClip: {fileID: 0} + m_AdditiveReferencePoseTime: 0 + m_StartTime: 0 + m_StopTime: 1 + m_OrientationOffsetY: 0 + m_Level: 0 + m_CycleOffset: 0 + m_HasAdditiveReferencePose: 0 + m_LoopTime: 0 + m_LoopBlend: 0 + m_LoopBlendOrientation: 0 + m_LoopBlendPositionY: 0 + m_LoopBlendPositionXZ: 0 + m_KeepOriginalOrientation: 0 + m_KeepOriginalPositionY: 1 + m_KeepOriginalPositionXZ: 0 + m_HeightFromFeet: 0 + m_Mirror: 0 + m_EditorCurves: + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: -168.6 + inSlope: 6.34893 + outSlope: 6.34893 + tangentMode: 0 + - serializedVersion: 2 + time: 0.36666667 + value: -91.93028 + inSlope: 140.105 + outSlope: 140.105 + tangentMode: 0 + - serializedVersion: 2 + time: 1 + value: -64.99997 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_AnchoredPosition.x + path: + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 105.8 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.73333335 + value: 120.43473 + inSlope: -134.45409 + outSlope: -134.45409 + tangentMode: 0 + - serializedVersion: 2 + time: 1 + value: 81.0264 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_AnchoredPosition.y + path: + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0.73333335 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 1 + value: 0.6 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.x + path: + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0.73333335 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 1 + value: 0.6 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.y + path: + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0.73333335 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.z + path: + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.16666667 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.73333335 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_Color.a + path: + classID: 114 + script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_EulerEditorCurves: [] + m_HasGenericRootTransform: 0 + m_HasMotionFloatCurves: 0 + m_GenerateMotionCurves: 0 + m_Events: + - time: 1 + functionName: OnAnimationFinished + data: + objectReferenceParameter: {fileID: 0} + floatParameter: 0 + intParameter: 0 + messageOptions: 0 diff --git a/Assets/uAdventure/Animations/Inventory/Insert.anim.meta b/Assets/uAdventure/Animations/Inventory/Insert.anim.meta new file mode 100644 index 0000000..bdb74eb --- /dev/null +++ b/Assets/uAdventure/Animations/Inventory/Insert.anim.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 91f146bd07a12d647bdd47d8f995c36f +timeCreated: 1521430626 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 7400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Animations/Inventory/InventoryButton.controller b/Assets/uAdventure/Animations/Inventory/InventoryButton.controller new file mode 100644 index 0000000..64a71a9 --- /dev/null +++ b/Assets/uAdventure/Animations/Inventory/InventoryButton.controller @@ -0,0 +1,150 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!91 &9100000 +AnimatorController: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: InventoryButton + serializedVersion: 5 + m_AnimatorParameters: + - m_Name: Highlight + m_Type: 9 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 9100000} + m_AnimatorLayers: + - serializedVersion: 5 + m_Name: Base Layer + m_StateMachine: {fileID: 1107302045806759690} + m_Mask: {fileID: 0} + m_Motions: [] + m_Behaviours: [] + m_BlendingMode: 0 + m_SyncedLayerIndex: -1 + m_DefaultWeight: 0 + m_IKPass: 0 + m_SyncedLayerAffectsTiming: 0 + m_Controller: {fileID: 9100000} +--- !u!1101 &1101126177131592438 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: + m_Conditions: [] + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1102973122537986852} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.25 + m_TransitionOffset: 0 + m_ExitTime: 0.75 + m_HasExitTime: 1 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 +--- !u!1101 &1101383521780819176 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: Highlight + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1102478988737432534} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0 + m_TransitionOffset: 0 + m_ExitTime: 0 + m_HasExitTime: 1 + m_HasFixedDuration: 0 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 +--- !u!1102 &1102478988737432534 +AnimatorState: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: Highlight + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: + - {fileID: 1101126177131592438} + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 7400000, guid: c709baece99c709418da2565d41e200b, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: +--- !u!1102 &1102973122537986852 +AnimatorState: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: Idle + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: [] + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 0} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: +--- !u!1107 &1107302045806759690 +AnimatorStateMachine: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: Base Layer + m_ChildStates: + - serializedVersion: 1 + m_State: {fileID: 1102478988737432534} + m_Position: {x: 348, y: 228, z: 0} + - serializedVersion: 1 + m_State: {fileID: 1102973122537986852} + m_Position: {x: 96, y: 228, z: 0} + m_ChildStateMachines: [] + m_AnyStateTransitions: + - {fileID: 1101383521780819176} + m_EntryTransitions: [] + m_StateMachineTransitions: {} + m_StateMachineBehaviours: [] + m_AnyStatePosition: {x: 384, y: 144, z: 0} + m_EntryPosition: {x: 120, y: 120, z: 0} + m_ExitPosition: {x: 800, y: 120, z: 0} + m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} + m_DefaultState: {fileID: 1102973122537986852} diff --git a/Assets/uAdventure/Animations/Inventory/InventoryButton.controller.meta b/Assets/uAdventure/Animations/Inventory/InventoryButton.controller.meta new file mode 100644 index 0000000..5bb4258 --- /dev/null +++ b/Assets/uAdventure/Animations/Inventory/InventoryButton.controller.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e65fd66e536cd094c820f42d28d56925 +timeCreated: 1521428877 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 9100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Animations/Inventory/ItemParticle.controller b/Assets/uAdventure/Animations/Inventory/ItemParticle.controller new file mode 100644 index 0000000..8518d11 --- /dev/null +++ b/Assets/uAdventure/Animations/Inventory/ItemParticle.controller @@ -0,0 +1,69 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!91 &9100000 +AnimatorController: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: ItemParticle + serializedVersion: 5 + m_AnimatorParameters: [] + m_AnimatorLayers: + - serializedVersion: 5 + m_Name: Base Layer + m_StateMachine: {fileID: 1107149289285539298} + m_Mask: {fileID: 0} + m_Motions: [] + m_Behaviours: [] + m_BlendingMode: 0 + m_SyncedLayerIndex: -1 + m_DefaultWeight: 0 + m_IKPass: 0 + m_SyncedLayerAffectsTiming: 0 + m_Controller: {fileID: 9100000} +--- !u!1102 &1102647434472645446 +AnimatorState: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: Insert + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: [] + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 7400000, guid: 91f146bd07a12d647bdd47d8f995c36f, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: +--- !u!1107 &1107149289285539298 +AnimatorStateMachine: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: Base Layer + m_ChildStates: + - serializedVersion: 1 + m_State: {fileID: 1102647434472645446} + m_Position: {x: 288, y: 300, z: 0} + m_ChildStateMachines: [] + m_AnyStateTransitions: [] + m_EntryTransitions: [] + m_StateMachineTransitions: {} + m_StateMachineBehaviours: [] + m_AnyStatePosition: {x: 50, y: 20, z: 0} + m_EntryPosition: {x: 50, y: 120, z: 0} + m_ExitPosition: {x: 800, y: 120, z: 0} + m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} + m_DefaultState: {fileID: 1102647434472645446} diff --git a/Assets/uAdventure/Animations/Inventory/ItemParticle.controller.meta b/Assets/uAdventure/Animations/Inventory/ItemParticle.controller.meta new file mode 100644 index 0000000..d94ec74 --- /dev/null +++ b/Assets/uAdventure/Animations/Inventory/ItemParticle.controller.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: f41959127a1e3de418523f4f8df284b3 +timeCreated: 1521430605 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 9100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Editor.meta b/Assets/uAdventure/Editor.meta new file mode 100644 index 0000000..7ca030e --- /dev/null +++ b/Assets/uAdventure/Editor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 234f472325c4d3e4bbc98d89bbcc9a5f +folderAsset: yes +timeCreated: 1480436543 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Editor/AbstractEditorComponent.cs b/Assets/uAdventure/Editor/AbstractEditorComponent.cs new file mode 100644 index 0000000..7d10a5f --- /dev/null +++ b/Assets/uAdventure/Editor/AbstractEditorComponent.cs @@ -0,0 +1,62 @@ +using System; +using UnityEngine; + +namespace uAdventure.Editor +{ + public abstract class AbstractEditorComponent : LayoutWindow, EditorComponent + { + public static EditorComponentAttribute GetAttribute(Type type) + { + var attrs = type.GetCustomAttributes(typeof(EditorComponentAttribute), true); + if (attrs.Length > 0) + { + var componentAttr = attrs[0] as EditorComponentAttribute; + return componentAttr; + } + return null; + } + + public static void RegisterComponent(EditorComponent component) + { + var attr = GetAttribute(component.GetType()); + if (attr != null) + { + foreach (var t in attr.Types) + { + EditorWindowBase.RegisterComponent(t, component); + } + } + } + + public EditorComponentAttribute Attribute { + get + { + return GetAttribute(GetType()); + } + } + + protected AbstractEditorComponent(Rect rect, GUIContent content, GUIStyle style, params GUILayoutOption[] options) : base(rect, content, style, options) + { + RegisterComponent(this); + } + + public bool Collapsed { get; set; } + + public DataControl Target { get; set; } + + public virtual void OnDrawingGizmos() { } + + public virtual void OnDrawingGizmosSelected() { } + + public virtual void OnPostRender() { } + + public virtual void OnPreRender() { } + + public virtual void OnRender() { } + + void EditorComponent.DrawInspector() { Draw(-1); } + + public virtual bool Update() { return false; } + } + +} diff --git a/Assets/uAdventure/Editor/AbstractEditorComponent.cs.meta b/Assets/uAdventure/Editor/AbstractEditorComponent.cs.meta new file mode 100644 index 0000000..8539d4b --- /dev/null +++ b/Assets/uAdventure/Editor/AbstractEditorComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 57ef41617a5bd634a9b9853cb90ebd60 +timeCreated: 1506626708 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Editor/AbstractEditorComponentWithPreview.cs b/Assets/uAdventure/Editor/AbstractEditorComponentWithPreview.cs new file mode 100644 index 0000000..2275c39 --- /dev/null +++ b/Assets/uAdventure/Editor/AbstractEditorComponentWithPreview.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +namespace uAdventure.Editor +{ + public class AbstractEditorComponentWithPreview : PreviewLayoutWindow, EditorComponent + { + public EditorComponentAttribute Attribute + { + get { return AbstractEditorComponent.GetAttribute(GetType()); } + } + + public AbstractEditorComponentWithPreview(Rect rect, GUIContent content, GUIStyle style, params GUILayoutOption[] options) : base(rect, content, style, options) + { + AbstractEditorComponent.RegisterComponent(this); + } + + private DataControl target; + public DataControl Target { get { return target; } set + { + if (value != target) + { + target = value; + OnTargetChanged(); + } + } + } + + public bool Collapsed { get; set; } + + protected virtual void OnTargetChanged() { } + + public virtual void OnDrawingGizmos() {} + + public virtual void OnDrawingGizmosSelected() {} + + public virtual void OnPostRender() {} + + public virtual void OnPreRender() {} + + public virtual void OnRender() {} + + void EditorComponent.DrawInspector(){ DrawInspector(); } + + public virtual bool Update() { return false; } + } +} \ No newline at end of file diff --git a/Assets/uAdventure/Editor/AbstractEditorComponentWithPreview.cs.meta b/Assets/uAdventure/Editor/AbstractEditorComponentWithPreview.cs.meta new file mode 100644 index 0000000..f421f4d --- /dev/null +++ b/Assets/uAdventure/Editor/AbstractEditorComponentWithPreview.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c7788118532ab8d41a394e0b12bfcdea +timeCreated: 1506626719 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Editor/ActionsList.cs b/Assets/uAdventure/Editor/ActionsList.cs new file mode 100644 index 0000000..a80af41 --- /dev/null +++ b/Assets/uAdventure/Editor/ActionsList.cs @@ -0,0 +1,223 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using uAdventure.Core; +using uAdventure.Editor; +using UnityEditor; +using UnityEngine; + +public class ActionsList : ScriptableObject { + + private Texture2D conditionsTex = null; + private Texture2D noConditionsTex = null; + + private DataControlList actionsList; + private CustomActionDataControl customAction; + private ResourcesEditor resourcesEditor; + + + public void Awake() + { + resourcesEditor = new ResourcesEditor { ShowResourcesList = true }; + conditionsTex = Resources.Load("EAdventureData/img/icons/conditions-24x24"); + noConditionsTex = Resources.Load("EAdventureData/img/icons/no-conditions-24x24"); + + actionsList = new DataControlList() + { + footerHeight = 25, + elementHeight = 40, + Columns = new System.Collections.Generic.List() + { + new ColumnList.Column() + { + Text = TC.get("ActionsList.ActionName"), + SizeOptions = new GUILayoutOption[] { GUILayout.Width(150) } + }, + new ColumnList.Column() + { + Text = TC.get("DescriptionList.Description"), + SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) } + }, + new ColumnList.Column() + { + Text = TC.get("ActionsList.NeedsGoTo"), + SizeOptions = new GUILayoutOption[] { GUILayout.Width(120) } + }, + new ColumnList.Column() + { + Text = TC.get("ActionsList.Conditions"), + SizeOptions = new GUILayoutOption[] { GUILayout.Width(70) } + }, + new ColumnList.Column() + { + Text = TC.get("Element.Effects"), + SizeOptions = new GUILayoutOption[] { GUILayout.Width(70) } + } + }, + drawCell = (rect, index, column, isActive, isFocused) => + { + var action = actionsList.list[index] as ActionDataControl; + switch (column) + { + case 0: + { + var name = action.getContent() is CustomAction ? ((CustomAction)action.getContent()).getName() : action.getTypeName(); + + var leftHalf = new Rect(rect); + leftHalf.width /= 2f; + var rightHalf = new Rect(leftHalf); + rightHalf.x += leftHalf.width; + + if (action.hasIdTarget()) + { + rightHalf.height = 25; + EditorGUI.LabelField(leftHalf, name); + if (!isActive) + { + EditorGUI.LabelField(rightHalf, !string.IsNullOrEmpty(action.getIdTarget()) ? action.getIdTarget() : "---"); + } + else + { + EditorGUI.BeginChangeCheck(); + string selected = string.Empty; + string[] choices = new string[0]; + switch ((action.getContent() as Action).getType()) + { + case Action.DRAG_TO: + case Action.CUSTOM_INTERACT: + choices = Controller.Instance.IdentifierSummary.combineIds(new System.Type[] { typeof(Item), typeof(NPC), typeof(ActiveArea) }); + break; + case Action.GIVE_TO: + choices = Controller.Instance.IdentifierSummary.getIds(); + break; + case Action.USE_WITH: + choices = Controller.Instance.IdentifierSummary.combineIds(new System.Type[] { typeof(Item), typeof(ActiveArea) }); + break; + } + + var selectedIndex = EditorGUI.Popup(rightHalf, System.Array.FindIndex(choices, action.getIdTarget().Equals), choices); + if (EditorGUI.EndChangeCheck()) + { + if (selectedIndex >= 0 && selectedIndex < choices.Length) + { + selected = choices[selectedIndex]; + action.setIdTarget(selected); + } + } + } + } + else if (action.getType() == Controller.ACTION_TALK_TO) + { + EditorGUI.LabelField(leftHalf, name); + var triggerConversationEffect = action.getEffects().getEffects().Find(e => e is TriggerConversationEffect) as TriggerConversationEffect; + if (triggerConversationEffect != null) + { + var conversationId = triggerConversationEffect.getTargetId(); + if (GUI.Button(rightHalf, "Open")) + { + var conversationsList = Controller.Instance.SelectedChapterDataControl.getConversationsList(); + var conversation = conversationsList.getConversations().Find(c => c.getId() == conversationId); + Controller.Instance.SelectElement(conversation); + } + } + } + else + { + EditorGUI.LabelField(rect, name); + } + } + break; + case 1: + EditorGUI.BeginChangeCheck(); + var documentation = EditorGUI.TextArea(rect, action.getDocumentation() ?? string.Empty); + if (EditorGUI.EndChangeCheck()) action.setDocumentation(documentation); + break; + case 2: + if (Controller.Instance.PlayerMode== Controller.FILE_ADVENTURE_1STPERSON_PLAYER) + { + EditorGUI.LabelField(rect, TC.get("ActionsList.NotRelevant")); + } + else + { + var leftHalf = new Rect(rect); + leftHalf.width /= 2f; + var rightHalf = new Rect(leftHalf); + rightHalf.x += leftHalf.width; + + EditorGUI.BeginChangeCheck(); + var needsToGo = EditorGUI.Toggle(leftHalf, action.getNeedsGoTo()); + if (EditorGUI.EndChangeCheck()) action.setNeedsGoTo(needsToGo); + + EditorGUI.BeginChangeCheck(); + var distance = EditorGUI.IntField(rightHalf, action.getKeepDistance()); + if (EditorGUI.EndChangeCheck()) action.setKeepDistance(distance); ; + } + break; + case 3: + if (GUI.Button(rect, action.getConditions().getBlocksCount() > 0 ? conditionsTex : noConditionsTex)) + { + ConditionEditorWindow window = ScriptableObject.CreateInstance(); + window.Init(action.getConditions()); + } + break; + case 4: + if (GUI.Button(rect, "Effects")) + { + EffectEditorWindow window = ScriptableObject.CreateInstance(); + window.Init(action.getEffects()); + } + break; + + } + } + }; + + actionsList.onSelectCallback += (list) => + { + var i = list.index; + var actions = ActionsListDataControl.getActions(); + customAction = i != -1 && actions[i] is CustomActionDataControl ? actions[i] as CustomActionDataControl : null; + if(customAction != null) + { + resourcesEditor.Data = customAction; + } + }; + + actionsList.onRemoveCallback += (list) => + { + customAction = null; + }; + } + + + public ActionsListDataControl ActionsListDataControl { + get + { + return actionsList.DataControl as ActionsListDataControl; + } + set + { + if(actionsList.DataControl != value) + { + actionsList.SetData(value, (data) => (data as ActionsListDataControl).getActions().Cast().ToList()); + } + } + } + + + public void DoList(float height, bool canRequestMoreSpace) + { + if(ActionsListDataControl == null) + { + EditorGUILayout.HelpBox("Actions List not setted!", MessageType.Warning); + return; + } + + actionsList.DoList(customAction != null && !canRequestMoreSpace ? height - 160 : height); + + if (customAction != null) + { + resourcesEditor.DoLayout(); + } + } +} diff --git a/Assets/uAdventure/Editor/ActionsList.cs.meta b/Assets/uAdventure/Editor/ActionsList.cs.meta new file mode 100644 index 0000000..70c860f --- /dev/null +++ b/Assets/uAdventure/Editor/ActionsList.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 6b4e10f765438e34a90d107d4a1ce838 +timeCreated: 1520514748 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Editor/AnimationField.cs b/Assets/uAdventure/Editor/AnimationField.cs new file mode 100644 index 0000000..7a3e104 --- /dev/null +++ b/Assets/uAdventure/Editor/AnimationField.cs @@ -0,0 +1,95 @@ +using System.Linq; +using uAdventure.Core; +using UnityEditor; +using UnityEngine; + +namespace uAdventure.Editor +{ + public class AnimationField : FileChooser + { + + const string EMPTY = "assets/special/EmptyAnimation"; + + public AnimationField() + { + Empty = EMPTY; + } + + public override void DoLayout(params GUILayoutOption[] options) + { + var initialPath = Path; + EditorGUILayout.BeginHorizontal(options); + { + if (!string.IsNullOrEmpty(newFilePath)) + { + Path = newFilePath; + newFilePath = string.Empty; + } + DrawPathLayout(); + DrawSelectLayout(); + DrawView(); + DrawClearLayout(); + } + EditorGUILayout.EndHorizontal(); + GUI.changed = initialPath != Path || frameChanged; + } + + protected void DrawView() + { + var text = EMPTY.Equals(Path) ? TC.get("Resources.Create") : TC.get("Resources.Edit"); + if (GUILayout.Button(text, GUILayout.Width(GUI.skin.button.CalcSize(new GUIContent(text)).x))) + { + // For not-existing cutscene - show new cutscene name dialog + if (Path.Equals(EMPTY)) + { + ScriptableObject.CreateInstance().Init(this, ""); + } + else + { + EditCutscene(); + } + } + } + + string newFilePath = string.Empty; + private bool frameChanged = false; + + public override void OnDialogOk(string message, object workingObject = null, object workingObjectSecond = null) + { + + if (workingObject is CutsceneNameInputPopup) + { + newFilePath = message; + OnSlidesceneCreated(message); + EditCutscene(); + } + else if (workingObject is CutsceneSlidesEditor) + { + newFilePath = message; + } + else if (workingObject is uAdventure.Core.Animation) + { + frameChanged = true; + } + else + { + base.OnDialogOk(message, workingObject, workingObjectSecond); + EditCutscene(); + } + } + + void OnSlidesceneCreated(string val) + { + uAdventure.Core.Animation newAnim = new uAdventure.Core.Animation(val.Split('/').Last()); + newAnim.getFrame(0).setUri(EMPTY + "_01.png"); + AnimationWriter.WriteAnimation(val, newAnim); + AssetDatabase.ImportAsset("Assets/uAdventure/Resources/CurrentGame/" + val); + Path = val; + } + + void EditCutscene() + { + ScriptableObject.CreateInstance().Init(this, Path); + } + } +} diff --git a/Assets/uAdventure/Editor/AnimationField.cs.meta b/Assets/uAdventure/Editor/AnimationField.cs.meta new file mode 100644 index 0000000..ec7737a --- /dev/null +++ b/Assets/uAdventure/Editor/AnimationField.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 04e577f6ab0915949bf20b2e07e34343 +timeCreated: 1501161580 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Editor/Assets.meta b/Assets/uAdventure/Editor/Assets.meta new file mode 100644 index 0000000..2d59b6b --- /dev/null +++ b/Assets/uAdventure/Editor/Assets.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c81bf6cb9c018a141a2cad70fc61783a +folderAsset: yes +timeCreated: 1528124832 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Editor/Assets/CursorPostProcessor.cs b/Assets/uAdventure/Editor/Assets/CursorPostProcessor.cs new file mode 100644 index 0000000..cb476b1 --- /dev/null +++ b/Assets/uAdventure/Editor/Assets/CursorPostProcessor.cs @@ -0,0 +1,25 @@ +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace uAdventure.Editor +{ + public class CursorPostProcessor : AssetPostprocessor + { + private static readonly string[] categories = { "/cursors/" }; + + void OnPreprocessTexture() + { + string lowerCaseAssetPath = assetPath.ToLower(); + bool isuAdventureAsset = lowerCaseAssetPath.Contains("/uadventure/"); + bool shouldMakeItCursor = isuAdventureAsset && categories.Any(c => lowerCaseAssetPath.Contains(c)); + + if (shouldMakeItCursor) + { + var textureImporter = assetImporter as TextureImporter; + textureImporter.textureType = TextureImporterType.Cursor; + } + } + } +} + diff --git a/Assets/uAdventure/Editor/Assets/CursorPostProcessor.cs.meta b/Assets/uAdventure/Editor/Assets/CursorPostProcessor.cs.meta new file mode 100644 index 0000000..980f651 --- /dev/null +++ b/Assets/uAdventure/Editor/Assets/CursorPostProcessor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 44815d9745f91c74d909f5c5dbc8d172 +timeCreated: 1528124851 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Editor/Assets/EditorPostProcessor.cs b/Assets/uAdventure/Editor/Assets/EditorPostProcessor.cs new file mode 100644 index 0000000..7a07e7d --- /dev/null +++ b/Assets/uAdventure/Editor/Assets/EditorPostProcessor.cs @@ -0,0 +1,43 @@ +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace uAdventure.Editor +{ + public class EditorPostProcessor : AssetPostprocessor + { + private static readonly string[] categories = { "/icons/", "/help/", "/gui/", "/build-icons/" }; + + void OnPreprocessTexture() + { + string lowerCaseAssetPath = assetPath.ToLower(); + bool isuAdventureAsset = lowerCaseAssetPath.Contains("/uadventure/editor/"); + bool shouldMakeItGUI = isuAdventureAsset && categories.Any(c => lowerCaseAssetPath.Contains(c)); + + if (shouldMakeItGUI) + { + var textureImporter = assetImporter as TextureImporter; + textureImporter.textureType = TextureImporterType.GUI; + + // Effect icons sizes + if (lowerCaseAssetPath.Contains("/16x16/")) + { + textureImporter.maxTextureSize = 16; + } + if (lowerCaseAssetPath.Contains("/32x32/") || lowerCaseAssetPath.Contains("/build-icons/")) + { + textureImporter.maxTextureSize = 32; + } + if (lowerCaseAssetPath.Contains("/64x64/")) + { + textureImporter.maxTextureSize = 64; + } + if (lowerCaseAssetPath.Contains("/64x64-hot/")) + { + textureImporter.maxTextureSize = 64; + } + } + } + } +} + diff --git a/Assets/uAdventure/Editor/Assets/EditorPostProcessor.cs.meta b/Assets/uAdventure/Editor/Assets/EditorPostProcessor.cs.meta new file mode 100644 index 0000000..32e04c7 --- /dev/null +++ b/Assets/uAdventure/Editor/Assets/EditorPostProcessor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 15314bc760408ce48ad6a7e8080648a7 +timeCreated: 1528126525 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Editor/Assets/ReadWritePostProcessor.cs b/Assets/uAdventure/Editor/Assets/ReadWritePostProcessor.cs new file mode 100644 index 0000000..a6d3ff6 --- /dev/null +++ b/Assets/uAdventure/Editor/Assets/ReadWritePostProcessor.cs @@ -0,0 +1,24 @@ +using UnityEngine; +using UnityEditor; +using System.Linq; + +namespace uAdventure.Editor +{ + public class ReadWritePostProcessor : AssetPostprocessor + { + private static readonly string[] categories = { "/animation/", "/arrows/", "/background/", "/foreground/", "/defaultassets/", "/hud/", "/image/", "/options/", "/special/" }; + + void OnPreprocessTexture() + { + string lowerCaseAssetPath = assetPath.ToLower(); + bool isuAdventureAsset = lowerCaseAssetPath.Contains("/uadventure/"); + bool shouldActiveReadWrite = isuAdventureAsset && categories.Any(c => lowerCaseAssetPath.Contains(c)); + + if (shouldActiveReadWrite) + { + var textureImporter = assetImporter as TextureImporter; + textureImporter.isReadable = true; + } + } + } +} \ No newline at end of file diff --git a/Assets/uAdventure/Editor/Assets/ReadWritePostProcessor.cs.meta b/Assets/uAdventure/Editor/Assets/ReadWritePostProcessor.cs.meta new file mode 100644 index 0000000..662c674 --- /dev/null +++ b/Assets/uAdventure/Editor/Assets/ReadWritePostProcessor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 447b07935daa6ec4da9cf6ba8d195c0f +timeCreated: 1528125303 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Editor/Assets/SpritePostProcessor.cs b/Assets/uAdventure/Editor/Assets/SpritePostProcessor.cs new file mode 100644 index 0000000..df855bf --- /dev/null +++ b/Assets/uAdventure/Editor/Assets/SpritePostProcessor.cs @@ -0,0 +1,26 @@ +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace uAdventure.Editor +{ + public class SpritePostProcessor : AssetPostprocessor + { + private static readonly string[] categories = { "/animation/", "/arrows/", "/background/", "/defaultassets/", "/hud/", "/icon/", "/image/", "/options/", "/special/" }; + + void OnPreprocessTexture() + { + string lowerCaseAssetPath = assetPath.ToLower(); + bool isuAdventureAsset = lowerCaseAssetPath.Contains("/uadventure/"); + bool shouldMakeItSprite = isuAdventureAsset && categories.Any(c => lowerCaseAssetPath.Contains(c)); + + if (shouldMakeItSprite) + { + var textureImporter = assetImporter as TextureImporter; + textureImporter.textureType = TextureImporterType.Sprite; + textureImporter.npotScale = TextureImporterNPOTScale.None; + } + } + } +} + diff --git a/Assets/uAdventure/Editor/Assets/SpritePostProcessor.cs.meta b/Assets/uAdventure/Editor/Assets/SpritePostProcessor.cs.meta new file mode 100644 index 0000000..ff61a0b --- /dev/null +++ b/Assets/uAdventure/Editor/Assets/SpritePostProcessor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 0de143c5efac32249b626e1b4dc4578f +timeCreated: 1528125759 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Editor/Assets/VideoPostProcessor.cs b/Assets/uAdventure/Editor/Assets/VideoPostProcessor.cs new file mode 100644 index 0000000..fb74efb --- /dev/null +++ b/Assets/uAdventure/Editor/Assets/VideoPostProcessor.cs @@ -0,0 +1,74 @@ +using UnityEngine; +using UnityEditor; +using System.Linq; + +namespace uAdventure.Editor +{ + public class VideoPostProcessor : AssetPostprocessor + { + private static readonly string[] categories = { "/video/" }; + + void OnPreprocessAsset() + { + string lowerCaseAssetPath = assetPath.ToLower(); + bool isuAdventureAsset = lowerCaseAssetPath.Contains("/uadventure/"); + bool shouldInitVideoClipSettings = isuAdventureAsset && categories.Any(c => lowerCaseAssetPath.Contains(c)); + + if (shouldInitVideoClipSettings) + { + var videoClipImporter = assetImporter as VideoClipImporter; + if(videoClipImporter == null) + { + return; + } + + var width = videoClipImporter.GetResizeWidth(VideoResizeMode.OriginalSize); + var height = videoClipImporter.GetResizeHeight(VideoResizeMode.OriginalSize); + var ratio = width / (float)height; + + // Default for standalone + videoClipImporter.defaultTargetSettings = new VideoImporterTargetSettings() + { + enableTranscoding = true, + resizeMode = width <= 1920 || height <= 1080 ? VideoResizeMode.OriginalSize : VideoResizeMode.CustomSize, + customWidth = ratio > 1 ? 1920 : Mathf.FloorToInt(1080 * ratio), + customHeight = ratio < 1 ? 1080 : Mathf.FloorToInt(1920 / ratio), + aspectRatio = VideoEncodeAspectRatio.NoScaling, + codec = VideoCodec.Auto, + spatialQuality = VideoSpatialQuality.HighSpatialQuality, + bitrateMode = VideoBitrateMode.High + }; + + + // Valid names: 'Default', 'Web', 'Standalone', 'iOS', 'Android', 'WebGL', 'PS4', 'PSP2', 'XBox360', 'XboxOne', 'WP8', or 'WSA' + // From: https://github.com/Unity-Technologies/UnityCsReference/blob/11bcfd801fccd2a52b09bb6fd636c1ddcc9f1705/artifacts/generated/bindings_old/common/Editor/VideoImporterBindings.gen.cs#L224 + + // Android + videoClipImporter.SetTargetSettings("Android", new VideoImporterTargetSettings() + { + enableTranscoding = true, + resizeMode = width <= 1280 || height <= 720 ? VideoResizeMode.OriginalSize : VideoResizeMode.CustomSize, + customWidth = ratio > 1 ? 1280 : Mathf.FloorToInt(720 * ratio), + customHeight = ratio < 1 ? 720 : Mathf.FloorToInt(1280 / ratio), + aspectRatio = VideoEncodeAspectRatio.NoScaling, + codec = VideoCodec.Auto, + spatialQuality = VideoSpatialQuality.LowSpatialQuality, + bitrateMode = VideoBitrateMode.Low + }); + + // iOS + videoClipImporter.SetTargetSettings("iOS", new VideoImporterTargetSettings() + { + enableTranscoding = true, + resizeMode = width <= 1280 || height <= 720 ? VideoResizeMode.OriginalSize : VideoResizeMode.CustomSize, + customWidth = ratio > 1 ? 1280 : Mathf.FloorToInt(720 * ratio), + customHeight = ratio < 1 ? 720 : Mathf.FloorToInt(1280 / ratio), + aspectRatio = VideoEncodeAspectRatio.NoScaling, + codec = VideoCodec.Auto, + spatialQuality = VideoSpatialQuality.MediumSpatialQuality, + bitrateMode = VideoBitrateMode.Medium + }); + } + } + } +} diff --git a/Assets/uAdventure/Editor/Assets/VideoPostProcessor.cs.meta b/Assets/uAdventure/Editor/Assets/VideoPostProcessor.cs.meta new file mode 100644 index 0000000..7b5a620 --- /dev/null +++ b/Assets/uAdventure/Editor/Assets/VideoPostProcessor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b8f626733ae009444adec178e6cb11e5 +timeCreated: 1528127334 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Editor/BuildingUtil.meta b/Assets/uAdventure/Editor/BuildingUtil.meta new file mode 100644 index 0000000..15840b5 --- /dev/null +++ b/Assets/uAdventure/Editor/BuildingUtil.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 8278e7b30b73e7a4cb22dcf3d8ee6dd0 +folderAsset: yes +timeCreated: 1526761382 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Editor/BuildingUtil/FileId.cs b/Assets/uAdventure/Editor/BuildingUtil/FileId.cs new file mode 100644 index 0000000..c25acb1 --- /dev/null +++ b/Assets/uAdventure/Editor/BuildingUtil/FileId.cs @@ -0,0 +1,442 @@ +using System; +using System.Linq; +using System.Collections.Generic; +using System.Security.Cryptography; +using UnityEngine; +using UnityEditor; +using System.Reflection; + +// Taken from http://www.superstarcoders.com/blogs/posts/md4-hash-algorithm-in-c-sharp.aspx +// Probably not the best implementation of MD4, but it works. + +namespace uAdventure.Editor +{ + public class MD4 : HashAlgorithm + { + private uint _a; + private uint _b; + private uint _c; + private uint _d; + private uint[] _x; + private int _bytesProcessed; + + public MD4() + { + _x = new uint[16]; + + Initialize(); + } + + public override void Initialize() + { + _a = 0x67452301; + _b = 0xefcdab89; + _c = 0x98badcfe; + _d = 0x10325476; + + _bytesProcessed = 0; + } + + protected override void HashCore(byte[] array, int offset, int length) + { + ProcessMessage(Bytes(array, offset, length)); + } + + protected override byte[] HashFinal() + { + try + { + ProcessMessage(Padding()); + + return new[] { _a, _b, _c, _d }.SelectMany(word => Bytes(word)).ToArray(); + } + finally + { + Initialize(); + } + } + + private void ProcessMessage(IEnumerable bytes) + { + foreach (byte b in bytes) + { + int c = _bytesProcessed & 63; + int i = c >> 2; + int s = (c & 3) << 3; + + _x[i] = (_x[i] & ~((uint)255 << s)) | ((uint)b << s); + + if (c == 63) + { + Process16WordBlock(); + } + + _bytesProcessed++; + } + } + + private static IEnumerable Bytes(byte[] bytes, int offset, int length) + { + for (int i = offset; i < length; i++) + { + yield return bytes[i]; + } + } + + private IEnumerable Bytes(uint word) + { + yield return (byte)(word & 255); + yield return (byte)((word >> 8) & 255); + yield return (byte)((word >> 16) & 255); + yield return (byte)((word >> 24) & 255); + } + + private IEnumerable Repeat(byte value, int count) + { + for (int i = 0; i < count; i++) + { + yield return value; + } + } + + private IEnumerable Padding() + { + return Repeat(128, 1) + .Concat(Repeat(0, ((_bytesProcessed + 8) & 0x7fffffc0) + 55 - _bytesProcessed)) + .Concat(Bytes((uint)_bytesProcessed << 3)) + .Concat(Repeat(0, 4)); + } + + private void Process16WordBlock() + { + uint aa = _a; + uint bb = _b; + uint cc = _c; + uint dd = _d; + + foreach (int k in new[] { 0, 4, 8, 12 }) + { + aa = Round1Operation(aa, bb, cc, dd, _x[k], 3); + dd = Round1Operation(dd, aa, bb, cc, _x[k + 1], 7); + cc = Round1Operation(cc, dd, aa, bb, _x[k + 2], 11); + bb = Round1Operation(bb, cc, dd, aa, _x[k + 3], 19); + } + + foreach (int k in new[] { 0, 1, 2, 3 }) + { + aa = Round2Operation(aa, bb, cc, dd, _x[k], 3); + dd = Round2Operation(dd, aa, bb, cc, _x[k + 4], 5); + cc = Round2Operation(cc, dd, aa, bb, _x[k + 8], 9); + bb = Round2Operation(bb, cc, dd, aa, _x[k + 12], 13); + } + + foreach (int k in new[] { 0, 2, 1, 3 }) + { + aa = Round3Operation(aa, bb, cc, dd, _x[k], 3); + dd = Round3Operation(dd, aa, bb, cc, _x[k + 8], 9); + cc = Round3Operation(cc, dd, aa, bb, _x[k + 4], 11); + bb = Round3Operation(bb, cc, dd, aa, _x[k + 12], 15); + } + + unchecked + { + _a += aa; + _b += bb; + _c += cc; + _d += dd; + } + } + + private static uint ROL(uint value, int numberOfBits) + { + return (value << numberOfBits) | (value >> (32 - numberOfBits)); + } + + private static uint Round1Operation(uint a, uint b, uint c, uint d, uint xk, int s) + { + unchecked + { + return ROL(a + ((b & c) | (~b & d)) + xk, s); + } + } + + private static uint Round2Operation(uint a, uint b, uint c, uint d, uint xk, int s) + { + unchecked + { + return ROL(a + ((b & c) | (b & d) | (c & d)) + xk + 0x5a827999, s); + } + } + + private static uint Round3Operation(uint a, uint b, uint c, uint d, uint xk, int s) + { + unchecked + { + return ROL(a + (b ^ c ^ d) + xk + 0x6ed9eba1, s); + } + } + } + + public static class FileIDUtil + { + public static IEnumerable FindDerivedTypes(IEnumerable types, Type baseType) + { + return types.Where(t => baseType.IsAssignableFrom(t)); + } + + private static IEnumerable GetTypesInNamespace(string nameSpace) + { + return AppDomain.CurrentDomain.GetAssemblies() + .SelectMany(t => t.GetTypes()) + .Where(t => t.IsClass && t.Namespace == nameSpace); + } + + public static void GenerateGUIDMap() + { + // Last argument is output path + var args = System.Environment.GetCommandLineArgs(); + string outputPath = args[args.Length - 1]; + + var runnerAssemblyFile = "Assets/uAdventure/Plugins/uAdventureScripts.dll"; + var editorAssemblyFile = "Assets/uAdventure/Editor/Plugins/uAdventureEditor.dll"; + var trackerAssemblyFile = "Assets/uAdventure/Plugins/unity-tracker/UnityTracker.dll"; + + Dictionary> guids = new Dictionary>(); + var monobehaviours = FindDerivedTypes(GetTypesInNamespace("uAdventure.Runner"), typeof(MonoBehaviour)) + .Select(t => new KeyValuePair(t, runnerAssemblyFile)) + .Union(FindDerivedTypes(GetTypesInNamespace("uAdventure.GameSelector"), typeof(MonoBehaviour)) + .Select(t => new KeyValuePair(t, runnerAssemblyFile))) + .Union(FindDerivedTypes(GetTypesInNamespace("uAdventure.Editor"), typeof(EditorWindow)) + .Select(t => new KeyValuePair(t, editorAssemblyFile))) + .Union(FindDerivedTypes(GetTypesInNamespace("RAGE.Analytics"), typeof(MonoBehaviour)) + .Select(t => new KeyValuePair(t, trackerAssemblyFile))); + + var scripts = System.IO.Directory.GetFiles("./", "*.cs", System.IO.SearchOption.AllDirectories); + + foreach(var s in scripts) + { + Debug.Log("Script found: " + s); + } + + foreach (var kv in monobehaviours) + { + // Iterate over all uAdventure monobehaviours + Type type = kv.Key; + string assemblyFile = kv.Value; + Debug.Log("Type found: " + type.ToString()); + var path = Array.Find(scripts, s => s.EndsWith("\\" + type.Name + ".cs")); + if (!string.IsNullOrEmpty(path)) + { + var cleanPath = path.Substring(2, path.Length - 2).Replace("\\", "/"); + var guid = AssetDatabase.AssetPathToGUID(cleanPath); + guids[type] = new KeyValuePair(guid, assemblyFile); + Debug.Log("Adding guid and file id for " + type.ToString() + ": " + Compute(type) + ", " + guid + ", " + assemblyFile); + } + } + + var fileInfo = new System.IO.FileInfo(outputPath); + if (!System.IO.Directory.Exists(fileInfo.DirectoryName)) + System.IO.Directory.CreateDirectory(fileInfo.DirectoryName); + System.IO.File.WriteAllText(outputPath, String.Join("\n", guids.Select(kv => kv.Value.Key + "," + Compute(kv.Key) + "," + kv.Value.Value).ToArray())); + } + + public static void SwitchPrefabsGUIDsToDLL() + { + // Last two arguments are guidpath and dllpath + var args = System.Environment.GetCommandLineArgs(); + string guidsPath = args[args.Length - 1]; + + var text = System.IO.File.ReadAllLines(guidsPath); + var guidToFileIdAndDllGUID = new Dictionary>(); + var fileIdInDll = new Dictionary(); + + foreach (var tokens in text.Select(l => l.Split(','))) + { + guidToFileIdAndDllGUID[tokens[0]] = new KeyValuePair(tokens[1], tokens[2]); + fileIdInDll[tokens[1]] = tokens[2]; + } + + List assetsToReimport = new List(); + + var layouts = System.IO.Directory.GetFiles(".\\", "*.wlt", System.IO.SearchOption.AllDirectories); + Debug.Log("Layouts found: " + layouts.Length); + foreach (var layout in layouts) + { + Debug.Log("Layout: " + layout); + FixFile(layout, guidToFileIdAndDllGUID, fileIdInDll); + } + + var scenes = System.IO.Directory.GetFiles(".\\", "*.unity", System.IO.SearchOption.AllDirectories); + Debug.Log("Scenes found: " + scenes.Length); + foreach (var scene in scenes) + { + Debug.Log("Scene: " + scene); + if (FixFile(scene, guidToFileIdAndDllGUID, fileIdInDll)) + { + assetsToReimport.Add(scene); + } + } + + var prefabs = System.IO.Directory.GetFiles(".\\", "*.prefab", System.IO.SearchOption.AllDirectories); + Debug.Log("Prefabs found: " + prefabs.Length); + foreach (var prefab in prefabs) + { + Debug.Log("Prefab: " + prefab); + if (FixFile(prefab, guidToFileIdAndDllGUID, fileIdInDll)) + { + assetsToReimport.Add(prefab); + } + } + + ImportAssets(assetsToReimport.ToArray()); + } + private static void ImportAssets(string[] paths) + { + try + { + AssetDatabase.StartAssetEditing(); + foreach (string path in paths) + AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate | ImportAssetOptions.ImportRecursive); + } + finally + { + AssetDatabase.StopAssetEditing(); + } + } + + private static bool FixFile(string file, Dictionary> guidToFileIdAndDllGUID, Dictionary fileIdInDll) + { + var fileText = System.IO.File.ReadAllLines(file); + bool modified = false; + for (int i = 0; i < fileText.Length; ++i) + { + if (fileText[i].StartsWith("MonoBehaviour:")) + { + // Reactivate the object + fileText[i + 1] = " m_ObjectHideFlags: 1"; + } + + if (fileText[i].StartsWith(" m_Script: ")) + { + Dictionary attrs = ParseLine(fileText[i]); + var fileId = attrs["fileID"]; + var isRuntime = fileId == "11500000"; + + var existsInRuntime = isRuntime && guidToFileIdAndDllGUID.ContainsKey(attrs["guid"]); + var existsCompiled = !isRuntime && fileIdInDll.ContainsKey(fileId); + + if (!existsInRuntime && !existsCompiled) + { + if (isRuntime) + { + Debug.LogWarning("Couldn't find type for: " + attrs["guid"]); + } + continue; + } + + string dll; + if(isRuntime) + { + // Is runtime script + var fileIdAndDll = guidToFileIdAndDllGUID[attrs["guid"]]; + fileId = fileIdAndDll.Key; + dll = fileIdAndDll.Value; + } + else + { + // Is editor script + dll = fileIdInDll[fileId]; + } + + var guid = AssetDatabase.AssetPathToGUID(dll); + if (string.IsNullOrEmpty(guid)) + { + Debug.LogWarning("Failed to get GUID for: " + dll); + continue; + } + + attrs["fileID"] = fileId; + attrs["guid"] = guid; + fileText[i] = " m_Script: " + EncodeLine(attrs); + Debug.Log("Fixed! " + fileText[i]); + modified = true; + } + /*var prefabAsset = AssetDatabase.LoadAllAssetsAtPath(prefab)[0]; + Debug.Log(prefabAsset.GetType()); + var prefabObject = new SerializedObject(prefabAsset); + // Iterate over all uAdventure monobehaviours + foreach (var obj in prefabObject.FindProperty("m_Component")) + { + var property = obj as SerializedProperty; + Debug.Log("Component:"); + var reference = property.FindPropertyRelative("component").objectReferenceValue; + Debug.Log(reference); + foreach(var val in reference.GetIterator()) + { + var varlProp = val as SerializedProperty; + Debug.Log(varlProp.name); + } + var scriptProperty = reference.FindProperty("m_Script"); + if(scriptProperty != null) + { + Debug.Log(scriptProperty.serializedObject); + } + }*/ + } + + if (modified) + { + System.IO.File.WriteAllLines(file, fileText); + } + + return modified; + } + + private static string EncodeLine(Dictionary attrs) + { + return "{" + attrs.Select(kv => kv.Key + ": " + kv.Value).Aggregate((s1, s2) => s1 + ", " + s2) + "}"; + } + + private static Dictionary ParseLine(string line) + { + var start = line.IndexOf("{"); + string areaToParse = line.Substring(line.IndexOf("{") + 1, line.IndexOf("}") - start - 1); + string[] tokens = areaToParse.Split(','); + + Dictionary attrs = new Dictionary(); + foreach (var token in tokens) + { + var dotsPos = token.IndexOf(':'); + var key = token.Substring(0, dotsPos).Trim(); + var value = token.Substring(dotsPos + 1).Trim(); + attrs.Add(key, value); + } + + return attrs; + } + + public static int Compute(Type t) + { + return ComputeName(t.Namespace + t.Name); + } + public static int ComputeName(string name) + { + string toBeHashed = "s\0\0\0" + name; + + using (HashAlgorithm hash = new MD4()) + { + byte[] hashed = hash.ComputeHash(System.Text.Encoding.UTF8.GetBytes(toBeHashed)); + + int result = 0; + + for (int i = 3; i >= 0; --i) + { + result <<= 8; + result |= hashed[i]; + } + + return result; + } + } + } +} \ No newline at end of file diff --git a/Assets/uAdventure/Editor/BuildingUtil/FileId.cs.meta b/Assets/uAdventure/Editor/BuildingUtil/FileId.cs.meta new file mode 100644 index 0000000..eee79b9 --- /dev/null +++ b/Assets/uAdventure/Editor/BuildingUtil/FileId.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 43ca0c4e66de6a44e8273dcfa136659e +timeCreated: 1526578510 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uAdventure/Editor/ButtonList.cs b/Assets/uAdventure/Editor/ButtonList.cs new file mode 100644 index 0000000..2329298 --- /dev/null +++ b/Assets/uAdventure/Editor/ButtonList.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEditor; +using UnityEditorInternal; +using UnityEngine; + +namespace uAdventure.Editor +{ + public class ButtonList : ColumnList + { + public float buttonWidth = 25; + + private class Defaults + { + public float buttonLeftMargin = 4f; + public float buttonTopMargin = -1f; + } + + private static Defaults m_defaults; + private static Defaults defaults + { + get + { + return m_defaults ?? (m_defaults = new Defaults()); + } + } + + public class Button + { + public GUIContent content; + public float width = 25f; + public ButtonEnabledDeletate onButtonEnabledCallback; + public ButtonPressedDelegate onButtonPressedCallback; + } + + public List