diff --git a/popcorn/Assets/USAYAUnityLib/AnimationValidator.meta b/popcorn/Assets/USAYAUnityLib/AnimationValidator.meta new file mode 100755 index 00000000..5f18e6d8 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/AnimationValidator.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5ef5cb85bff006b48b311c18b5b66ec9 +folderAsset: yes +timeCreated: 1524593791 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/AnimationValidator/Editor.meta b/popcorn/Assets/USAYAUnityLib/AnimationValidator/Editor.meta new file mode 100755 index 00000000..8824a1f3 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/AnimationValidator/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9117919f6e527984394914b0933e1c09 +folderAsset: yes +timeCreated: 1524310466 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/AnimationValidator/Editor/AnimationValidator.cs b/popcorn/Assets/USAYAUnityLib/AnimationValidator/Editor/AnimationValidator.cs new file mode 100755 index 00000000..740af6f1 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/AnimationValidator/Editor/AnimationValidator.cs @@ -0,0 +1,279 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEditor.Animations; +using UnityEngine; + +namespace StaTech.AnimationValidator { + public static class AnimationValidator { + private static Animator _animator; + + private static readonly string[] CurveNames = { + "m_PositionCurves", + "m_ScaleCurves", + "m_FloatCurves", + "m_PPtrCurves", + "m_EditorCurves", + "m_EulerEditorCurves" + }; + + private static readonly string PathPropName = "path"; + private static readonly string AttributePropName = "attribute"; + + private static List _clipValidations; + + public static List ValidateAnimation(){ + if(Selection.activeGameObject == null){ + return null; + } + + var selectedTransform = Selection.activeGameObject.transform; + // アニメーションクリップを取り出すAnimator + _animator = selectedTransform.GetComponent(); + + if(_animator == null){ + // 警告window出す + EditorUtility.DisplayDialog("エラー", "選択したオブジェクトにAnimatorがついていません", "閉じる"); + return null; + } + + var runTimeAnimatorController = _animator.runtimeAnimatorController; + var animationController = runTimeAnimatorController as AnimatorController; + + if(animationController == null){ + // 警告window出す + EditorUtility.DisplayDialog("エラー", "AnimatorにAnimationControllerが設定されていません", "閉じる"); + return null; + } + + if(_clipValidations == null){ + _clipValidations = new List(); + }else{ + _clipValidations.Clear(); + } + + // 全てのレイヤーを取り出す + for(var i = 0; i < animationController.layers.Length; ++i){ + var layer = animationController.layers[i]; + var stateMachine = layer.stateMachine; + // 全てのステートを取り出す + for(var j = 0; j < stateMachine.states.Length; ++j){ + var state = stateMachine.states[j]; + var clip = state.state.motion as AnimationClip; + if(clip){ + var validationData = FindLostAnimations(clip, selectedTransform); + _clipValidations.Add(validationData); + } + } + } + + return _clipValidations; + } + + public static void ExecuteUnitRecovery(GameObject selected, ClipValidationContainer container, Action onProgressChanged){ + var childObjectsNames = GetChildObjectNames(selected); + Recovery(container, ref childObjectsNames, onProgressChanged); + EditorUtility.ClearProgressBar(); + } + + public static void ExecuteAllRecovery(GameObject selected, List containers, Action onProgressChanged){ + var childObjectsNames = GetChildObjectNames(selected); + var targetCount = containers.Count; + for(var i = 0; i < containers.Count; ++i){ + var container = containers[i]; + Recovery(container, ref childObjectsNames); + if(onProgressChanged != null){ + onProgressChanged.Invoke(container.ClipName, (float)i / targetCount); + } + } + + AssetDatabase.SaveAssets(); + EditorUtility.ClearProgressBar(); + } + + private static ClipValidationContainer FindLostAnimations(AnimationClip clip, Transform root){ + var lostAnimations = new List(); + var serializedClip = new SerializedObject(clip); + // clipはいくつかのカーブをもっている + foreach(var curveName in CurveNames){ + var curves = serializedClip.FindProperty(curveName); + var curveCount = curves.arraySize; + for(var i = 0; i < curveCount; ++i){ + var curve = curves.GetArrayElementAtIndex(i); + var pathProperty = curve.FindPropertyRelative(PathPropName); + var attributeProperty = curve.FindPropertyRelative(AttributePropName); + var attribute = attributeProperty != null ? attributeProperty.stringValue : "Position"; + // ルートの直下からの相対パスが入ってる + var path = pathProperty.stringValue; + var result = root.Find(path); + if(result == null){ + var lost = new LostProperty { + ObjectName = GetObjectName(path), + PropPath = path, + AttributeName = attribute, + SerializedProperty = pathProperty, + SerializedClip = serializedClip, + State = FixState.Lost + }; + lostAnimations.Add(lost); + } + } + } + + var clipLost = new ClipValidationContainer(lostAnimations, clip); + return clipLost; + } + + private static void Recovery(ClipValidationContainer validationContainer, ref List paths, Action onUnitProgressChanged = null){ + for(var i = 0; i < validationContainer.LostProperties.Count; ++i){ + var anim = validationContainer.LostProperties[i]; + var pathInHierarchy = paths.Where(path => path.ObjectName == anim.ObjectName).ToList(); + var hierarchyCount = pathInHierarchy.Count; + + if(onUnitProgressChanged != null){ + onUnitProgressChanged.Invoke(anim.ObjectName, (float)i / validationContainer.LostProperties.Count); + } + + if(hierarchyCount == 0){ + //同名のobjectNameが存在しない + anim.State = FixState.ErrorNoSameName; + continue; + } + + if(hierarchyCount >= 2){ + // 複数のobjectが存在するから修正出来ない + anim.State = FixState.ErrorDuplicate; + continue; + } + + + // 修復処理 + var correctPath = pathInHierarchy.First().RelativePath; + Debug.Log(anim.PropPath + "を" + correctPath + "に修正"); + anim.State = FixState.Fixed; + anim.SerializedProperty.stringValue = correctPath; + anim.SerializedClip.ApplyModifiedProperties(); + } + } + + public static string GetObjectName(string path){ + if(string.IsNullOrEmpty(path)){ + return ""; + } + + var separated = path.Split('/'); + return separated[separated.Length - 1]; + } + + private static List GetChildObjectNames(GameObject root){ + var children = GetAllObjects(root); + + return children.Select(obj => { + // なんか進捗とか出す + return new PathModel(obj, root.name); + }).ToList(); + } + + public static List GetAllObjects(GameObject obj){ + var allChildren = new List(); + GetChildren(obj, ref allChildren); + return allChildren; + } + + public static void GetChildren(GameObject obj, ref List allChildren){ + var children = obj.GetComponentInChildren (); + // 子要素がいなければ終了 + if(children.childCount == 0){ + return; + } + foreach(Transform ob in children){ + allChildren.Add(ob.gameObject); + GetChildren(ob.gameObject, ref allChildren); + } + } + + public static string ParentRelativePath(Transform t, string path, string rootName){ + var parent = t.parent; + if(parent == null){ + if(t.name != rootName){ + Debug.LogError("不正な階層指定してます" + rootName); + } + + return path; + } + + if(parent.name == rootName){ + return path; + } + path = parent.name + "/" + path; + + return ParentRelativePath(parent, path, rootName); + } + + private class PathModel { + public readonly string ObjectName; + public readonly string RelativePath; + + public PathModel(GameObject go, string rootName){ + ObjectName = go.name; + RelativePath = ParentRelativePath(go.transform, ObjectName, rootName); + } + } + } + + public class ClipValidationContainer{ + public ClipValidationContainer(List lostAnims, AnimationClip clip){ + LostProperties = lostAnims; + ClipName = clip.name; + } + + public string ClipName { + get; + set; + } + + public bool HasNoError { + get{ + return LostProperties.Count == 0 || LostProperties.All(p => p.State == FixState.Fixed); + } + } + + public List LostProperties { + get; + private set; + } + } + + public class LostProperty { + public string AttributeName; + + /// + /// オブジェクトの名前 + /// 一意である必要がある + /// + public string ObjectName; + + /// + /// アニメーション内のプロパティのパス + /// + public string PropPath; + + public SerializedObject SerializedClip; + + public SerializedProperty SerializedProperty; + + /// + /// 修復済みフラグ + /// + public FixState State; + } + + public enum FixState { + None, + Lost, + ErrorNoSameName, + ErrorDuplicate, + Fixed + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/AnimationValidator/Editor/AnimationValidator.cs.meta b/popcorn/Assets/USAYAUnityLib/AnimationValidator/Editor/AnimationValidator.cs.meta new file mode 100755 index 00000000..3d73825d --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/AnimationValidator/Editor/AnimationValidator.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: d44c737829d86874d922d82403ef21c2 +timeCreated: 1523983104 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/AnimationValidator/Editor/AnimationValidatorView.cs b/popcorn/Assets/USAYAUnityLib/AnimationValidator/Editor/AnimationValidatorView.cs new file mode 100755 index 00000000..e4733146 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/AnimationValidator/Editor/AnimationValidatorView.cs @@ -0,0 +1,204 @@ +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +namespace StaTech.AnimationValidator { + public class AnimationValidatorView : EditorWindow { + private Texture2D _successIcon; + private Texture2D SuccessIcon { + get{ + if(_successIcon == null){ + _successIcon = GetBuiltInIcon("testpassed.png"); + } + return _successIcon; + } + } + + private Texture2D _errorIcon; + private Texture2D ErrorIcon { + get{ + if(_errorIcon == null){ + _errorIcon = GetBuiltInIcon("testfailed.png"); + } + return _errorIcon; + } + } + + private const float DetailSpace = 30f; + private const float RightPadding = 30f; + + private static List _clipValidations; + private static GameObject _selectedObject; + private static AnimationValidatorView _window; + private static Vector2 _scrollPos; + + [MenuItem("GameObject/アニメーションクリップ修正", false, -1)] + public static void Open(){ + _clipValidations = AnimationValidator.ValidateAnimation(); + if(_clipValidations == null){ + return; + } + _window = GetWindow (); + _window.titleContent = new GUIContent("anim修正"); + _selectedObject = Selection.activeGameObject; + } + + private void OnGUI(){ + if(_clipValidations == null || _clipValidations.Count == 0){ + GUILayout.Label("AnimationClipがありません"); + return; + } + + _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, true, true); + GUILayout.Label("====================================="); + GUILayout.Label("Animationでmissingになっているものを表示します"); + GUILayout.Label("オブジェクトの名前が他と被っていなれば自動で修正します"); + GUILayout.Label("====================================="); + + if(_clipValidations.Count > 1){ + foreach(var result in _clipValidations){ + if(!result.HasNoError){ + DrawButton("全部まとめて修正", () => { + AnimationValidator.ExecuteAllRecovery(_selectedObject, _clipValidations, ShowProgress); + _window.Repaint(); + EditorApplication.RepaintAnimationWindow(); + }); + break; + } + } + } + + foreach(var result in _clipValidations){ + DrawResult(result); + } + DrawButton("閉じる", () => _window.Close()); + EditorGUILayout.EndScrollView(); + } + + private void DrawResult(ClipValidationContainer result){ + if(result.HasNoError){ + using(new EditorGUILayout.VerticalScope("box", GUILayout.Width(position.width - RightPadding))){ + DrawOnSuccess(result); + } + }else{ + using(new EditorGUILayout.VerticalScope("box", GUILayout.Width(position.width - RightPadding))){ + DrawOnError(result); + } + } + } + + private void DrawOnSuccess(ClipValidationContainer result){ + DrawIconAndLabel(SuccessIcon, result.ClipName, "→正常です"); + DrawDetail(result.LostProperties); + } + + private void DrawOnError(ClipValidationContainer result){ + DrawIconAndLabel(ErrorIcon, result.ClipName); + DrawDetail(result.LostProperties); + DrawButton("自動修正", () => { + AnimationValidator.ExecuteUnitRecovery(_selectedObject, result, ShowProgress); + _window.Repaint(); + EditorApplication.RepaintAnimationWindow(); + }); + } + + private void ShowProgress(string content, float progress){ + EditorUtility.DisplayProgressBar("実行中", content, progress); + } + + private void DrawDetail(List Props){ + using(new GUILayout.VerticalScope()){ + foreach(var prop in Props){ + var icon = prop.State == FixState.Fixed ? SuccessIcon : ErrorIcon; + DrawSpaceAndText(DetailSpace, prop.PropPath + " : " + prop.AttributeName, icon, prop.State); + } + } + } + + private void DrawIconAndLabel(Texture image, string content, string detail = ""){ + using(new GUILayout.HorizontalScope()){ + GUILayout.Label(image, GUILayout.Height(18f), GUILayout.Width(20f)); + GUILayout.Label(content); + if(!string.IsNullOrEmpty(detail)){ + GUIStyle s = new GUIStyle(EditorStyles.label){ + normal = { textColor = Color.green } + }; + GUILayout.Label(detail, s); + GUILayout.FlexibleSpace(); + } + } + } + + private void DrawSpaceAndText(float space, string content, Texture headIcon, FixState state = FixState.None){ + using(new GUILayout.HorizontalScope()){ + GUILayout.Space(space); + if(headIcon){ + GUILayout.Label(headIcon, GUILayout.Height(18f), GUILayout.Width(20f)); + } + GUILayout.Label(content); + var detail = GetDetail(state); + if(!string.IsNullOrEmpty(detail)){ + // 黄色文字で足す + var color = GetColor(state); + if(color != Color.white){ + GUIStyle s = new GUIStyle(EditorStyles.label){ + normal = { textColor = color } + }; + GUILayout.Label(detail, s); + GUILayout.FlexibleSpace(); + } + } + } + } + + private static Color GetColor(FixState state){ + switch(state){ + case FixState.ErrorDuplicate: + case FixState.ErrorNoSameName: + return Color.yellow; + case FixState.Fixed: + return Color.green; + default: + return Color.white; + } + } + + private static string GetDetail(FixState state){ + switch(state){ + case FixState.ErrorDuplicate: + return "→同じ名前のオブジェクトが子階層上に複数あります"; + case FixState.ErrorNoSameName: + return "→同じ名前のオブジェクトが見つかりませんでした"; + case FixState.Lost: + return " "; + case FixState.Fixed: + return "→Animationのパスを変更しました"; + default: + return ""; + } + } + + private void DrawButton(string buttonName, System.Action callback = null){ + if(GUILayout.Button(buttonName, GUILayout.Width(200f))){ + if(callback != null){ + callback.Invoke(); + } + } + } + + private void OnDestroy(){ + if(_clipValidations != null){ + _clipValidations.Clear(); + _clipValidations = null; + } + } + + private static Texture2D GetBuiltInIcon(string name){ + System.Reflection.MethodInfo mi = typeof(EditorGUIUtility).GetMethod("IconContent", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public, null, new System.Type[] { typeof(string) }, null); + if(mi == null){ + mi = typeof(EditorGUIUtility).GetMethod("IconContent", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic, null, new System.Type[] { typeof(string) }, null); + } + return (Texture2D)((GUIContent) mi.Invoke(null, new object[] { name })).image; + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/AnimationValidator/Editor/AnimationValidatorView.cs.meta b/popcorn/Assets/USAYAUnityLib/AnimationValidator/Editor/AnimationValidatorView.cs.meta new file mode 100755 index 00000000..c0d935e5 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/AnimationValidator/Editor/AnimationValidatorView.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f37417dd83a19b64ba497a3247d7d0b7 +timeCreated: 1524310971 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Attributes.meta b/popcorn/Assets/USAYAUnityLib/Attributes.meta new file mode 100644 index 00000000..a4a10371 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Attributes.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6507f0123e30443a3a79145e5f979d8d +folderAsset: yes +timeCreated: 1469076906 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Attributes/Editor.meta b/popcorn/Assets/USAYAUnityLib/Attributes/Editor.meta new file mode 100644 index 00000000..6fba42dc --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Attributes/Editor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 819b5f6b5a15345c8a3ce047055b1c02 +folderAsset: yes +timeCreated: 1475126980 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Attributes/Editor/PrefabFieldDrawer.cs b/popcorn/Assets/USAYAUnityLib/Attributes/Editor/PrefabFieldDrawer.cs new file mode 100644 index 00000000..637a2211 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Attributes/Editor/PrefabFieldDrawer.cs @@ -0,0 +1,25 @@ +using UnityEngine; +using UnityEditor; + +[CustomPropertyDrawer(typeof(PrefabFieldAttribute))] +public class PrefabFieldDrawer : PropertyDrawer { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label){ + if(property.objectReferenceValue != null){ + var prefabAssetType = PrefabUtility.GetPrefabAssetType(property.objectReferenceValue); + switch(prefabAssetType){ + case PrefabAssetType.Regular: + case PrefabAssetType.Model: + case PrefabAssetType.Variant: + break; + default: + // Prefab以外がアタッチされた場合アタッチを外す + property.objectReferenceValue = null; + break; + } + } + + label.text += " (Prefab Only)"; + EditorGUI.PropertyField(position, property, label); + } +} + diff --git a/popcorn/Assets/USAYAUnityLib/Attributes/Editor/PrefabFieldDrawer.cs.meta b/popcorn/Assets/USAYAUnityLib/Attributes/Editor/PrefabFieldDrawer.cs.meta new file mode 100644 index 00000000..f60be690 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Attributes/Editor/PrefabFieldDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0ff00e08698044c2db627525064d0472 +timeCreated: 1475127005 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Attributes/Editor/ReadOnlyDrawer.cs b/popcorn/Assets/USAYAUnityLib/Attributes/Editor/ReadOnlyDrawer.cs new file mode 100644 index 00000000..9c82cca6 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Attributes/Editor/ReadOnlyDrawer.cs @@ -0,0 +1,15 @@ +using UnityEngine; +using UnityEditor; + +[CustomPropertyDrawer(typeof(ReadOnlyAttribute))] +public class ReadOnlyDrawer : PropertyDrawer { + public override float GetPropertyHeight(SerializedProperty property, GUIContent label){ + return EditorGUI.GetPropertyHeight(property, label, true); + } + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label){ + GUI.enabled = false; + EditorGUI.PropertyField(position, property, label, true); + GUI.enabled = true; + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Attributes/Editor/ReadOnlyDrawer.cs.meta b/popcorn/Assets/USAYAUnityLib/Attributes/Editor/ReadOnlyDrawer.cs.meta new file mode 100644 index 00000000..06dd9e41 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Attributes/Editor/ReadOnlyDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 65b425c14c5094e27a20e2a2ee78db06 +timeCreated: 1475126989 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Attributes/PrefabFieldAttribute.cs b/popcorn/Assets/USAYAUnityLib/Attributes/PrefabFieldAttribute.cs new file mode 100644 index 00000000..b5cb26e1 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Attributes/PrefabFieldAttribute.cs @@ -0,0 +1,3 @@ +using UnityEngine; + +public class PrefabFieldAttribute : PropertyAttribute {} diff --git a/popcorn/Assets/USAYAUnityLib/Attributes/PrefabFieldAttribute.cs.meta b/popcorn/Assets/USAYAUnityLib/Attributes/PrefabFieldAttribute.cs.meta new file mode 100644 index 00000000..33851694 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Attributes/PrefabFieldAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 05d68fb980e084628ac781ed8182d48a +timeCreated: 1470027454 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Attributes/ReadOnlyAttribute.cs b/popcorn/Assets/USAYAUnityLib/Attributes/ReadOnlyAttribute.cs new file mode 100644 index 00000000..35e719fe --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Attributes/ReadOnlyAttribute.cs @@ -0,0 +1,3 @@ +using UnityEngine; + +public class ReadOnlyAttribute : PropertyAttribute {} diff --git a/popcorn/Assets/USAYAUnityLib/Attributes/ReadOnlyAttribute.cs.meta b/popcorn/Assets/USAYAUnityLib/Attributes/ReadOnlyAttribute.cs.meta new file mode 100644 index 00000000..cb41402a --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Attributes/ReadOnlyAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c47b0faab6f8c405abdb31811ce5f733 +timeCreated: 1469076924 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/CameraFilters.meta b/popcorn/Assets/USAYAUnityLib/CameraFilters.meta new file mode 100644 index 00000000..59a9f563 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/CameraFilters.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b821feb572d0d4ddca587a8dbc61ba4e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter.meta b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter.meta new file mode 100644 index 00000000..f0da50e5 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1baf84e9b399949f98fce3fcf8577d42 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/Blur.shader b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/Blur.shader new file mode 100644 index 00000000..d839b066 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/Blur.shader @@ -0,0 +1,79 @@ +// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' + +Shader "Hidden/USAYALib/Outline/Blur" { + Properties { + _MainTex ("Main", 2D) = "white" {} + } + + SubShader { + ZTest Always Cull Off ZWrite Off Blend Off + Fog { Mode off } + Pass { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + + #include "UnityCG.cginc" + + struct v2f { + float4 pos : SV_POSITION; + float2 uv : TEXCOORD0; + float4 uv01 : TEXCOORD1; + float4 uv23 : TEXCOORD2; + float4 uv45 : TEXCOORD3; + float4 uv67 : TEXCOORD4; + float4 uv89 : TEXCOORD5; + }; + + sampler2D _MainTex; + float2 _Offsets; + + v2f vert(appdata_img v){ + v2f o; + o.pos = UnityObjectToClipPos(v.vertex); + o.uv.xy = v.texcoord.xy; + o.uv01 = v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * (1 / _ScreenParams.xyxy); + o.uv23 = v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * (1 / _ScreenParams.xyxy); + o.uv45 = v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * (1 / _ScreenParams.xyxy); + o.uv67 = v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * (1 / _ScreenParams.xyxy); + o.uv89 = v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * (1 / _ScreenParams.xyxy); + return o; + } + float4 frag(v2f i) : SV_Target { + float4 sum = float4(0, 0, 0, 0); + float w = 0; + float weights = 0; + const float G_WEIGHTS[9] = { 1.0, 0.8, 0.65, 0.5, 0.4, 0.2, 0.1, 0.05, 0.025 }; + + float4 sampleA = tex2D(_MainTex, i.uv.xy); + float4 sampleB = tex2D(_MainTex, i.uv01.xy); + float4 sampleC = tex2D(_MainTex, i.uv01.zw); + float4 sampleD = tex2D(_MainTex, i.uv23.xy); + float4 sampleE = tex2D(_MainTex, i.uv23.zw); + float4 sampleF = tex2D(_MainTex, i.uv45.xy); + float4 sampleG = tex2D(_MainTex, i.uv45.zw); + float4 sampleH = tex2D(_MainTex, i.uv67.xy); + float4 sampleI = tex2D(_MainTex, i.uv67.zw); + float4 sampleJ = tex2D(_MainTex, i.uv89.xy); + float4 sampleK = tex2D(_MainTex, i.uv89.zw); + + w = G_WEIGHTS[0]; sum += sampleA * w; weights += w; + w = G_WEIGHTS[1]; sum += sampleB * w; weights += w; + w = G_WEIGHTS[1]; sum += sampleC * w; weights += w; + w = G_WEIGHTS[2]; sum += sampleD * w; weights += w; + w = G_WEIGHTS[2]; sum += sampleE * w; weights += w; + w = G_WEIGHTS[3]; sum += sampleF * w; weights += w; + w = G_WEIGHTS[3]; sum += sampleG * w; weights += w; + w = G_WEIGHTS[4]; sum += sampleH * w; weights += w; + w = G_WEIGHTS[4]; sum += sampleI * w; weights += w; + w = G_WEIGHTS[5]; sum += sampleJ * w; weights += w; + w = G_WEIGHTS[5]; sum += sampleK * w; weights += w; + + sum /= weights + 1e-4f; + return sum; + } + ENDCG + } + } + Fallback Off +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/Blur.shader.meta b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/Blur.shader.meta new file mode 100644 index 00000000..da651740 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/Blur.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: db183b7cc1b7049d4bc355d6958bbe9b +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/FlatColor.shader b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/FlatColor.shader new file mode 100644 index 00000000..dad0ec77 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/FlatColor.shader @@ -0,0 +1,45 @@ +// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' + +Shader "Hidden/USAYALib/Outline/FlatColor" { + Properties { + _MainTex ("Texture", 2D) = "white" {} + } + + SubShader { + + Blend One One + Cull Off + + Pass { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + + #include "UnityCG.cginc" + + struct appdata { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + struct v2f { + float4 pos : SV_POSITION; + float2 uv : TEXCOORD0; + }; + + sampler2D _MainTex; + float4 _MainTex_ST; + + v2f vert(appdata v){ + v2f o; + o.pos = UnityObjectToClipPos(v.vertex); + o.uv = TRANSFORM_TEX(v.uv, _MainTex); + return o; + } + float4 frag(v2f i) : SV_TARGET { + return step(0.5, (tex2D(_MainTex, i.uv)).a); + } + ENDCG + } + } + FallBack Off +} diff --git a/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/FlatColor.shader.meta b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/FlatColor.shader.meta new file mode 100644 index 00000000..121373bd --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/FlatColor.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 60851fe30c623421b8015141412be220 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/Halo.shader b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/Halo.shader new file mode 100644 index 00000000..7a83f10d --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/Halo.shader @@ -0,0 +1,33 @@ +Shader "Hidden/USAYALib/Outline/Halo" { + Properties { + _MainTex ("Main", 2D) = "black" {} + _GlowTex ("Glow Object", 2D) = "black" {} + _GlowColor ("Glow Color", Color) = (0, 1, 1, 1) + _CutOut ("Cut Out", Float) = 0.5 + } + + SubShader { + Blend SrcAlpha OneMinusSrcAlpha + Pass { + CGPROGRAM + #pragma vertex vert_img + #pragma fragment frag + + #include "UnityCG.cginc" + + sampler2D _MainTex, _GlowTex; + float4 _GlowColor; + float _CutOut; + + float4 frag(v2f_img i) : SV_Target { + float r = tex2D(_GlowTex, i.uv).r; + clip(-r); + float4 result = _GlowColor; +// result.a *= (r < 1.0 && tex2D(_MainTex, i.uv).r > _CutOut) ? 1.0 : 0.0; + result.a *= (1.0 - step(1.0, r)) * (1.0 - step(tex2D(_MainTex, i.uv).r, _CutOut)); + return result; + } + ENDCG + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/Halo.shader.meta b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/Halo.shader.meta new file mode 100644 index 00000000..17902bde --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/Halo.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 22146d67b54ae4183a260c05b86f647f +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/OutlineFilter.cs b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/OutlineFilter.cs new file mode 100644 index 00000000..213bc0b5 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/OutlineFilter.cs @@ -0,0 +1,76 @@ +using UnityEngine; +using UnityEngine.Rendering; + +[RequireComponent(typeof(Camera))] +public sealed class OutlineFilter : MonoBehaviour { + [SerializeField] + private Color color = Color.white; + [SerializeField, Range(0.1f, 10.0f)] + private float width = 1.0f; + [SerializeField, Range(0f, 1f)] + private float cutOut = 0f; + [SerializeField] + private LayerMask outlineLayer = default; + + private Shader flatColorShader; + private Material haloMaterial; + private Material blurMaterial; + private Camera _camera; + private Camera renderTextureCamera; + private int idOffsets = 0; + private int idGlowTex = 0; + private int idGlowColor = 0; + private int idCutOut = 0; + + void Awake(){ + _camera = GetComponent(); + flatColorShader = Shader.Find("Hidden/USAYALib/Outline/FlatColor"); + blurMaterial = Shader.Find("Hidden/USAYALib/Outline/Blur").CreateHiddenMaterial(); + haloMaterial = Shader.Find("Hidden/USAYALib/Outline/Halo").CreateHiddenMaterial(); + + renderTextureCamera = new GameObject("OutlineRendererTextureCamera").AddComponent(); + renderTextureCamera.transform.parent = _camera.gameObject.transform; + renderTextureCamera.enabled = false; + + idOffsets = Shader.PropertyToID("_Offsets"); + idGlowTex = Shader.PropertyToID("_GlowTex"); + idGlowColor = Shader.PropertyToID("_GlowColor"); + idCutOut = Shader.PropertyToID("_CutOut"); + } + + void OnRenderImage(RenderTexture src, RenderTexture dst){ + Graphics.Blit(src, dst); // prepare main back framebuffer + + renderTextureCamera.CopyFrom(_camera); + renderTextureCamera.clearFlags = CameraClearFlags.Color; + renderTextureCamera.backgroundColor = Color.black; // r as mask, should be black here + + var renderTexture1 = RenderTexture.GetTemporary(src.width, src.height, 16, RenderTextureFormat.R8); + renderTextureCamera.targetTexture = renderTexture1; + + renderTextureCamera.cullingMask = outlineLayer; + renderTextureCamera.RenderWithShader(flatColorShader, ""); + + // blur pass + int shrink = 1; // shrink == 1 for best quality, try 2 or 4 for low quality but better performance + var renderTexture2 = RenderTexture.GetTemporary(Screen.width / shrink, Screen.height / shrink, 0); + var renderTexture3 = RenderTexture.GetTemporary(Screen.width / shrink, Screen.height / shrink, 0); + DoBlurPass(renderTexture1, renderTexture2, Vector2.up); + DoBlurPass(renderTexture2, renderTexture3, Vector2.right); + + // copy the temporary RT to the final image + haloMaterial.SetTexture(idGlowTex, renderTexture1); + haloMaterial.SetColor(idGlowColor, color); + haloMaterial.SetFloat(idCutOut, cutOut); + Graphics.Blit(renderTexture3, dst, haloMaterial); + + RenderTexture.ReleaseTemporary(renderTexture1); + RenderTexture.ReleaseTemporary(renderTexture2); + RenderTexture.ReleaseTemporary(renderTexture3); + } + private void DoBlurPass(RenderTexture input, RenderTexture output, Vector2 direction){ + var blurPixelOffset = width * input.height / 1920.0f; + blurMaterial.SetVector(idOffsets, direction * blurPixelOffset); + Graphics.Blit(input, output, blurMaterial); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/OutlineFilter.cs.meta b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/OutlineFilter.cs.meta new file mode 100644 index 00000000..feaf505f --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/CameraFilters/OutlineFilter/OutlineFilter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7023f26e2ff004e119537b8c822726e1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/DebugOption.meta b/popcorn/Assets/USAYAUnityLib/DebugOption.meta new file mode 100644 index 00000000..6ecf1fd5 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/DebugOption.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 13829856eb3944aeebcb498ec23022d3 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs.meta b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs.meta new file mode 100644 index 00000000..9b4eaf5d --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0bc2c9b816cc0431ea5ae4363cd040ac +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Button.prefab b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Button.prefab new file mode 100644 index 00000000..4e86e60f --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Button.prefab @@ -0,0 +1,193 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &4621217213727453643 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1687065005769937004} + - component: {fileID: 7161669052425278145} + - component: {fileID: 5062447477614030396} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1687065005769937004 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4621217213727453643} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4063882079711355622} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: -10, y: -10} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &7161669052425278145 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4621217213727453643} + m_CullTransparentMesh: 0 +--- !u!114 &5062447477614030396 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4621217213727453643} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: "\u6A5F\u80FD\u540D" +--- !u!1 &5850834825256791800 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4063882079711355622} + - component: {fileID: 1841557246581323496} + - component: {fileID: 1877055874433787818} + - component: {fileID: 502413859327355263} + m_Layer: 5 + m_Name: Button + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &4063882079711355622 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5850834825256791800} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1687065005769937004} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &1841557246581323496 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5850834825256791800} + m_CullTransparentMesh: 0 +--- !u!114 &1877055874433787818 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5850834825256791800} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!114 &502413859327355263 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5850834825256791800} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1877055874433787818} + m_OnClick: + m_PersistentCalls: + m_Calls: [] diff --git a/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Button.prefab.meta b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Button.prefab.meta new file mode 100644 index 00000000..283c9530 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Button.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: f19992fe2069b4e16b2f83277fb189cb +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Canvas.prefab b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Canvas.prefab new file mode 100644 index 00000000..05ba47ba --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Canvas.prefab @@ -0,0 +1,801 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2541661407703704363 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2541661407703704362} + - component: {fileID: 2541661407703704364} + - component: {fileID: 2541661407703704365} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2541661407703704362 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661407703704363} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 2541661408982824309} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2541661407703704364 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661407703704363} + m_CullTransparentMesh: 0 +--- !u!114 &2541661407703704365 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661407703704363} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: "\u623B\u308B" +--- !u!1 &2541661408295226766 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2541661408295226753} + - component: {fileID: 2541661408295226755} + - component: {fileID: 2541661408295226752} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2541661408295226753 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661408295226766} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 2541661408536301877} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2541661408295226755 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661408295226766} + m_CullTransparentMesh: 0 +--- !u!114 &2541661408295226752 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661408295226766} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: "\u5371\u967A" +--- !u!1 &2541661408357901930 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2541661408357901934} + - component: {fileID: 2541661408357901935} + - component: {fileID: 2541661408357901932} + - component: {fileID: 2541661408357901933} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2541661408357901934 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661408357901930} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 2541661408570683701} + - {fileID: 2541661409141469743} + - {fileID: 2541661408982824309} + - {fileID: 2541661408536301877} + - {fileID: 2541661409648867662} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!223 &2541661408357901935 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661408357901930} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!114 &2541661408357901932 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661408357901930} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 1 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 750, y: 1334} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 1 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!114 &2541661408357901933 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661408357901930} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!1 &2541661408536301873 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2541661408536301877} + - component: {fileID: 2541661408536301874} + - component: {fileID: 2541661408536301875} + - component: {fileID: 2541661408536301872} + m_Layer: 5 + m_Name: ResetButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2541661408536301877 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661408536301873} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 2541661408295226753} + m_Father: {fileID: 2541661408357901934} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 250, y: -500} + m_SizeDelta: {x: 100, y: 50} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2541661408536301874 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661408536301873} + m_CullTransparentMesh: 0 +--- !u!114 &2541661408536301875 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661408536301873} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 0.45882353, b: 0.5058824, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!114 &2541661408536301872 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661408536301873} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 2541661408536301875} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!1 &2541661408982824306 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2541661408982824309} + - component: {fileID: 2541661408982824311} + - component: {fileID: 2541661408982824308} + - component: {fileID: 2541661408982824310} + m_Layer: 5 + m_Name: BackButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2541661408982824309 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661408982824306} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 2541661407703704362} + m_Father: {fileID: 2541661408357901934} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: -500} + m_SizeDelta: {x: 160, y: 90} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2541661408982824311 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661408982824306} + m_CullTransparentMesh: 0 +--- !u!114 &2541661408982824308 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661408982824306} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!114 &2541661408982824310 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661408982824306} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 2541661408982824308} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!1 &2541661409141469740 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2541661409141469743} + - component: {fileID: 2541661409141469742} + m_Layer: 5 + m_Name: Buttons + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2541661409141469743 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661409141469740} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 2541661408357901934} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 1, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: -100, y: 400} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2541661409141469742 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661409141469740} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -2095666955, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_ChildAlignment: 0 + m_StartCorner: 0 + m_StartAxis: 0 + m_CellSize: {x: 100, y: 100} + m_Spacing: {x: 0, y: 0} + m_Constraint: 0 + m_ConstraintCount: 2 +--- !u!1 &2541661409648867663 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2541661409648867662} + - component: {fileID: 2541661409648867651} + - component: {fileID: 2541661409648867648} + - component: {fileID: 2541661409648867649} + m_Layer: 5 + m_Name: CoverButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2541661409648867662 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661409648867663} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 2541661408357901934} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 250, y: -500} + m_SizeDelta: {x: 100, y: 50} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2541661409648867651 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661409648867663} + m_CullTransparentMesh: 0 +--- !u!114 &2541661409648867648 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661409648867663} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19215688, g: 0.19215688, b: 0.19215688, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 316fe626d2dfa490ca675da5c1c648b4, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!114 &2541661409648867649 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541661409648867663} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 2541661409648867648} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 2541661409648867663} + m_MethodName: SetActive + m_Mode: 6 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!1001 &9095851792703994660 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 2541661408357901934} + m_Modifications: + - target: {fileID: 6737172384967821846, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_Name + value: StageInputField + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_AnchoredPosition.x + value: -170 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_AnchoredPosition.y + value: 550 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_SizeDelta.x + value: 120 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_SizeDelta.y + value: 80 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_AnchorMin.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_AnchorMin.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_AnchorMax.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_AnchorMax.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 6737172384039791724, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_Text + value: "\u30B9\u30C6\u30FC\u30B8" + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 485257dfeb2144672bcc21b704b6ca0f, type: 3} +--- !u!224 &2541661408570683701 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + m_PrefabInstance: {fileID: 9095851792703994660} + m_PrefabAsset: {fileID: 0} diff --git a/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Canvas.prefab.meta b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Canvas.prefab.meta new file mode 100644 index 00000000..4a7987fb --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Canvas.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 32f8e8f0ced494daeb0f218e6be9d9db +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/IntInputField.prefab b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/IntInputField.prefab new file mode 100644 index 00000000..8682c821 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/IntInputField.prefab @@ -0,0 +1,291 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &6737172384039791730 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6737172384039791725} + - component: {fileID: 6737172384039791727} + - component: {fileID: 6737172384039791724} + m_Layer: 5 + m_Name: NameText + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &6737172384039791725 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6737172384039791730} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 6737172384967821841} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 0} + m_Pivot: {x: 1, y: 0.5} +--- !u!222 &6737172384039791727 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6737172384039791730} + m_CullTransparentMesh: 0 +--- !u!114 &6737172384039791724 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6737172384039791730} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 32 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 10 + m_MaxSize: 32 + m_Alignment: 5 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: "\u540D\u524D" +--- !u!1 &6737172384848310723 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6737172384848310722} + - component: {fileID: 6737172384848310780} + - component: {fileID: 6737172384848310781} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &6737172384848310722 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6737172384848310723} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 6737172384967821841} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &6737172384848310780 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6737172384848310723} + m_CullTransparentMesh: 0 +--- !u!114 &6737172384848310781 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6737172384848310723} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 32 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 3 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: 0 +--- !u!1 &6737172384967821846 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6737172384967821841} + - component: {fileID: 6737172384967821843} + - component: {fileID: 6737172384967821840} + - component: {fileID: 6737172384967821842} + m_Layer: 5 + m_Name: IntInputField + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &6737172384967821841 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6737172384967821846} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 6737172384039791725} + - {fileID: 6737172384848310722} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -170, y: 550} + m_SizeDelta: {x: 120, y: 80} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &6737172384967821843 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6737172384967821846} + m_CullTransparentMesh: 0 +--- !u!114 &6737172384967821840 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6737172384967821846} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!114 &6737172384967821842 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6737172384967821846} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 575553740, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 6737172384967821840} + m_TextComponent: {fileID: 6737172384848310781} + m_Placeholder: {fileID: 0} + m_ContentType: 2 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 4 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 1 + m_CharacterLimit: 0 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: 0 + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 diff --git a/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/IntInputField.prefab.meta b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/IntInputField.prefab.meta new file mode 100644 index 00000000..6ca665ad --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/IntInputField.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 485257dfeb2144672bcc21b704b6ca0f +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/MainCamera.prefab b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/MainCamera.prefab new file mode 100644 index 00000000..a349746f --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/MainCamera.prefab @@ -0,0 +1,75 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1418391247242195742 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1418391247242195739} + - component: {fileID: 1418391247242195736} + m_Layer: 0 + m_Name: MainCamera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1418391247242195739 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1418391247242195742} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!20 &1418391247242195736 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1418391247242195742} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.19215687, b: 0.19215687, a: 0} + m_projectionMatrixMode: 1 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_GateFitMode: 2 + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_AllowMSAA: 0 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 diff --git a/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/MainCamera.prefab.meta b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/MainCamera.prefab.meta new file mode 100644 index 00000000..4e9159fe --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/MainCamera.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8dee1e67eb6fa45268e20133acc68259 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/StringInputField.prefab b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/StringInputField.prefab new file mode 100644 index 00000000..3f57ff18 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/StringInputField.prefab @@ -0,0 +1,161 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &6962151599299144406 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 6737172384848310781, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_Text + value: + objectReference: {fileID: 0} + - target: {fileID: 6737172384848310781, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_FontData.m_BestFit + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6737172384848310781, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_FontData.m_HorizontalOverflow + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_AnchorMax.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_AnchorMax.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_AnchorMin.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_AnchorMin.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_SizeDelta.x + value: 120 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_SizeDelta.y + value: 80 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_AnchoredPosition.x + value: -170 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_AnchoredPosition.y + value: 550 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821841, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821842, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_Text + value: + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821842, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_LineType + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821842, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_ContentType + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821842, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_KeyboardType + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821842, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_CharacterValidation + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6737172384967821846, guid: 485257dfeb2144672bcc21b704b6ca0f, + type: 3} + propertyPath: m_Name + value: StringInputField + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 485257dfeb2144672bcc21b704b6ca0f, type: 3} diff --git a/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/StringInputField.prefab.meta b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/StringInputField.prefab.meta new file mode 100644 index 00000000..6df9e772 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/StringInputField.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 81de4ed12e3874110b42569fd8f3c162 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Toggle.prefab b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Toggle.prefab new file mode 100644 index 00000000..514c9a9f --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Toggle.prefab @@ -0,0 +1,306 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1907863346325523399 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8789217124120630612} + - component: {fileID: 8246534116929882156} + m_Layer: 5 + m_Name: Toggle + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &8789217124120630612 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1907863346325523399} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 937410549135013519} + - {fileID: 4969098926396769855} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -170, y: 390} + m_SizeDelta: {x: 80, y: 80} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &8246534116929882156 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1907863346325523399} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 2109663825, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 5530625025939557361} + toggleTransition: 1 + graphic: {fileID: 9069741319519684883} + m_Group: {fileID: 0} + onValueChanged: + m_PersistentCalls: + m_Calls: [] + m_IsOn: 1 +--- !u!1 &4732693032646562594 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 937410549135013519} + - component: {fileID: 3161523647402802971} + - component: {fileID: 6855072136971505580} + m_Layer: 5 + m_Name: NameText + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &937410549135013519 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4732693032646562594} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 8789217124120630612} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: -20, y: 0} + m_SizeDelta: {x: 100, y: 0} + m_Pivot: {x: 1, y: 0.5} +--- !u!222 &3161523647402802971 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4732693032646562594} + m_CullTransparentMesh: 0 +--- !u!114 &6855072136971505580 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4732693032646562594} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 32 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 10 + m_MaxSize: 32 + m_Alignment: 5 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: "\u540D\u524D" +--- !u!1 &7953774624198755404 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4969098926396769855} + - component: {fileID: 935700448316683054} + - component: {fileID: 5530625025939557361} + m_Layer: 5 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &4969098926396769855 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7953774624198755404} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 3450878312509628740} + m_Father: {fileID: 8789217124120630612} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: -20, y: -20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &935700448316683054 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7953774624198755404} + m_CullTransparentMesh: 0 +--- !u!114 &5530625025939557361 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7953774624198755404} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!1 &8621330901285670047 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3450878312509628740} + - component: {fileID: 8336172991856618550} + - component: {fileID: 9069741319519684883} + m_Layer: 5 + m_Name: Checkmark + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &3450878312509628740 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8621330901285670047} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4969098926396769855} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: -20, y: -20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &8336172991856618550 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8621330901285670047} + m_CullTransparentMesh: 0 +--- !u!114 &9069741319519684883 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8621330901285670047} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10901, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 diff --git a/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Toggle.prefab.meta b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Toggle.prefab.meta new file mode 100644 index 00000000..5247cd3a --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/DebugOption/Prefabs/Toggle.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: bc0b42d29ba9f4568aa0b803c18574c5 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor.meta b/popcorn/Assets/USAYAUnityLib/Editor.meta new file mode 100644 index 00000000..838cfd16 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9eeda945de99842c98da2bfc3b32d5c3 +folderAsset: yes +timeCreated: 1464664292 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/BitmapFontGenerater.cs b/popcorn/Assets/USAYAUnityLib/Editor/BitmapFontGenerater.cs new file mode 100644 index 00000000..3583f4a8 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/BitmapFontGenerater.cs @@ -0,0 +1,148 @@ +#if UNITY_EDITOR + +using UnityEngine; +using System.IO; +using System.Xml; + +using UnityEditor; + +public static class BitmapFontGenerater +{ + static string DEFAULT_SHADER = "Unlit/Transparent"; + + [MenuItem("Assets/Create/Bitmap Font")] + public static void GenerateBitmapFont() + { + Object[] textAssets = Selection.GetFiltered(typeof(TextAsset), SelectionMode.DeepAssets); + Object[] textures = Selection.GetFiltered(typeof(Texture2D), SelectionMode.DeepAssets); + + if(textAssets.Length < 1) + { + Debug.LogError("BitmapFont Create Error -- XML File is not Selected. (XMLファイルを選択してください)"); + return; + } + if(textures.Length < 1) + { + Debug.LogError("BitmapFont Create Error -- Texture File is not selected. (フォントテクスチャを選択してください)"); + return; + } + + Generate((TextAsset)textAssets[0] , (Texture2D)textures[0]); + } + + static void Generate(TextAsset textAsset , Texture2D texture) + { + XmlDocument xml = new XmlDocument(); + xml.LoadXml(textAsset.text); + + XmlNode common = xml.GetElementsByTagName("common")[0]; + XmlNodeList chars = xml.GetElementsByTagName("chars")[0].ChildNodes; + + CharacterInfo[] charInfos = new CharacterInfo[chars.Count]; + + float textureW = float.Parse(GetValue(common , "scaleW")); + float textureH = float.Parse(GetValue(common , "scaleH")); + + for (int i=0; i < chars.Count; i++) + { + XmlNode charNode = chars[i]; + if(charNode.Attributes != null) + { + charInfos[i].index = int.Parse(GetValue(charNode, "id")); + + Rect vertRect = new Rect(); + vertRect.width = float.Parse(GetValue(charNode, "width")); + vertRect.height = -(float.Parse(GetValue(charNode, "height"))); + vertRect.x = float.Parse(GetValue(charNode, "xoffset")); + vertRect.y = -(float.Parse(GetValue(charNode, "yoffset"))); + + float charX = float.Parse(GetValue(charNode, "x")) / textureW; + float charWidth = float.Parse(GetValue(charNode, "width")) / textureW; + float charHeight = float.Parse(GetValue(charNode, "height")); + float charY = (textureH - float.Parse(GetValue(charNode, "y")) - charHeight) / textureH; + charHeight = charHeight / textureH; + + // UnFlipped. + charInfos[i].uvBottomLeft = new Vector2(charX, charY); + charInfos[i].uvBottomRight = new Vector2(charX + charWidth, charY); + charInfos[i].uvTopLeft = new Vector2(charX, charY + charHeight); + charInfos[i].uvTopRight = new Vector2(charX + charWidth, charY + charHeight); + + charInfos[i].minX = (int)vertRect.xMin; + charInfos[i].maxX = (int)vertRect.xMax; + charInfos[i].minY = (int)vertRect.yMax; + charInfos[i].maxY = (int)vertRect.yMin; + + charInfos[i].advance = int.Parse(GetValue(charNode, "xadvance")); + } + } + + string rootPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(textAsset)); + string exportPath = rootPath + "/" + Path.GetFileNameWithoutExtension(textAsset.name); + + Material material = GenerateMaterial(exportPath, texture); + Font font = GenerateFont(exportPath, textAsset.name, material); + + font.characterInfo = charInfos; + + // Save m_LineSpacing. + XmlNode info = xml.GetElementsByTagName("info")[0]; + SerializedObject serializedFont = new SerializedObject(font); + SerializedProperty serializedLineSpacing = serializedFont.FindProperty("m_LineSpacing"); + serializedLineSpacing.floatValue = Mathf.Abs(float.Parse(GetValue(info, "size"))); + serializedFont.ApplyModifiedProperties(); + } + + static Material GenerateMaterial(string materialPath , Texture2D texture) + { + Shader shader = Shader.Find(DEFAULT_SHADER); + Material material = LoadAsset(materialPath + ".mat", new Material(shader)); + material.shader = shader; + material.mainTexture = texture; + + SaveAsset(material, materialPath + ".mat"); + + return material; + } + + static Font GenerateFont(string fontPath, string fontName, Material material) + { + Font font = LoadAsset(fontPath + ".fontsettings", new Font(fontName)); + font.material = material; + + SaveAsset(font, fontPath + ".fontsettings"); + + return font; + } + + static string GetValue(XmlNode node, string name) + { + return node.Attributes.GetNamedItem(name).InnerText; + } + + static void SaveAsset(Object obj, string path) + { + Object existingAsset = AssetDatabase.LoadMainAssetAtPath(path); + if(existingAsset != null) + { + EditorUtility.CopySerialized(obj, existingAsset); + EditorUtility.SetDirty(existingAsset); + AssetDatabase.SaveAssets(); + } + else + { + AssetDatabase.CreateAsset(obj, path); + } + } + + static T LoadAsset(string path , T defaultAsset) where T : Object + { + T existingAsset = AssetDatabase.LoadMainAssetAtPath(path) as T; + if(existingAsset == null) + { + existingAsset = defaultAsset; + } + return existingAsset; + } +} +#endif diff --git a/popcorn/Assets/USAYAUnityLib/Editor/BitmapFontGenerater.cs.meta b/popcorn/Assets/USAYAUnityLib/Editor/BitmapFontGenerater.cs.meta new file mode 100644 index 00000000..45e72d5d --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/BitmapFontGenerater.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d9177045eec804d9198f1af54374656c +timeCreated: 1465548788 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/BuildCompressedPlayer.cs b/popcorn/Assets/USAYAUnityLib/Editor/BuildCompressedPlayer.cs new file mode 100644 index 00000000..46e78ced --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/BuildCompressedPlayer.cs @@ -0,0 +1,22 @@ +using UnityEngine; +using UnityEditor; + +public class BuildCompressedPlayer : MonoBehaviour { + + [MenuItem("Build/BuildAndroid")] + static void BuildAndroid(){ + Build(string.Format("{0}_{1}_{2}.apk", PlayerSettings.productName, PlayerSettings.bundleVersion, PlayerSettings.Android.bundleVersionCode), BuildTarget.Android); + } + + [MenuItem("Build/BuildIOS")] + static void BuildIOS(){ + Build("xcode", BuildTarget.iOS); + } + + static void Build(string locationPathName, BuildTarget buildTarget){ + BuildOptions opt = BuildOptions.SymlinkLibraries; +// opt |= BuildOptions.Development; + opt |= BuildOptions.CompressWithLz4; + BuildPipeline.BuildPlayer(EditorBuildSettings.scenes, locationPathName, buildTarget, opt); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Editor/BuildCompressedPlayer.cs.meta b/popcorn/Assets/USAYAUnityLib/Editor/BuildCompressedPlayer.cs.meta new file mode 100644 index 00000000..5cf46bc9 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/BuildCompressedPlayer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 73c0cd415ede34cf0b5ab558028a71d8 +timeCreated: 1526896269 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/ContinuationManager.cs b/popcorn/Assets/USAYAUnityLib/Editor/ContinuationManager.cs new file mode 100644 index 00000000..c6e28a40 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/ContinuationManager.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; + +/* kjems - http://answers.unity3d.com/questions/221651/yielding-with-www-in-editor.html + +I made a ContinuationManager to handle the cases where I want to wait for a condition and then do something with an object. + +The snippet below is an example of WWW using the ContinuationManager where the condition to trigger the continuation is www.isDone. +The lambda closure captures the www object so it can be used when the www is done. The code is non-blocking. + + var www = new WWW("someURL"); + ContinuationManager.Add(() => www.isDone, () => { + if(!string.IsNullOrEmpty(www.error)){ + Debug.Log("WWW failed: " + www.error); + } + + Debug.Log("WWW result : " + www.text); + }); + */ + +internal static class ContinuationManager { + private class Job { + public Job(Func completed, Action continueWith){ + Completed = completed; + ContinueWith = continueWith; + } + public Func Completed { get; private set; } + public Action ContinueWith { get; private set; } + } + + private static readonly List jobs = new List(); + + public static void Add(Func completed, Action continueWith){ + if(!jobs.Any()){ + EditorApplication.update += Update; + } + jobs.Add(new Job(completed, continueWith)); + } + + private static void Update(){ + for(int i = 0; i >= 0; --i){ + var jobIt = jobs[i]; + if(jobIt.Completed()){ + jobIt.ContinueWith(); + jobs.RemoveAt(i); + } + } + if(!jobs.Any()){ + EditorApplication.update -= Update; + } + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Editor/ContinuationManager.cs.meta b/popcorn/Assets/USAYAUnityLib/Editor/ContinuationManager.cs.meta new file mode 100644 index 00000000..9cb4e891 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/ContinuationManager.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 160bb54b28f45e14592818dfa8d093bf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/DevelopmentBuilder.cs b/popcorn/Assets/USAYAUnityLib/Editor/DevelopmentBuilder.cs new file mode 100644 index 00000000..5fd42ab7 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/DevelopmentBuilder.cs @@ -0,0 +1,16 @@ +using UnityEditor.Build; +using UnityEditor.Build.Reporting; + +public class DevelopmentBuilder : IPreprocessBuildWithReport { + + // 実行順 + public int callbackOrder { + get{ return 0; } + } + + public void OnPreprocessBuild(BuildReport report) { + UnityEditor.EditorUserBuildSettings.development = true; + UnityEditor.EditorUserBuildSettings.iOSBuildConfigType = UnityEditor.iOSBuildType.Debug; + UnityEditor.AssetDatabase.SaveAssets(); + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/Editor/DevelopmentBuilder.cs.meta b/popcorn/Assets/USAYAUnityLib/Editor/DevelopmentBuilder.cs.meta new file mode 100644 index 00000000..7ab00287 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/DevelopmentBuilder.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f93a50b4f5aa34178a7078755b891745 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/EditorRestartUnity.cs b/popcorn/Assets/USAYAUnityLib/Editor/EditorRestartUnity.cs new file mode 100644 index 00000000..5f0bd04b --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/EditorRestartUnity.cs @@ -0,0 +1,13 @@ +using UnityEngine; +using UnityEditor; +using System.Collections; +using System.Diagnostics; + +public class EditorRestartUnity{ + [MenuItem("File/Restart")] + static void RestartUnity(){ + // 別のUnityを起動したあとに自身を終了 + Process.Start(EditorApplication.applicationPath); + EditorApplication.Exit(0); + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/Editor/EditorRestartUnity.cs.meta b/popcorn/Assets/USAYAUnityLib/Editor/EditorRestartUnity.cs.meta new file mode 100644 index 00000000..68719bb0 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/EditorRestartUnity.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9e272b580454b439996f43d8c6e7d64e +timeCreated: 1470385604 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/EditorUtils.cs b/popcorn/Assets/USAYAUnityLib/Editor/EditorUtils.cs new file mode 100644 index 00000000..32309892 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/EditorUtils.cs @@ -0,0 +1,349 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using UnityEditor; +using UnityEditor.Experimental.SceneManagement; +using UnityEditor.SceneManagement; +using UnityEditorInternal; +using UnityEngine; + +public static class EditorUtils { + + public static void OpenAllScene(Func editFunc){ + var currentScenePath = EditorSceneManager.GetActiveScene().path; + var scenes = EditorBuildSettings.scenes.Where(s => s.enabled).ToArray(); + for(int i = 0; i < scenes.Length; ++i){ + var scene = scenes[i]; + EditorSceneManager.OpenScene(scene.path); + var gameObjectArray = Resources.FindObjectsOfTypeAll().Where(go => string.IsNullOrEmpty(AssetDatabase.GetAssetPath(go)) && go.hideFlags == HideFlags.None).ToArray(); + var isChanged = editFunc((float)i / scenes.Length, scene, gameObjectArray); + if(isChanged){ + EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene()); + } + } + EditorSceneManager.OpenScene(currentScenePath); + } + + public static GameObject[] GetAllAssets(){ + var pathArray = AssetDatabase.GetAllAssetPaths().Where(path => path.StartsWith("Assets/")).ToArray(); + return pathArray.Select(a => AssetDatabase.LoadAssetAtPath(a, typeof(GameObject)) as GameObject).Where(a => a != null).ToArray(); + } + + public static void FindAllPrefabPath(string folderPath, Action action){ + var pathArray = Directory.GetFiles(folderPath, "*.prefab"); + for(int i = 0; i < pathArray.Length; ++i){ + action((float)i / pathArray.Length, pathArray[i].Replace(Application.dataPath, "Assets")); + } + } + public static void FindAllChildrensPrefabPath(string folderPath, Action action){ + FindAllPrefabPath(folderPath, action); + foreach(var childPath in Directory.GetDirectories(folderPath)){ + FindAllChildrensPrefabPath(childPath, action); + } + } + + public static void EditPrefab(string folderPath, Func editFunc){ + var prefab = PrefabUtility.LoadPrefabContents(folderPath); + var isChanged = editFunc(prefab); + if(isChanged){ + PrefabUtility.SaveAsPrefabAsset(prefab, folderPath); + } + PrefabUtility.UnloadPrefabContents(prefab); + } + + public static void FindAllChildrensPrefab(Transform transform, Action action){ + for(int i = transform.childCount - 1; i >= 0; --i){ + Transform child = transform.GetChild(i); + if(PrefabUtility.IsAnyPrefabInstanceRoot(child.gameObject)){ + action(child); + }else{ + FindAllChildrensPrefab(child, action); + } + } + } + + public static void SwapPrefab(Transform target, GameObject swapPrefab){ + var to = (UnityEditor.PrefabUtility.InstantiatePrefab(swapPrefab) as GameObject).transform; + to.parent = target.parent; + to.localPosition = target.localPosition; + to.localRotation = target.localRotation; + to.localScale = target.localScale; + GameObject.DestroyImmediate(target.gameObject); + } + + public static string MigratePrefabToPrefabVariant(GameObject basePrefab, GameObject migrationPrefab){ + var basePath = AssetDatabase.GetAssetPath(basePrefab); + var path = AssetDatabase.GetAssetPath(migrationPrefab).Replace(".prefab", " Variant.prefab"); + var instance = PrefabUtility.InstantiatePrefab(basePrefab) as GameObject; + PrefabUtility.SaveAsPrefabAsset(instance, path); + GameObject.DestroyImmediate(instance); + + var prefab = PrefabUtility.LoadPrefabContents(path); + + var result = Migrate(prefab.transform, migrationPrefab.transform); + if(!result){ + FixField(prefab.transform, migrationPrefab.transform); + + PrefabUtility.SaveAsPrefabAsset(prefab, path); + } + PrefabUtility.UnloadPrefabContents(prefab); + return path; + } + + private static bool Migrate(Transform targetTransform, Transform migrationTransform){ + var targetChildCount = targetTransform.childCount; + for(int i = 0; i < migrationTransform.childCount; ++i){ + var migrationChild = migrationTransform.GetChild(i); + Transform targetChild; + if(i < targetChildCount){ + targetChild = targetTransform.GetChild(i); + if(migrationChild.name != targetChild.name){ + var containsNameCount = ChildContaintsNameCount(targetTransform, migrationChild.name); + if(containsNameCount == 0){ + targetChild = GameObject.Instantiate(migrationChild.gameObject, targetTransform).transform; + targetChild.name = migrationChild.name; + targetChild.SetSiblingIndex(migrationChild.GetSiblingIndex()); + ++targetChildCount; + }else if(containsNameCount == 1){ + for(int j = 0; j < targetChildCount; ++j){ + if(targetTransform.GetChild(j).name == migrationChild.name){ + targetChild = targetTransform.GetChild(j); + targetChild.SetSiblingIndex(migrationChild.GetSiblingIndex()); + break; + } + } + }else{ + Debug.LogError("同一階層に同じ名前のオブジェクトがある為中止します。"); + return true; + } + } + }else{ + targetChild = GameObject.Instantiate(migrationChild.gameObject, targetTransform).transform; + targetChild.name = migrationChild.name; + ++targetChildCount; + } + CopyComponents(targetChild, migrationChild); + var result = Migrate(targetChild, migrationChild); + if(result){ + return true; + } + targetChild.gameObject.SetActive(migrationChild.gameObject.activeSelf); + } + for(int i = 0; i < targetChildCount; ++i){ + var toChild = targetTransform.GetChild(i); + var containsNameCount = ChildContaintsNameCount(migrationTransform, toChild.name); + if(containsNameCount == 0){ + toChild.gameObject.SetActive(false); + Debug.LogWarning("Change disable " + toChild.GetPath()); + } + } + return false; + } + + private static void FixField(Transform targetTransform, Transform migrationTransform){ + var targetChildCount = targetTransform.childCount; + for(int i = 0; i < migrationTransform.childCount; ++i){ + var migrationChild = migrationTransform.GetChild(i); + var targetChild = targetTransform.GetChild(i); + if(migrationChild.name != targetChild.name){ + for(int j = 0; j < targetChildCount; ++j){ + if(targetTransform.GetChild(j).name == migrationChild.name){ + targetChild = targetTransform.GetChild(j); + break; + } + } + } + FixField(targetChild, migrationChild); + ProcessReflection(migrationChild, targetChild, targetTransform); + migrationChild.FindComponent(fromPS => { + if(fromPS.subEmitters.enabled){ + var fromSub = fromPS.subEmitters; + FindChildrensByPath(targetTransform, migrationChild.GetPath(), t => { + t.FindComponent(toPS => { + var toSub = toPS.subEmitters; + for(int index = 0; index < fromSub.subEmittersCount; ++index){ + var fromTarget = fromSub.GetSubEmitterSystem(index); + FindChildrensByPath(targetTransform, fromTarget.transform.GetPath(), toTarget => { + toSub.SetSubEmitterSystem(index, toTarget.GetComponent()); + }); + } + }); + }); + } + }); + } + } + private static int ChildContaintsNameCount(Transform transform, string name){ + var counter = 0; + foreach(Transform child in transform){ + if(child.name == name){ + ++counter; + } + } + return counter; + } + + private static void CopyComponents(Transform to, Transform from){ + var components = from.gameObject.GetComponents(); + var targetComponents = to.gameObject.GetComponents(); + var currentComponentCount = new Dictionary(); + foreach(var component in components){ + var componentType = component.GetType(); + var componentCount = targetComponents.Count(c => c.GetType() == componentType); + ComponentUtility.CopyComponent(component); + if(componentCount == 0){ + ComponentUtility.PasteComponentAsNew(to.gameObject); + }else if(componentCount == 1){ + var targetComponent = targetComponents.First(c => c.GetType() == componentType); + ComponentUtility.PasteComponentValues(targetComponent); + }else{ + if(!currentComponentCount.ContainsKey(componentType)){ + currentComponentCount.Add(componentType, 0); + } + var count = currentComponentCount[componentType]; + var targetComponentsWithType = targetComponents.Where(c => c.GetType() == componentType); + if(count < targetComponentsWithType.Count()){ + var targetComponent = targetComponents.Where(c => c.GetType() == componentType).ElementAt(count); + currentComponentCount[componentType] += 1; + ComponentUtility.PasteComponentValues(targetComponent); + }else{ + ComponentUtility.PasteComponentAsNew(to.gameObject); + } + } + } + foreach(var component in targetComponents){ + var componentType = component.GetType(); + var componentCount = components.Count(c => c.GetType() == componentType); + if(componentCount == 0){ + Debug.LogWarning("Deestroy component " + to.GetPath() + " " + componentType); + GameObject.DestroyImmediate(component); + } + } + } + + private static void ProcessReflection(Transform from, Transform to, Transform parent){ + var fromComponents = from.GetComponents(); + for(int i = 0; i < fromComponents.Length; ++i){ + var fromType = fromComponents[i].GetType(); + var toComponent = to.GetComponent(fromType); + if(toComponent == null){ + continue; + } + MemberInfo[] members = fromType.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); + foreach(var m in members){ + if(m.MemberType != MemberTypes.Field){ + continue; + } + System.Type fieldType = ((FieldInfo)m).FieldType; + if(fieldType == typeof(Transform) || fieldType == typeof(GameObject)){ + string targetPath; + FieldInfo field = fromType.GetField(m.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic); + if(fieldType == typeof(Transform)){ + Transform t = (Transform)field.GetValue(fromComponents[i]); + if(t == null){ + continue; + } + targetPath = t.GetPath(); + }else if(fieldType == typeof(GameObject)){ + GameObject obj = (GameObject)field.GetValue(fromComponents[i]); + if(obj == null){ + continue; + } + targetPath = obj.transform.GetPath(); + }else{ + continue; + } + FindChildrensByPath(parent, targetPath, targetTransform => { + FieldInfo setField = fromType.GetField(m.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic); + if(setField == null){ + Debug.Log("setField is null " + m.Name); + }else{ + if(fieldType == typeof(Transform)){ + setField.SetValue(toComponent, targetTransform); + }else if(fieldType == typeof(GameObject)){ + setField.SetValue(toComponent, targetTransform.gameObject); + } + } + }); + }else if(fieldType == typeof(Transform[])){ + FieldInfo field = fromType.GetField(m.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic); + Transform[] t = (Transform[])field.GetValue(fromComponents[i]); + if(t == null){ + continue; + } + var targetPathArray = new string[t.Length]; + for(int j = 0; j < t.Length; ++j){ + if(t[j] == null){ + targetPathArray[j] = null; + }else{ + targetPathArray[j] = t[j].GetPath(); + } + } + var newTransformArray = new Transform[t.Length]; + for(int j = 0; j < t.Length; ++j){ + if(targetPathArray[j] == null){ + continue; + } + FindChildrensByPath(parent, targetPathArray[j], targetTransform => { + newTransformArray[j] = targetTransform; + }); + } + FieldInfo setField = fromType.GetField(m.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic); + if(setField == null){ + Debug.Log("setField is null " + m.Name); + }else{ + setField.SetValue(toComponent, newTransformArray); + } + }else if(fieldType == typeof(GameObject[])){ + FieldInfo field = fromType.GetField(m.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic); + GameObject[] t = (GameObject[])field.GetValue(fromComponents[i]); + if(t == null){ + continue; + } + var targetPathArray = new string[t.Length]; + for(int j = 0; j < t.Length; ++j){ + if(t[j] == null){ + targetPathArray[j] = null; + }else{ + targetPathArray[j] = t[j].transform.GetPath(); + } + } + var newArray = new GameObject[t.Length]; + for(int j = 0; j < t.Length; ++j){ + if(targetPathArray[j] == null){ + continue; + } + FindChildrensByPath(parent, targetPathArray[j], targetTransform => { + newArray[j] = targetTransform.gameObject; + }); + } + FieldInfo setField = fromType.GetField(m.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic); + if(setField == null){ + Debug.Log("setField is null " + m.Name); + }else{ + setField.SetValue(toComponent, newArray); + } + } + } + } + } + + private static bool FindChildrensByPath(Transform t, string path, Action callback){ + for(int i = 0; i < t.childCount; ++i){ + Transform child = t.GetChild(i); + if(child.GetPath().Replace(" Variant", "") == path){ + callback(child); + return true; + } + } + for(int i = 0; i < t.childCount; ++i){ + Transform child = t.GetChild(i); + if(FindChildrensByPath(child, path, callback)){ + return true; + } + } + return false; + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Editor/EditorUtils.cs.meta b/popcorn/Assets/USAYAUnityLib/Editor/EditorUtils.cs.meta new file mode 100644 index 00000000..40ba03cb --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/EditorUtils.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d534ae6e5c0ae498088916e672848230 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/EmptyFolderDestroyer.cs b/popcorn/Assets/USAYAUnityLib/Editor/EmptyFolderDestroyer.cs new file mode 100644 index 00000000..2211b99c --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/EmptyFolderDestroyer.cs @@ -0,0 +1,38 @@ +using UnityEngine; +using UnityEditor; +using System.IO; + +[InitializeOnLoad] +public class EmptyFolderDestroyer { + + static EmptyFolderDestroyer(){ + EditorApplication.playModeStateChanged += state => { + if(state == PlayModeStateChange.EnteredEditMode){ + DirectoryInfo directory = new DirectoryInfo(Application.dataPath); + CheckFolder(directory); + } + }; + } + + private static bool CheckFolder(DirectoryInfo directory){ + DirectoryInfo[] childrens = directory.GetDirectories(); + if(childrens.Length > 0){ + bool deleted = false; + foreach(DirectoryInfo childDirectory in childrens){ + deleted = CheckFolder(childDirectory); + } + return deleted ? CheckFolder(directory) : false; + }else if(directory.GetFiles().Length <= 0){ + DeleteFolder(directory.FullName); + return true; + }else{ + return false; + } + } + + private static void DeleteFolder(string path){ + Debug.Log(string.Format("空フォルダを削除 : {0}", path)); + System.IO.Directory.Delete(path, true); + System.IO.File.Delete(string.Format("{0}.meta", path)); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Editor/EmptyFolderDestroyer.cs.meta b/popcorn/Assets/USAYAUnityLib/Editor/EmptyFolderDestroyer.cs.meta new file mode 100644 index 00000000..f9ed05fd --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/EmptyFolderDestroyer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 14638c40afaa74329bacee043a65e015 +timeCreated: 1490339018 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/MeshRendererInspector.cs b/popcorn/Assets/USAYAUnityLib/Editor/MeshRendererInspector.cs new file mode 100644 index 00000000..a734dcc6 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/MeshRendererInspector.cs @@ -0,0 +1,26 @@ +using UnityEngine; +using UnityEditor; +using System.Linq; + +[CustomEditor(typeof(MeshRenderer))] +public class MeshRendererInspector : Editor { + public override void OnInspectorGUI(){ + serializedObject.Update(); + EditorGUILayout.BeginHorizontal(); + + // sorting order + SerializedProperty sortOrderProperty = serializedObject.FindProperty("m_SortingOrder"); + sortOrderProperty.intValue = EditorGUILayout.IntField("Order in Layer", sortOrderProperty.intValue); + + // sorting layer + // SerializedProperty layerIDProperty = serializedObject.FindProperty("m_SortingLayerID"); + // var index = System.Array.FindIndex(SortingLayer.layers, layer => layer.id == layerIDProperty.intValue); + // index = EditorGUILayout.Popup(index, (from layer in SortingLayer.layers select layer.name).ToArray()); + // layerIDProperty.intValue = SortingLayer.layers[index].id; + + EditorGUILayout.EndHorizontal(); + serializedObject.ApplyModifiedProperties(); + + base.OnInspectorGUI(); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Editor/MeshRendererInspector.cs.meta b/popcorn/Assets/USAYAUnityLib/Editor/MeshRendererInspector.cs.meta new file mode 100644 index 00000000..29c52237 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/MeshRendererInspector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7b02150d276f346c084d16910016c901 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/ObliqueProjection.cs b/popcorn/Assets/USAYAUnityLib/Editor/ObliqueProjection.cs new file mode 100644 index 00000000..3fcae916 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/ObliqueProjection.cs @@ -0,0 +1,34 @@ +using UnityEngine; +using UnityEditor; + +[ExecuteInEditMode] +public class ObliqueProjection : MonoBehaviour { + + [Range(-1f, 1f)] + public float horizontal; + [Range(-1f, 1f)] + public float vertical; + public float distance; + private Vector3 orgPosition; + + void OnEnable(){ + EditorApplication.update += EditorUpdate; + orgPosition = transform.localPosition; + } + + void OnDisable(){ + EditorApplication.update -= EditorUpdate; + } + + void EditorUpdate(){ + var cam = GetComponent(); + var proj = cam.projectionMatrix; + proj.m02 = horizontal; + proj.m12 = vertical; + cam.projectionMatrix = proj; + var tan = Mathf.Tan(cam.fieldOfView * 0.5f * Mathf.Deg2Rad); + var rect = cam.pixelRect; + var ratio = (float)rect.width / (float)rect.height; + transform.localPosition = orgPosition + new Vector3(-horizontal * distance * tan * ratio, -vertical * distance * tan, 0f); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Editor/ObliqueProjection.cs.meta b/popcorn/Assets/USAYAUnityLib/Editor/ObliqueProjection.cs.meta new file mode 100644 index 00000000..67a39354 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/ObliqueProjection.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d0f55f0fdd4aa4d1594e6024b695b52e +timeCreated: 1521183141 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/OverrideFile.cs b/popcorn/Assets/USAYAUnityLib/Editor/OverrideFile.cs new file mode 100644 index 00000000..589ea210 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/OverrideFile.cs @@ -0,0 +1,30 @@ +using UnityEngine; +using System.Text.RegularExpressions; +using System.IO; +using UnityEditor; + +public class OverrideFile : AssetPostprocessor { + + static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath){ + if(Event.current == null || Event.current.type != EventType.DragPerform) return; + + foreach(var asset in importedAssets){ + var rootAsset = ParentFile(asset); + if(rootAsset == null) continue; + + if(EditorUtility.DisplayDialog("override", rootAsset + "を上書きしますか?", "上書き", "両方残す")){ + File.Copy(asset, rootAsset, true); + AssetDatabase.DeleteAsset(asset); + + AssetDatabase.ImportAsset(rootAsset); + AssetDatabase.Refresh(); + } + } + } + + static string ParentFile(string name){ + var match = Regex.Match(name, @"(?.*) 1.(?.*)"); + if(!match.Success) return null; + else return string.Format("{0}.{1}", match.Groups["item"], match.Groups["extension"]); + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/Editor/OverrideFile.cs.meta b/popcorn/Assets/USAYAUnityLib/Editor/OverrideFile.cs.meta new file mode 100644 index 00000000..b691dbdf --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/OverrideFile.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7139f64bf261d41ed806517599cf7ed4 +timeCreated: 1461068180 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/SceneReloader.cs b/popcorn/Assets/USAYAUnityLib/Editor/SceneReloader.cs new file mode 100644 index 00000000..85e19293 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/SceneReloader.cs @@ -0,0 +1,36 @@ +using UnityEngine; +using UnityEditor; +using UnityEditor.SceneManagement; + +[InitializeOnLoad] +class SceneReloader : AssetPostprocessor { + + private static bool isReload = false; + + static SceneReloader(){ + EditorApplication.update += Update; + } + + private static void Update(){ + if(isReload){ + isReload = false; + EditorSceneManager.OpenScene(EditorSceneManager.GetActiveScene().path); + } + } + + // 反応しない + // static void OnPreprocessAsset(){ + // isReload = true; + // Debug.Log("PreprocessAsset"); + // } + + static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths){ + // 暫定対応 + // Assetインポート->Scene更新確認Dialog->更新になるので途中での保存には対処出来ない + foreach(var importedAsset in importedAssets){ + if(importedAsset.Contains(".unity")){ + isReload = true; + } + } + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Editor/SceneReloader.cs.meta b/popcorn/Assets/USAYAUnityLib/Editor/SceneReloader.cs.meta new file mode 100644 index 00000000..3538d596 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/SceneReloader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3506533d15c8d4f2f9cb831c2870c717 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/TextureModifier.cs b/popcorn/Assets/USAYAUnityLib/Editor/TextureModifier.cs new file mode 100644 index 00000000..5bc8602c --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/TextureModifier.cs @@ -0,0 +1,89 @@ +using UnityEngine; +using UnityEditor; + +class TextureModifier : AssetPostprocessor { + + void OnPostprocessTexture (Texture2D texture){ + if (!assetPath.EndsWith ("Dither.png")) { + return; + } + + var texw = texture.width; + var texh = texture.height; + + var pixels = texture.GetPixels (); + var offs = 0; + + var k1Per15 = 1.0f / 15.0f; + var k1Per16 = 1.0f / 16.0f; + var k3Per16 = 3.0f / 16.0f; + var k5Per16 = 5.0f / 16.0f; + var k7Per16 = 7.0f / 16.0f; + + for (var y = 0; y < texh; y++) { + for (var x = 0; x < texw; x++) { + float a = pixels [offs].a; + float r = pixels [offs].r; + float g = pixels [offs].g; + float b = pixels [offs].b; + + var a2 = Mathf.Clamp01 (Mathf.Floor (a * 16) * k1Per15); + var r2 = Mathf.Clamp01 (Mathf.Floor (r * 16) * k1Per15); + var g2 = Mathf.Clamp01 (Mathf.Floor (g * 16) * k1Per15); + var b2 = Mathf.Clamp01 (Mathf.Floor (b * 16) * k1Per15); + + var ae = a - a2; + var re = r - r2; + var ge = g - g2; + var be = b - b2; + + pixels [offs].a = a2; + pixels [offs].r = r2; + pixels [offs].g = g2; + pixels [offs].b = b2; + + var n1 = offs + 1; + var n2 = offs + texw - 1; + var n3 = offs + texw; + var n4 = offs + texw + 1; + + if (x < texw - 1) { + pixels [n1].a += ae * k7Per16; + pixels [n1].r += re * k7Per16; + pixels [n1].g += ge * k7Per16; + pixels [n1].b += be * k7Per16; + } + + if (y < texh - 1) { + pixels [n3].a += ae * k5Per16; + pixels [n3].r += re * k5Per16; + pixels [n3].g += ge * k5Per16; + pixels [n3].b += be * k5Per16; + + if (x > 0) { + pixels [n2].a += ae * k3Per16; + pixels [n2].r += re * k3Per16; + pixels [n2].g += ge * k3Per16; + pixels [n2].b += be * k3Per16; + } + + if (x < texw - 1) { + pixels [n4].a += ae * k1Per16; + pixels [n4].r += re * k1Per16; + pixels [n4].g += ge * k1Per16; + pixels [n4].b += be * k1Per16; + } + } + + offs++; + } + } + + texture.SetPixels (pixels); +#if UNITY_2018_1_OR_NEWER + EditorUtility.CompressTexture (texture, TextureFormat.RGBA4444, UnityEditor.TextureCompressionQuality.Best); +#else + EditorUtility.CompressTexture (texture, TextureFormat.RGBA4444, TextureCompressionQuality.Best); +#endif + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Editor/TextureModifier.cs.meta b/popcorn/Assets/USAYAUnityLib/Editor/TextureModifier.cs.meta new file mode 100644 index 00000000..10c6fdf1 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/TextureModifier.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 755998079b2404170980be49465fda06 +timeCreated: 1474456189 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/Tools.meta b/popcorn/Assets/USAYAUnityLib/Editor/Tools.meta new file mode 100644 index 00000000..2832c1a8 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/Tools.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0dd5f0e8659264f84ba2e86340d856aa +folderAsset: yes +timeCreated: 1474347172 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/Tools/ExportAssetBundle.cs b/popcorn/Assets/USAYAUnityLib/Editor/Tools/ExportAssetBundle.cs new file mode 100644 index 00000000..a22b203d --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/Tools/ExportAssetBundle.cs @@ -0,0 +1,18 @@ + +using UnityEngine; +using UnityEditor; +using System.IO; + +public class ExportAssetBundle { + + [MenuItem("Tools/Export AssetBundle")] + static void Export(){ + Build("/iOS/", BuildTarget.iOS); +// Build("/Android/", BuildTarget.Android); + } + + private static void Build(string path, BuildTarget targetPlatform){ + Directory.CreateDirectory(Application.streamingAssetsPath + path); + BuildPipeline.BuildAssetBundles(Application.streamingAssetsPath + path, BuildAssetBundleOptions.ChunkBasedCompression, targetPlatform); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Editor/Tools/ExportAssetBundle.cs.meta b/popcorn/Assets/USAYAUnityLib/Editor/Tools/ExportAssetBundle.cs.meta new file mode 100644 index 00000000..0af08e57 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/Tools/ExportAssetBundle.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7c335a6145daa4e5ba9a31c7e31f20c7 +timeCreated: 1459322533 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/Tools/PlayerPrefsResetter.cs b/popcorn/Assets/USAYAUnityLib/Editor/Tools/PlayerPrefsResetter.cs new file mode 100644 index 00000000..d2bab66a --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/Tools/PlayerPrefsResetter.cs @@ -0,0 +1,42 @@ +using System.IO; +using UnityEngine; +using UnityEditor; + +public static class PlayerPrefsResetter { + + [MenuItem("Tools/ResetTool/Reset PlayerPrefs")] + public static void ResetPlayerPrefs(){ + PlayerPrefs.DeleteAll(); + PlayerPrefs.Save(); + Debug.Log("Reset PlayerPrefs"); + } + + [MenuItem("Tools/ResetTool/Reset Data")] + public static void ResetData(){ + UsayaStorageManager.Remove(UsayaStorageFilename.Main_Data, Const.GameDataTag); + UsayaStorageManager.Remove(UsayaStorageFilename.Settings_Data, Const.GameDataTag); + UsayaStorageManager.Remove(UsayaStorageFilename.Wallet_Data, Const.GameDataTag); + UsayaStorageManager.Remove(UsayaStorageFilename.Purchaser_Data, Const.GameDataTag); + Debug.Log("Reset Data"); + } + + [MenuItem("Tools/ResetTool/Reset All Data")] + public static void ResetAllData(){ + UsayaStorageManager.Remove(UsayaStorageFilename.Main_Data, Const.GameDataTag); + UsayaStorageManager.Remove(UsayaStorageFilename.Settings_Data, Const.GameDataTag); + UsayaStorageManager.Remove(UsayaStorageFilename.Wallet_Data, Const.GameDataTag); + UsayaStorageManager.Remove(UsayaStorageFilename.Purchaser_Data, Const.GameDataTag); + PlayerPrefs.DeleteAll(); + PlayerPrefs.Save(); + Debug.Log("Reset All Data"); + } + [MenuItem("Tools/ResetTool/Delete All Data")] + public static void DeleteAllData(){ + if(!Directory.Exists(Application.persistentDataPath)){ + Debug.Log("Aready deleted."); + return; + } + Directory.Delete(Application.persistentDataPath, true); + Debug.Log("Delete All Data"); + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/Editor/Tools/PlayerPrefsResetter.cs.meta b/popcorn/Assets/USAYAUnityLib/Editor/Tools/PlayerPrefsResetter.cs.meta new file mode 100644 index 00000000..5dcba239 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/Tools/PlayerPrefsResetter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6aa4e9af91459451db718ca557fe66cd +timeCreated: 1474347100 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/Window.meta b/popcorn/Assets/USAYAUnityLib/Editor/Window.meta new file mode 100644 index 00000000..7bd8110e --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/Window.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 43a39b010bb1b4f089436a00bfbc830b +folderAsset: yes +timeCreated: 1475475984 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Editor/Window/UVChecker.cs b/popcorn/Assets/USAYAUnityLib/Editor/Window/UVChecker.cs new file mode 100644 index 00000000..fef682a7 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/Window/UVChecker.cs @@ -0,0 +1,117 @@ +using System.Collections; +using System.Text; +using UnityEditor; +using UnityEngine; + +public class UVChecker : EditorWindow { + private GameObject targetGameObject; + private MeshFilter targetMeshFilter; + private Texture2D tex; + + [MenuItem("Window/UVChecker")] + private static void Open(){ + GetWindow(); + } + + private void OnGUI(){ + targetGameObject = EditorGUILayout.ObjectField("TargetMesh", targetGameObject, typeof(GameObject), true) as GameObject; + if(GUILayout.Button("Execute")){ + targetMeshFilter = targetGameObject.GetComponent(); + tex = new Texture2D(256, 256); + var mesh = targetMeshFilter.sharedMesh; + DrawUV(mesh); + } + if(tex != null){ + EditorGUI.DrawPreviewTexture(new Rect(10, 50, tex.width, tex.height), tex); + } + } + + private void DrawUV(Mesh mesh){ + var uvs = mesh.uv; + var tri = mesh.triangles; + + for(int i_base = 0; i_base < tri.Length; i_base += 3){ + int i_1 = i_base; + int i_2 = i_base + 1; + int i_3 = i_base + 2; + + Vector2 uv1 = uvs[tri[i_1]]; + Vector2 uv2 = uvs[tri[i_2]]; + Vector2 uv3 = uvs[tri[i_3]]; + + DrawLine(uv1, uv2); + DrawLine(uv2, uv3); + DrawLine(uv3, uv1); + } + + tex.Apply(false); + + UVLog(uvs); + } + + private void UVLog(Vector2[] uvs){ + StringBuilder sb = new StringBuilder(); + foreach(var uv in uvs){ + sb.AppendLine(uv.ToString()); + } + + Debug.Log(sb.ToString()); + } + + private void DrawLine(Vector2 from, Vector2 to){ + int x0 = Mathf.RoundToInt(from.x * tex.width); + int y0 = Mathf.RoundToInt(from.y * tex.height); + int x1 = Mathf.RoundToInt(to.x * tex.width); + int y1 = Mathf.RoundToInt(to.y * tex.height); + + DrawLine(x0, y0, x1, y1, Color.red); + } + + private void DrawLine(int x0, int y0, int x1, int y1, Color col){ + int dy = y1 - y0; + int dx = x1 - x0; + int stepx, stepy; + + if(dy < 0){ + dy = -dy; + stepy = -1; + }else{ + stepy = 1; + } + if(dx < 0){ + dx = -dx; + stepx = -1; + }else{ + stepx = 1; + } + dy <<= 1; + dx <<= 1; + + float fraction = 0; + + tex.SetPixel(x0, y0, col); + if(dx > dy){ + fraction = dy - (dx >> 1); + while(Mathf.Abs(x0 - x1) > 1){ + if(fraction >= 0){ + y0 += stepy; + fraction -= dx; + } + x0 += stepx; + fraction += dy; + tex.SetPixel(x0, y0, col); + } + }else{ + fraction = dx - (dy >> 1); + while(Mathf.Abs(y0 - y1) > 1){ + if(fraction >= 0){ + x0 += stepx; + fraction -= dy; + } + y0 += stepy; + fraction += dx; + tex.SetPixel(x0, y0, col); + } + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/Editor/Window/UVChecker.cs.meta b/popcorn/Assets/USAYAUnityLib/Editor/Window/UVChecker.cs.meta new file mode 100644 index 00000000..f62d5fd6 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Editor/Window/UVChecker.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d5ec281105a8a4d83928a39475a0e015 +timeCreated: 1475475744 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Java.meta b/popcorn/Assets/USAYAUnityLib/Java.meta new file mode 100644 index 00000000..39cf110d --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Java.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f1b645066b4c14f2da8a355d54b2d42b +folderAsset: yes +timeCreated: 1505305681 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Java/NotificationReceiver.java.txt b/popcorn/Assets/USAYAUnityLib/Java/NotificationReceiver.java.txt new file mode 100644 index 00000000..7499b69c --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Java/NotificationReceiver.java.txt @@ -0,0 +1,76 @@ +package jp.usaya.lib; + +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.app.Service; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.net.Uri; +import android.support.v4.app.NotificationCompat; + + +/** + * Created by sutoatsushi on 2018/03/23. + */ + +public class NotificationReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + + //値の取得 + Integer primary_key = intent.getIntExtra("PRIMARY_KEY", 0); + String ticker = intent.getStringExtra("TICKER"); + String content_title = intent.getStringExtra("CONTENT_TITLE"); + String content_text = intent.getStringExtra ("CONTENT_TEXT"); + String sound_path = intent.getStringExtra("SOUND_PATH"); + + // intentからPendingIntentを作成 + PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); + + // LargeIcon の Bitmap を生成 + final PackageManager pm = context.getPackageManager(); + ApplicationInfo applicationInfo = null; + try { + applicationInfo = pm.getApplicationInfo(context.getPackageName(),PackageManager.GET_META_DATA); + } catch (NameNotFoundException e) { + e.printStackTrace(); + return; + } + final int appIconResId = applicationInfo.icon; + Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), appIconResId); + + // NotificationBuilderを作成 + NotificationCompat.Builder builder = new NotificationCompat.Builder(context); + builder.setContentIntent(pendingIntent); + builder.setTicker(ticker); //通知到着時に通知バーに表示(4.4まで) + builder.setSmallIcon(appIconResId); //アイコン + builder.setContentTitle(content_title); // タイトル + builder.setContentText(content_text); // 本文(サブタイトル) + builder.setLargeIcon(largeIcon); //開いた時のアイコン + builder.setWhen(System.currentTimeMillis()); //通知に表示される時間(※通知時間ではない!) + + // 通知時の音・バイブ・ライト + if( sound_path.equals("Default") ){ + builder.setDefaults(Notification.DEFAULT_SOUND); + }else{ + builder.setSound( Uri.parse(sound_path)); + } + builder.setDefaults(Notification.DEFAULT_VIBRATE); + builder.setDefaults(Notification.DEFAULT_LIGHTS); + builder.setAutoCancel(true); + + // NotificationManagerを取得 + NotificationManager manager = (NotificationManager) context.getSystemService(Service.NOTIFICATION_SERVICE); + // Notificationを作成して通知 + manager.notify(primary_key, builder.build()); + } + +} diff --git a/popcorn/Assets/USAYAUnityLib/Java/NotificationReceiver.java.txt.meta b/popcorn/Assets/USAYAUnityLib/Java/NotificationReceiver.java.txt.meta new file mode 100644 index 00000000..10c7cd36 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Java/NotificationReceiver.java.txt.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fba37493533674d0daeacdc649fa71d2 +timeCreated: 1521809007 +licenseType: Pro +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Java/UsayaUnityPlayerActivity.java.txt b/popcorn/Assets/USAYAUnityLib/Java/UsayaUnityPlayerActivity.java.txt new file mode 100644 index 00000000..5ea4033f --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Java/UsayaUnityPlayerActivity.java.txt @@ -0,0 +1,221 @@ +package jp.usaya.lib; + +import android.content.Intent; +import android.os.Bundle; +// import com.google.firebase.messaging.MessageForwardingService; +import com.unity3d.player.UnityPlayer; +import com.unity3d.player.UnityPlayerActivity; +// import com.onevcat.uniwebview.AndroidPlugin; +import android.util.DisplayMetrics; + +import android.app.Activity; +import android.content.Intent; +import android.content.pm.*; +import android.net.Uri; +import android.util.Log; +import android.os.SystemClock; +import java.io.File; +import java.net.URLEncoder; +import java.util.*; + +import android.content.Context; +import android.app.AlarmManager; +import android.app.PendingIntent; + +import android.content.pm.ActivityInfo; + +// public class UsayaUnityPlayerActivity extends com.unity3d.player.UnityPlayerActivity // NCMB使わない場合はこっち +public class UsayaUnityPlayerActivity extends com.nifcloud.mbaas.ncmbfcmplugin.UnityPlayerActivity +{ + public UsayaUnityPlayerActivity() + { + } + + protected void onNewIntent(Intent intent) + { + // Intent message = new Intent(this, MessageForwardingService.class); + // message.setAction(MessageForwardingService.ACTION_REMOTE_INTENT); + // message.putExtras(intent); + // startService(message); + } + + public void onCreate(Bundle savedInstanceState) + { + if(mUnityPlayer != null) + { + mUnityPlayer.quit(); + mUnityPlayer = null; + } + super.onCreate(savedInstanceState); + } + + public float getHeightPixels() + { + DisplayMetrics dMetrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getRealMetrics(dMetrics); + return dMetrics.heightPixels; + } + + public float getWidthPixels() + { + DisplayMetrics dMetrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getRealMetrics(dMetrics); + return dMetrics.widthPixels; + } + + public float getPointHeight() + { + DisplayMetrics dMetrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getRealMetrics(dMetrics); + return dMetrics.heightPixels / dMetrics.density; + } + + public float getPointWidth() + { + DisplayMetrics dMetrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getRealMetrics(dMetrics); + return dMetrics.widthPixels / dMetrics.density ; + } + + public void forceOrientationPortrait(){ + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + } + public void forceOrientationLandscape(){ + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + } + + public long elapsedRealtime(){ + return SystemClock.elapsedRealtime(); + } + + public void postTwitterOrFacebook(boolean isTwitter, String message, String url, String imagePath) + { + try + { + String name = isTwitter ? "com.twitter.android" : "com.facebook.katana"; + String type = imagePath.equals("") ? "text/plain" : getIntentTypeForImage(imagePath); + Intent intent = createAppIntent(name, "android.intent.action.SEND", type); + if(intent != null) + { + intent.putExtra("android.intent.extra.TEXT", (new StringBuilder(String.valueOf(message))).append(BR).append(url).toString()); + if(!imagePath.equals("")) + intent.putExtra("android.intent.extra.STREAM", Uri.fromFile(new File(imagePath))); + UnityPlayer.currentActivity.startActivity(intent); + UnityPlayer.UnitySendMessage(UNITY_SEND_GAMEOBJECT, UNITY_SEND_CALLBACK, "0"); + } else + { + UnityPlayer.UnitySendMessage(UNITY_SEND_GAMEOBJECT, UNITY_SEND_CALLBACK, "1"); + } + } + catch(Exception e) + { + Log.e(TAG, "postTwitterOrFacebook", e); + UnityPlayer.UnitySendMessage(UNITY_SEND_GAMEOBJECT, UNITY_SEND_CALLBACK, "2"); + } + } + + public void createChooser(String message, String imagePath) + { + try + { + String type = imagePath.equals("") ? "text/plain" : getIntentTypeForImage(imagePath); + Intent intent = createAppIntent(null, "android.intent.action.SEND", type); + if(intent != null) + { + intent.putExtra("android.intent.extra.TEXT", message); + if(!imagePath.equals("")) + intent.putExtra("android.intent.extra.STREAM", Uri.fromFile(new File(imagePath))); + UnityPlayer.currentActivity.startActivity(Intent.createChooser(intent, "Share")); + UnityPlayer.UnitySendMessage(UNITY_SEND_GAMEOBJECT, UNITY_SEND_CALLBACK, "0"); + } else + { + UnityPlayer.UnitySendMessage(UNITY_SEND_GAMEOBJECT, UNITY_SEND_CALLBACK, "1"); + } + } + catch(Exception e) + { + Log.e(TAG, "createChooser", e); + UnityPlayer.UnitySendMessage(UNITY_SEND_GAMEOBJECT, UNITY_SEND_CALLBACK, "2"); + } + } + + private String getIntentTypeForImage(String imagePath) + { + String extension = imagePath.substring(imagePath.lastIndexOf(".") + 1).toLowerCase(Locale.getDefault()); + return extension != ".png" ? "image/jpg" : "image/png"; + } + + private Intent createAppIntent(String name, String action, String type) + throws Exception + { + Intent intent; + List ris; + Iterator iterator; + try + { + intent = new Intent(action); + intent.setType(type); + ris = UnityPlayer.currentActivity.getPackageManager().queryIntentActivities(intent, 0x10000); + if(name == "" || name == null) + return ris.isEmpty() ? null : intent; + } + catch(Exception e) + { + throw e; + } + iterator = ris.iterator(); + while(iterator.hasNext()) + { + ResolveInfo ri = (ResolveInfo)iterator.next(); + if(ri.activityInfo.packageName.equals(name)) + { + intent.setClassName(ri.activityInfo.packageName, ri.activityInfo.name); + return intent; + } + } + return null; + } + + public void sendNotification(long unixtime, int primary_key, String ticker, String content_title, String content_text, String sound_path) + { + // インテント作成 + Activity activity = UnityPlayer.currentActivity; + Context context = activity.getApplicationContext(); + Intent intent = new Intent(context, NotificationReceiver.class); + //渡す値 + intent.putExtra("PRIMARY_KEY", primary_key); + intent.putExtra("TICKER", ticker); + intent.putExtra("CONTENT_TITLE", content_title); + intent.putExtra("CONTENT_TEXT", content_text); + intent.putExtra("SOUND_PATH", sound_path); + + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(unixtime); + + PendingIntent sender = PendingIntent.getBroadcast(context, primary_key, intent, PendingIntent.FLAG_UPDATE_CURRENT); + AlarmManager alarm = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); + alarm.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis() , sender); + } + public void clearNotification(int primary_key) + { + // インテント作成 + Activity activity = UnityPlayer.currentActivity; + Context context = activity.getApplicationContext(); + Intent intent = new Intent(context,NotificationReceiver.class); + + PendingIntent sender = PendingIntent.getBroadcast(context, primary_key, intent, PendingIntent.FLAG_CANCEL_CURRENT); + AlarmManager alarm = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); + alarm.cancel(sender); + sender.cancel(); + } + + public static final String TAG = "UsayaUnityPlayerActivity"; + public static final String BR = System.getProperty("line.separator"); + public static final String UNITY_SEND_GAMEOBJECT = "ShareManager"; + public static final String UNITY_SEND_CALLBACK = "OnShareManagerResult"; + public static final String RESULT_SUCCESS = "0"; + public static final String RESULT_NOT_AVAILABLE = "1"; + public static final String RESULT_ERROR = "2"; + + +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/Java/UsayaUnityPlayerActivity.java.txt.meta b/popcorn/Assets/USAYAUnityLib/Java/UsayaUnityPlayerActivity.java.txt.meta new file mode 100644 index 00000000..7fd7e6e1 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Java/UsayaUnityPlayerActivity.java.txt.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1d2033f57cf7d4c7388ff1c7330f7e13 +timeCreated: 1505376972 +licenseType: Pro +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Logo.meta b/popcorn/Assets/USAYAUnityLib/Logo.meta new file mode 100644 index 00000000..74a5791d --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Logo.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9d5228357859d4cbc8b327ec4aa665ac +folderAsset: yes +timeCreated: 1495443112 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Logo/Logo.png b/popcorn/Assets/USAYAUnityLib/Logo/Logo.png new file mode 100644 index 00000000..deef9c6c Binary files /dev/null and b/popcorn/Assets/USAYAUnityLib/Logo/Logo.png differ diff --git a/popcorn/Assets/USAYAUnityLib/Logo/Logo.png.meta b/popcorn/Assets/USAYAUnityLib/Logo/Logo.png.meta new file mode 100644 index 00000000..94226e66 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Logo/Logo.png.meta @@ -0,0 +1,121 @@ +fileFormatVersion: 2 +guid: be9c6b7d0e0264a8cae5ecd136b2b5d0 +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 9 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 0 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: iPhone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 4 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 1 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 13 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 1 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: fbe5b219faf0247128f647c4af7d32fb + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Plugins.meta b/popcorn/Assets/USAYAUnityLib/Plugins.meta new file mode 100644 index 00000000..18f9727e --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c3865fff9beea4eaf9bf9e375ae00fea +folderAsset: yes +timeCreated: 1505292483 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/Android.meta b/popcorn/Assets/USAYAUnityLib/Plugins/Android.meta new file mode 100644 index 00000000..2c3210a3 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/Android.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 11c71e8e010bc4f41b23483713363284 +folderAsset: yes +timeCreated: 1505303258 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/Android/NotificationReceiver.jar b/popcorn/Assets/USAYAUnityLib/Plugins/Android/NotificationReceiver.jar new file mode 100644 index 00000000..5036bdb7 Binary files /dev/null and b/popcorn/Assets/USAYAUnityLib/Plugins/Android/NotificationReceiver.jar differ diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/Android/NotificationReceiver.jar.meta b/popcorn/Assets/USAYAUnityLib/Plugins/Android/NotificationReceiver.jar.meta new file mode 100644 index 00000000..11895564 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/Android/NotificationReceiver.jar.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: a1f7a4504e34b42aab2e242344e11b55 +timeCreated: 1521809007 +licenseType: Pro +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + Android: Android + second: + enabled: 1 + settings: {} + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/Android/UsayaUnityPlayerActivity.jar b/popcorn/Assets/USAYAUnityLib/Plugins/Android/UsayaUnityPlayerActivity.jar new file mode 100644 index 00000000..de28b685 Binary files /dev/null and b/popcorn/Assets/USAYAUnityLib/Plugins/Android/UsayaUnityPlayerActivity.jar differ diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/Android/UsayaUnityPlayerActivity.jar.meta b/popcorn/Assets/USAYAUnityLib/Plugins/Android/UsayaUnityPlayerActivity.jar.meta new file mode 100644 index 00000000..f54f2aee --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/Android/UsayaUnityPlayerActivity.jar.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 9ae001176e96c4ba2b2d8ff79bbbc03b +timeCreated: 1505373166 +licenseType: Pro +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + Android: Android + second: + enabled: 1 + settings: {} + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/NativeUtils.cs b/popcorn/Assets/USAYAUnityLib/Plugins/NativeUtils.cs new file mode 100644 index 00000000..f2c7ae77 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/NativeUtils.cs @@ -0,0 +1,394 @@ +using UnityEngine; +using System; +using System.Collections; +using System.Runtime.InteropServices; + + +public enum VibrationType { + None, + Once, + OnceStrong, + OnceWeak, + DoubleStrong, + DoubleWeak, + Triple, +} + +public static class NativeUtils { + + // Vibration Effect Type + public static readonly string vEffectOneShot = "EFFECT_DEFAULT_AMPLITUDE"; + public static readonly string vEffectClick = "EFFECT_CLICK"; + public static readonly string vEffectDClick = "EFFECT_DOUBLE_CLICK"; + public static readonly string vEffectHClick = "EFFECT_HEAVY_CLICK"; + public static readonly string vEffectTick = "EFFECT_TICK"; + +#if UNITY_EDITOR +#elif UNITY_IOS + [DllImport("__Internal")] + private static extern int _getHeight(); + [DllImport("__Internal")] + private static extern int _getWidth(); + [DllImport("__Internal")] + private static extern int _getPointHeight(); + [DllImport("__Internal")] + private static extern int _getPointWidth(); + [DllImport("__Internal")] + private static extern bool _enableReviewWindow(); + [DllImport("__Internal")] + private static extern int _reviewWindow(string appid); + [DllImport("__Internal")] + private static extern long _systemClockTime(); + + [DllImport("__Internal")] + private static extern bool _canOpenTwitter(); + [DllImport("__Internal")] + private static extern bool _canOpenFacebook(); + + [DllImport("__Internal")] + private static extern void _registerNotification(); + [DllImport("__Internal")] + private static extern void _scheduleNotification(int triggerInSeconds, string message, string alarmId); + [DllImport("__Internal")] + private static extern void _cancelAllNotifications(); + [DllImport("__Internal")] + private static extern void _PlayVibration(int id); + [DllImport("__Internal")] + private static extern void _PlayVibrationOnce(); + [DllImport("__Internal")] + private static extern void _PlayVibrationOnceStrong(); + [DllImport("__Internal")] + private static extern void _PlayVibrationOnceWeak(); + [DllImport("__Internal")] + private static extern void _PlayVibrationDoubleStrong(); + [DllImport("__Internal")] + private static extern void _PlayVibrationDoubleWeak(); + [DllImport("__Internal")] + private static extern void _PlayVibrationTriple(); + + [DllImport("__Internal")] + private static extern void _showAlert(string title, string message); + +#elif UNITY_ANDROID + + private static void _Vibration(){ + Handheld.Vibrate(); + } + private static void _VibrationAndroid(string effectType, long msec = 100){ + using (AndroidJavaClass cls = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) + using (AndroidJavaObject jo = cls.GetStatic("currentActivity")) + using (AndroidJavaObject vibrator = jo.Call("getSystemService", "vibrator")) + { + if(androidOSVersion() >= 26 ) + { + using (AndroidJavaClass vCls = new AndroidJavaClass("android.os.VibrationEffect")) + { + AndroidJavaObject vEffect = default; + if( effectType != NativeUtils.vEffectOneShot && androidOSVersion() >= 29) + { + vEffect = vCls.CallStatic("createPredefined", vCls.GetStatic(effectType)); + } + else + { + vEffect = vCls.CallStatic("createOneShot", new object[] { msec, vCls.GetStatic("DEFAULT_AMPLITUDE") }); + } + vibrator.Call("vibrate", vEffect); + } + } + else + { + vibrator.Call("vibrate", msec); + } + } + } + + private static int androidOSVersion() { +#if !UNITY_EDITOR + using (var version = new AndroidJavaClass("android.os.Build$VERSION")) + { + return version.GetStatic("SDK_INT"); + } +#else + return -1; +#endif + } + +#endif + + public static int getHeight(){ + int height = 0; +#if UNITY_EDITOR + height = Screen.height; +#elif UNITY_IOS + height = _getHeight(); +#elif UNITY_ANDROID + using (AndroidJavaClass cls = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) + using (AndroidJavaObject jo = cls.GetStatic("currentActivity")) + { + height = (int)jo.Call("getHeightPixels"); + } +#endif + return height; + } + public static int getWidth(){ + int width = 0; +#if UNITY_EDITOR + width = Screen.width; +#elif UNITY_IOS + width = _getWidth(); +#elif UNITY_ANDROID + using (AndroidJavaClass cls = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) + using (AndroidJavaObject jo = cls.GetStatic("currentActivity")) + { + width = (int)jo.Call("getWidthPixels"); + } +#endif + return width; + } + + public static int getPointHeight(){ + int height = 0; + #if UNITY_EDITOR + height = Screen.height; + #elif UNITY_IOS + if (Application.platform != RuntimePlatform.OSXEditor) { + height = _getPointHeight(); + } + #elif UNITY_ANDROID + using (AndroidJavaClass cls = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) + using (AndroidJavaObject jo = cls.GetStatic("currentActivity")) + { + height = (int)jo.Call("getPointHeight"); + } + #endif + + + + return height; + } + public static int getPointWidth(){ + int width = 0; + #if UNITY_EDITOR + width = Screen.width; + #elif UNITY_IOS && !UNITY_EDITOR + if (Application.platform != RuntimePlatform.OSXEditor) { + width = _getPointWidth(); + } + #elif UNITY_ANDROID && !UNITY_EDITOR + using (AndroidJavaClass cls = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) + using (AndroidJavaObject jo = cls.GetStatic("currentActivity")) + { + width = (int)jo.Call("getPointWidth"); + } + #endif + + return width; + } + + public static void forceOrientationLandscape(){ +#if UNITY_EDITOR +#elif UNITY_IOS +#elif UNITY_ANDROID + using (AndroidJavaClass cls = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) + using (AndroidJavaObject jo = cls.GetStatic("currentActivity")) + { + jo.Call("forceOrientationLandscape"); + } +#endif + } + public static void forceOrientationPortrait(){ +#if UNITY_EDITOR +#elif UNITY_IOS +#elif UNITY_ANDROID + using (AndroidJavaClass cls = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) + using (AndroidJavaObject jo = cls.GetStatic("currentActivity")) + { + jo.Call("forceOrientationPortrait"); + } +#endif + } + + public static bool enableReviewWindow(){ + bool res = false; +#if UNITY_IOS && !UNITY_EDITOR + if (Application.platform != RuntimePlatform.OSXEditor) { + res = _enableReviewWindow(); + } +#endif + return res; + } + + public static void reviewWindow( string appid){ + #if UNITY_IOS && !UNITY_EDITOR + if (Application.platform != RuntimePlatform.OSXEditor) { + _reviewWindow(appid); + } + #endif + } + + /// + /// 端末起動からの経過時間(s) + /// + public static long systemClockTime(){ + + long res = 0; + #if UNITY_EDITOR + var start = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + res = (long)(DateTime.Now.ToUniversalTime() - start).TotalSeconds; + #elif UNITY_IOS && !UNITY_EDITOR + if (Application.platform != RuntimePlatform.OSXEditor) { + res = _systemClockTime(); + } + #elif UNITY_ANDROID && !UNITY_EDITOR + using (AndroidJavaClass cls = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) + using (AndroidJavaObject jo = cls.GetStatic("currentActivity")) + { + res = (long)(jo.Call("elapsedRealtime") / 1000); + } + #endif + + return res; + } + +#if UNITY_ANDROID + public static int getAndroidApiLevel(){ + var cls = new AndroidJavaClass("android.os.Build$VERSION"); + var apiLevel = cls.GetStatic("SDK_INT"); + Debug.Log(apiLevel); + return apiLevel; + } +#elif UNITY_EDITOR +#elif UNITY_IOS + public static bool canOpenTwitter(){ + return _canOpenTwitter(); + } + public static bool canOpenFacebook(){ + return _canOpenFacebook(); + } + + public static int GetiOSMajorVersion(){ + string version = SystemInfo.operatingSystem; + version = version.Split('.')[0]; + string[] stringSplits = version.Split(' '); + version = stringSplits[stringSplits.Length -1]; + return int.Parse(version); + } +#endif + public static void InitNotification() + { +#if UNITY_EDITOR +#elif UNITY_IOS +#elif UNITY_ANDROID + // UniLocalNotification.Initialize(); +#endif + } + + public static void RegisterNotification() + { +#if UNITY_EDITOR +#elif UNITY_IOS + _registerNotification(); +#elif UNITY_ANDROID +#endif + } + public static void ScheduleNotification(int triggerInSeconds, string title, string message, int id) + { +#if UNITY_EDITOR +#elif UNITY_IOS + _scheduleNotification(triggerInSeconds, message, id.ToString()); +#elif UNITY_ANDROID + // UniLocalNotification.Register(triggerInSeconds, message, title); +#endif + } + public static void CancelAllNotifications(){ +#if UNITY_EDITOR +#elif UNITY_IOS + _cancelAllNotifications(); +#elif UNITY_ANDROID + // UniLocalNotification.CancelAll(); +#endif + } + + public static void PlayVibration(VibrationType vibrationType){ + switch(vibrationType){ + case VibrationType.Once: + PlayVibrationOnce(); + break; + case VibrationType.OnceStrong: + PlayVibrationOnceStrong(); + break; + case VibrationType.OnceWeak: + PlayVibrationOnceWeak(); + break; + case VibrationType.DoubleStrong: + PlayVibrationDoubleStrong(); + break; + case VibrationType.DoubleWeak: + PlayVibrationDoubleWeak(); + break; + case VibrationType.Triple: + PlayVibrationTriple(); + break; + } + } + + public static void PlayVibrationOnce(){ +#if UNITY_EDITOR +#elif UNITY_IOS + _PlayVibrationOnce(); +#elif UNITY_ANDROID + _VibrationAndroid(NativeUtils.vEffectClick, 20); +#endif + } + public static void PlayVibrationOnceStrong(){ +#if UNITY_EDITOR +#elif UNITY_IOS + _PlayVibrationOnceStrong(); +#elif UNITY_ANDROID + _VibrationAndroid(NativeUtils.vEffectHClick, 50); +#endif + } + public static void PlayVibrationOnceWeak(){ +#if UNITY_EDITOR +#elif UNITY_IOS + _PlayVibrationOnceWeak(); +#elif UNITY_ANDROID + _VibrationAndroid(NativeUtils.vEffectTick, 10); +#endif + } + public static void PlayVibrationDoubleStrong(){ +#if UNITY_EDITOR +#elif UNITY_IOS + _PlayVibrationDoubleStrong(); +#elif UNITY_ANDROID + _VibrationAndroid(NativeUtils.vEffectDClick, 80); +#endif + } + public static void PlayVibrationDoubleWeak(){ +#if UNITY_EDITOR +#elif UNITY_IOS + _PlayVibrationDoubleWeak(); +#elif UNITY_ANDROID + _VibrationAndroid(NativeUtils.vEffectOneShot, 100); // TODO:最適化 +#endif + } + public static void PlayVibrationTriple(){ +#if UNITY_EDITOR +#elif UNITY_IOS + _PlayVibrationTriple(); +#elif UNITY_ANDROID + _VibrationAndroid(NativeUtils.vEffectOneShot, 200); // TODO:最適化 +#endif + } + + public static void ShowAlert(string title, string message){ +#if UNITY_EDITOR +#elif UNITY_IOS + _showAlert(title, message); +#elif UNITY_ANDROID +// TODO: +#endif + } +} + + diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/NativeUtils.cs.meta b/popcorn/Assets/USAYAUnityLib/Plugins/NativeUtils.cs.meta new file mode 100644 index 00000000..dae442a0 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/NativeUtils.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1d79e45cfabba4cd3b1d6a9f7ab0bf2c +timeCreated: 1496659633 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/iOS.meta b/popcorn/Assets/USAYAUnityLib/Plugins/iOS.meta new file mode 100644 index 00000000..b29905d8 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/iOS.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 2aac40ba60ff849ee88ec188ff5852ed +folderAsset: yes +timeCreated: 1505293985 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_NativeCore.h b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_NativeCore.h new file mode 100644 index 00000000..b6805f5b --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_NativeCore.h @@ -0,0 +1,22 @@ + +@interface ISN_DataConvertor : NSObject + ++ (NSString*) charToNSString: (char*)value; ++ (const char *) NSStringToChar: (NSString *) value; + +@end + + +@interface ISN_NativeUtility : NSObject + +@property (strong) UIActivityIndicatorView *spinner; + ++ (id) sharedInstance; ++ (int) majorIOSVersion; ++ (BOOL) IsIPad; + +- (void) ISN_NativeLog: (NSString *) appId, ...; +- (void) ISN_SetLogState: (BOOL) appId; + +@end + diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_NativeCore.h.meta b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_NativeCore.h.meta new file mode 100644 index 00000000..8508e771 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_NativeCore.h.meta @@ -0,0 +1,137 @@ +fileFormatVersion: 2 +guid: 6387bda137dcb4b67ad4a0285193a98f +timeCreated: 1505294039 +licenseType: Pro +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + iPhone: iOS + second: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: Accounts;Social; + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_NativeCore.mm b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_NativeCore.mm new file mode 100644 index 00000000..91748177 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_NativeCore.mm @@ -0,0 +1,97 @@ +#import + +#import "ISN_NativeCore.h" +#import "AppDelegateListener.h" + + +@implementation ISN_DataConvertor + ++(NSString *) charToNSString:(char *)value { + if (value != NULL) { + return [NSString stringWithUTF8String: value]; + } else { + return [NSString stringWithUTF8String: ""]; + } +} + ++ (const char *) NSStringToChar:(NSString *)value { + return [value UTF8String]; +} + +@end + +@implementation ISN_NativeUtility + +static bool logState = false; +static ISN_NativeUtility * na_sharedInstance; + ++ (id)sharedInstance { + if (na_sharedInstance == nil) { + na_sharedInstance = [[self alloc] init]; + } + + return na_sharedInstance; +} + ++ (BOOL) IsIPad { + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + return true; + } else { + return false; + } +} + ++ (int) majorIOSVersion { + NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; + return [[vComp objectAtIndex:0] intValue]; +} + +-(void) ISN_SetLogState:(BOOL)state { + logState = state; +} + +-(void) ISN_NativeLog:(NSString *)msg, ... { + if(logState) { + va_list argumentList; + va_start(argumentList, msg); + + NSString *message = [[NSString alloc] initWithFormat:msg arguments:argumentList]; + + // clean up + va_end(argumentList); + + NSLog(@"ISN_NativeLog: %@", message); + } +} + +- (CGFloat) GetW { + UIViewController *vc = UnityGetGLViewController(); + + bool IsLandscape = true; + +#if !TARGET_OS_TV + + UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; + if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) { + IsLandscape = true; + } else { + IsLandscape = false; + } +#endif + + CGFloat w; + if(IsLandscape) { + w = vc.view.frame.size.height; + } else { + w = vc.view.frame.size.width; + } + + NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; + if ([[vComp objectAtIndex:0] intValue] >= 8) { + w = vc.view.frame.size.width; + } + + return w; +} + +@end diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_NativeCore.mm.meta b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_NativeCore.mm.meta new file mode 100644 index 00000000..bab15d9e --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_NativeCore.mm.meta @@ -0,0 +1,129 @@ +fileFormatVersion: 2 +guid: 2b48a13e4a3f24b7c9817beafda29890 +timeCreated: 1505294039 +licenseType: Pro +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + iPhone: iOS + second: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: Accounts;Social; + data: + first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_SocialGate.mm b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_SocialGate.mm new file mode 100644 index 00000000..0bc311ab --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_SocialGate.mm @@ -0,0 +1,1022 @@ +#if !TARGET_OS_TV + +// +// SocialGate.m +// Unity-iPhone +// +// Created by lacost on 2/15/14. +// +// + +#import +#import +#import +#import + +#if UNITY_VERSION < 450 +#include "iPhone_View.h" +#endif + +#import "ISN_NativeCore.h" + + +@interface ISN_SocialGate : NSObject + + +@property (nonatomic, strong) UIDocumentInteractionController * documentInteractionController; + ++ (id) sharedInstance; + +- (void) twitterPost:(NSString*)status url: (NSString*) url media: (NSString*) media; +- (void) fbPost:(NSString*)status url: (NSString*) url media: (NSString*) media; + + + +- (void) mediaShare:(NSString*)text media: (NSString*) media; +- (void) sendEmail:(NSString*)subject body: (NSString*) body recipients: (NSString*) recipients media: (NSString*) media; + +- (void)whatsappShareText:(NSString *)msg; +- (void)whatsappShareImage:(NSString *)media; + + + +@end + + + + +@implementation ISN_SocialGate + +static ISN_SocialGate * cg_sharedInstance; + + ++ (id)sharedInstance { + + if (cg_sharedInstance == nil) { + cg_sharedInstance = [[self alloc] init]; + } + + return cg_sharedInstance; +} + + +#define MMM_WHATSAPP_URL @"whatsapp://" +#define MMM_WHATSAPP_IMAGEFILENAME @"wa.wai" +#define MMM_WHATSAPP_IMAGEUTI @"net.whatsapp.image" + +-(BOOL)whatsappInstalled{ + return [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:MMM_WHATSAPP_URL]]; +} + + +-(void)whatsappShareText:(NSString *)msg { + + + + NSString * urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=%@",msg]; + NSURL * whatsappURL = [NSURL URLWithString:[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; + if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) { + [[UIApplication sharedApplication] openURL: whatsappURL]; + } else { + //Probably report the errror + } + +} + +-(void)whatsappShareImage:(NSString *)media { + + NSData *imageData = [[NSData alloc] initWithBase64Encoding:media]; + UIImage *image = [[UIImage alloc] initWithData:imageData]; + + NSString *filepath=[NSTemporaryDirectory() stringByAppendingPathComponent:MMM_WHATSAPP_IMAGEFILENAME]; + NSURL *fileURL = [NSURL fileURLWithPath:filepath]; + + // save image to path.. + if([UIImagePNGRepresentation(image) writeToFile:filepath atomically:YES]){ + + // setup a document interaction controller with our file .. + UIDocumentInteractionController *dic = [self setupControllerWithURL:fileURL usingDelegate:nil]; + self.documentInteractionController=dic; + dic.UTI = MMM_WHATSAPP_IMAGEUTI; + dic.name = MMM_WHATSAPP_IMAGEFILENAME; + + dic.annotation=@{@"message":@"Test Text",@"text":@"Test Text"}; + + + UIViewController *vc = UnityGetGLViewController(); + + [dic presentOpenInMenuFromRect:vc.view.bounds inView:vc.view animated:YES]; + + // exit; we're not calling activityDidFinish here, but later in documentInteractionControllerDidDismissOpenInMenu. + return; + } + +} + +- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL + usingDelegate: (id ) interactionDelegate { + + UIDocumentInteractionController *interactionController = + [UIDocumentInteractionController interactionControllerWithURL: fileURL]; + interactionController.delegate = interactionDelegate; + + return interactionController; +} + + +-(void) mediaShare:(NSString *)text media:(NSString *)media { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: mediaShare"]; + UIActivityViewController *controller; + + + if(media.length != 0) { + NSData *imageData = [[NSData alloc] initWithBase64Encoding:media]; + UIImage *image = [[UIImage alloc] initWithData:imageData]; + + //[UIPopoverPresentationController alloc] ini + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: image added"]; + if(text.length != 0) { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: text added"]; + controller = [[UIActivityViewController alloc] initWithActivityItems:@[text, image] applicationActivities:nil]; + } else { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: no text"]; + controller = [[UIActivityViewController alloc] initWithActivityItems:@[image] applicationActivities:nil]; + } + + } else { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: no media"]; + controller = [[UIActivityViewController alloc] initWithActivityItems:@[text] applicationActivities:nil]; + } + + + + + UIViewController *vc = UnityGetGLViewController(); + + + NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; + if ([[vComp objectAtIndex:0] intValue] >= 8) { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: iOS8 detected"]; + UIPopoverPresentationController *presentationController = [controller popoverPresentationController]; + presentationController.sourceView = vc.view; + } + + [vc presentViewController:controller animated:YES completion:nil]; + +} + +-(void) twitterPost:(NSString *)status url:(NSString *)url media:(NSString *)media { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: twitterPost"]; + + [SLComposeServiceViewController attemptRotationToDeviceOrientation]; + SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; + + if(tweetSheet == NULL) { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: SLServiceTypeTwitter not avaliable "]; + UnitySendMessage("ShareManager", "OnTwitterPostFailed", [ISN_DataConvertor NSStringToChar:@""]); + return; + } + + + if(status.length > 0) { + [tweetSheet setInitialText:status]; + } + + if(media.length > 0) { + NSData *imageData = [[NSData alloc] initWithBase64Encoding:media]; + UIImage *image = [[UIImage alloc] initWithData:imageData]; + [tweetSheet addImage:image]; + } + + if(url.length > 0) { + NSURL *urlObject = [NSURL URLWithString:url]; + [tweetSheet addURL:urlObject]; + } + + UIViewController *vc = UnityGetGLViewController(); + [vc presentViewController:tweetSheet animated:YES completion:nil]; + + tweetSheet.completionHandler = ^(SLComposeViewControllerResult result) { + NSArray *vComp; + switch(result) { + // This means the user cancelled without sending the Tweet + case SLComposeViewControllerResultCancelled: + vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; + if ([[vComp objectAtIndex:0] intValue] < 7) { + [tweetSheet dismissViewControllerAnimated:YES completion:nil]; + } + + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: Tweet message was cancelled"]; + UnitySendMessage("ShareManager", "OnTwitterPostFailed", [ISN_DataConvertor NSStringToChar:@""]); + break; + // This means the user hit 'Send' + case SLComposeViewControllerResultDone: + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: Done pressed successfully"]; + + vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; + if ([[vComp objectAtIndex:0] intValue] < 7) { + [tweetSheet dismissViewControllerAnimated:YES completion:nil]; + } + + UnitySendMessage("ShareManager", "OnTwitterPostSuccess", [ISN_DataConvertor NSStringToChar:@""]); + break; + } + }; +} + +- (void)twitterPostGif:(NSString *)status url:(NSString*)gifPath { + + NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/update_with_media.json"]; + NSMutableDictionary *paramater = [[NSMutableDictionary alloc] init]; + + //set the parameter here. to see others acceptable parameters find it at twitter API here : http://bit.ly/Occe6R + [paramater setObject:status forKey:@"status"]; + + ACAccountStore *accountStore = [[ACAccountStore alloc] init]; + ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; + + [accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) { + if (granted == YES) { + + NSArray *accountsArray = [accountStore accountsWithAccountType:accountType]; + + if ([accountsArray count] > 0) { + ACAccount *twitterAccount = [accountsArray lastObject]; + + SLRequest *postRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:url parameters:paramater]; + + NSData *imageData = [[NSData alloc] initWithContentsOfFile:gifPath]; // GIF89a file + + + [postRequest addMultipartData:imageData withName:@"media[]" type:@"image/gif" filename:@"animated.gif"]; + + [postRequest setAccount:twitterAccount]; // or postRequest.account = twitterAccount; + + [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { + NSString *output = [NSString stringWithFormat:@"HTTP response status: %li", (long)[urlResponse statusCode]]; + NSLog(@"output = %@",output); + dispatch_async(dispatch_get_main_queue(), ^{ + + }); + + if([urlResponse statusCode] == 200) { + UnitySendMessage("ShareManager", "OnTwitterPostSuccess", [ISN_DataConvertor NSStringToChar:@""]); + + } else { + UnitySendMessage("ShareManager", "OnTwitterPostFailed", [ISN_DataConvertor NSStringToChar:@""]); + } + + }]; + } + + } + }]; +} + + + + +- (void) fbPost:(NSString *)status url:(NSString *)url media:(NSString *)media { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: fbPostWithMedia"]; + + [SLComposeServiceViewController attemptRotationToDeviceOrientation]; + SLComposeViewController *fbSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; + if(fbSheet == NULL) { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: SLServiceTypeFacebook not avaliable "]; + UnitySendMessage("ShareManager", "OnFacebookPostFailed", [ISN_DataConvertor NSStringToChar:@""]); + return; + } + + + if(status.length > 0) { + [fbSheet setInitialText:status]; + } + + if(media.length > 0) { + NSData *imageData = [[NSData alloc] initWithBase64Encoding:media]; + UIImage *image = [[UIImage alloc] initWithData:imageData]; + [fbSheet addImage:image]; + } + + if(url.length > 0) { + NSURL *urlObject = [NSURL URLWithString:url]; + [fbSheet addURL:urlObject]; + } + + + UIViewController *vc = UnityGetGLViewController(); + + [vc presentViewController:fbSheet animated:YES completion:nil]; + + fbSheet.completionHandler = ^(SLComposeViewControllerResult result) { + NSArray *vComp; + switch(result) { + + case SLComposeViewControllerResultCancelled: + + vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; + if ([[vComp objectAtIndex:0] intValue] < 7) { + [fbSheet dismissViewControllerAnimated:YES completion:nil]; + } + + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: Tweet message was cancelled"]; + UnitySendMessage("ShareManager", "OnFacebookPostFailed", [ISN_DataConvertor NSStringToChar:@""]); + break; + // This means the user hit 'Send' + case SLComposeViewControllerResultDone: + + vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; + if ([[vComp objectAtIndex:0] intValue] < 7) { + [fbSheet dismissViewControllerAnimated:YES completion:nil]; + } + + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: Done pressed successfully"]; + UnitySendMessage("ShareManager", "OnFacebookPostSuccess", [ISN_DataConvertor NSStringToChar:@""]); + break; + } + + }; + +} + + + +- (void) sendEmail:(NSString *)subject body:(NSString *)body recipients: (NSString*) recipients media:(NSString *)media { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: sendEmail"]; + + + //Create a string with HTML formatting for the email body + NSMutableString *emailBody = [[NSMutableString alloc] initWithString:@""] ; +#if UNITY_VERSION < 500 + [emailBody retain]; +#endif + + + //Add some text to it however you want + [emailBody appendString:@"

"]; + [emailBody appendString:body]; + [emailBody appendString:@"

"]; + + + /* + if(media.length > 0) { + // NSLog(@"media: %@",media); + + + + [emailBody appendString:[NSString stringWithFormat:@"

",media]]; + } + */ + + + //close the HTML formatting + [emailBody appendString:@""]; + // NSLog(@"emailBody: %@",emailBody); + + + + //Create the mail composer window + MFMailComposeViewController *emailDialog = [[MFMailComposeViewController alloc] init]; + + if(emailDialog == nil) { + UnitySendMessage("ShareManager", "OnMailFailed", [ISN_DataConvertor NSStringToChar:@""]); + return; + } + + emailDialog.mailComposeDelegate = self; + [emailDialog setSubject:subject]; + [emailDialog setMessageBody:emailBody isHTML:YES]; + + if(media.length > 0) { + NSData *imageData = [[NSData alloc] initWithBase64Encoding:media]; + [emailDialog addAttachmentData:imageData mimeType:@"image/png" fileName:@"Attachment"]; + } + + + NSArray *emails = [recipients componentsSeparatedByString:@","]; + + [emailDialog setToRecipients:emails]; + + + UIViewController *vc = UnityGetGLViewController(); + + [vc presentViewController:emailDialog animated:YES completion:nil]; +#if UNITY_VERSION < 500 + [emailDialog release]; + [emailBody release]; +#endif + + +} + + +#pragma private + +- (NSString*) photoFilePath { + return [NSString stringWithFormat:@"%@/%@",[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"],@"tempinstgramphoto.igo"]; +} + + +- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error { + switch (result) + { + case MFMailComposeResultCancelled: + UnitySendMessage("ShareManager", "OnMailFailed", [ISN_DataConvertor NSStringToChar:@""]); + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: Mail cancelled"]; + break; + case MFMailComposeResultSaved: + UnitySendMessage("ShareManager", "OnMailFailed", [ISN_DataConvertor NSStringToChar:@""]); + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: Mail saved"]; + break; + case MFMailComposeResultSent: + UnitySendMessage("ShareManager", "OnMailSuccess", [ISN_DataConvertor NSStringToChar:@""]); + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: Mail sent"]; + break; + case MFMailComposeResultFailed: + UnitySendMessage("ShareManager", "OnMailFailed", [ISN_DataConvertor NSStringToChar:@""]); + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"ISN: Mail sent failure: %@", [error localizedDescription]]; + break; + default: + UnitySendMessage("ShareManager", "OnMailFailed", [ISN_DataConvertor NSStringToChar:@""]); + break; + } + + UIViewController *vc = UnityGetGLViewController(); + [vc dismissViewControllerAnimated:YES completion:NULL]; +} +@end + + +@interface IOSInstaPlugin : NSObject + ++ (id) sharedInstance; + +- (void) share:(NSString*)status media: (NSString*) media; + + +@end + + +@interface MGInstagram : NSObject + +extern NSString* const kInstagramAppURLString; +extern NSString* const kInstagramOnlyPhotoFileName; + +//DEFAULT file name is kInstagramDefualtPhotoFileName +//DEFAULT file name is restricted to only the instagram app +//Make sure your photoFileName has a valid photo extension. ++ (void) setPhotoFileName:(NSString*)fileName; ++ (NSString*) photoFileName; + +//checks to see if user has instagram installed on device ++ (BOOL) isAppInstalled; + +//checks to see if image is large enough to be posted by instagram +//returns NO if image dimensions are under 612x612 +// +//Technically the instagram allows for photos to be published under the size of 612x612 +//BUT if you want nice quality pictures, I recommend checking the image size. ++ (BOOL) isImageCorrectSize:(UIImage*)image; + +//post image to instagram by passing in the target image and +//the view in which the user will be presented with the instagram model ++ (void) postImage:(UIImage*)image inView:(UIView*)view; +//Same as above method but with the option for a photo caption ++ (void) postImage:(UIImage*)image withCaption:(NSString*)caption inView:(UIView*)view; ++ (void) postImage:(UIImage*)image withCaption:(NSString*)caption inView:(UIView*)view delegate:(id)delegate; + +@end + + +@interface IOSTwitterPlugin : NSObject + ++ (id) sharedInstance; + +- (void) initTwitterPlugin; +- (void) authificateUser; +- (void) loadUserData; +- (void) post:(NSString*)status; +- (void) postWithMedia:(NSString*)status media: (NSString*) media; + + +@end + + + + +@implementation IOSInstaPlugin + +static IOSInstaPlugin *_sharedInstance; + + ++ (id)sharedInstance { + + if (_sharedInstance == nil) { + _sharedInstance = [[self alloc] init]; + } + + return _sharedInstance; +} +-(void) share:(NSString *)status media:(NSString *)media { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"Insta share"]; + + NSData *imageData = [[NSData alloc] initWithBase64Encoding:media]; + UIImage *image = [[UIImage alloc] initWithData:imageData]; + + + + if ([[[UIDevice currentDevice] systemVersion] floatValue] < 5.0) { + float i = [[[UIDevice currentDevice] systemVersion] floatValue]; + NSString *str = [NSString stringWithFormat:@"We're sorry, but Instagram is not supported with your iOS %.1f version.", i]; + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message" message:str delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; + + UnitySendMessage("IOSInstagramManager", "OnInstaPostFailed", [ISN_DataConvertor NSStringToChar:@"3"]); + UnitySendMessage("ShareManager", "OnInstaPostFailed", [ISN_DataConvertor NSStringToChar:@"3"]); + + + + + + } else { + + + + if ([MGInstagram isAppInstalled]) { + UIViewController *vc = UnityGetGLViewController(); + [MGInstagram postImage:image withCaption:status inView:vc.view delegate:self]; + } else { + UnitySendMessage("IOSInstagramManager", "OnInstaPostFailed", [ISN_DataConvertor NSStringToChar:@"1"]); + UnitySendMessage("ShareManager", "OnInstaPostFailed", [ISN_DataConvertor NSStringToChar:@"1"]); + + } + + } + +} + + +- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"documentInteractionControllerDidDismissOpenInMenu"]; + UnitySendMessage("IOSInstagramManager", "OnInstaPostFailed", [ISN_DataConvertor NSStringToChar:@"2"]); + UnitySendMessage("ShareManager", "OnInstaPostFailed", [ISN_DataConvertor NSStringToChar:@"2"]); + + +} + + +- (void) documentInteractionController: (UIDocumentInteractionController *) controller willBeginSendingToApplication: (NSString *) application { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"willBeginSendingToApplication"]; + UnitySendMessage("IOSInstagramManager", "OnInstaPostSuccess", [ISN_DataConvertor NSStringToChar:@""]); + UnitySendMessage("ShareManager", "OnInstaPostSuccess", [ISN_DataConvertor NSStringToChar:@""]); +} + + + +@end + + + +@interface MGInstagram () { + UIDocumentInteractionController *documentInteractionController; +} + +@property (nonatomic) NSString *photoFileName; + +@end + +@implementation MGInstagram + +NSString* const kInstagramAppURLString = @"instagram://app"; +NSString* const kInstagramOnlyPhotoFileName = @"tempinstgramphoto.igo"; + ++ (instancetype) sharedInstance +{ + static MGInstagram* sharedInstance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedInstance = [[MGInstagram alloc] init]; + }); + return sharedInstance; +} + +- (id) init { + if (self = [super init]) { + self.photoFileName = kInstagramOnlyPhotoFileName; + } + return self; +} + ++ (void) setPhotoFileName:(NSString*)fileName { + [MGInstagram sharedInstance].photoFileName = fileName; +} ++ (NSString*) photoFileName { + return [MGInstagram sharedInstance].photoFileName; +} + ++ (BOOL) isAppInstalled { + NSURL *appURL = [NSURL URLWithString:kInstagramAppURLString]; + return [[UIApplication sharedApplication] canOpenURL:appURL]; +} + +//Technically the instagram allows for photos to be published under the size of 612x612 +//BUT if you want nice quality pictures, I recommend checking the image size. ++ (BOOL) isImageCorrectSize:(UIImage*)image { + CGImageRef cgImage = [image CGImage]; + return (CGImageGetWidth(cgImage) >= 612 && CGImageGetHeight(cgImage) >= 612); +} + +- (NSString*) photoFilePath { + return [NSString stringWithFormat:@"%@/%@",[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"],self.photoFileName]; +} + ++ (void) postImage:(UIImage*)image inView:(UIView*)view { + [self postImage:image withCaption:nil inView:view]; +} ++ (void) postImage:(UIImage*)image withCaption:(NSString*)caption inView:(UIView*)view { + [self postImage:image withCaption:caption inView:view delegate:nil]; +} + ++ (void) postImage:(UIImage*)image withCaption:(NSString*)caption inView:(UIView*)view delegate:(id)delegate { + [[MGInstagram sharedInstance] postImage:image withCaption:caption inView:view delegate:delegate]; +} + +- (void) postImage:(UIImage*)image withCaption:(NSString*)caption inView:(UIView*)view delegate:(id)delegate +{ + if (!image) + [NSException raise:NSInternalInconsistencyException format:@"Image cannot be nil!"]; + + [UIImageJPEGRepresentation(image, 1.0) writeToFile:[self photoFilePath] atomically:YES]; + + + + NSURL *fileURL = [NSURL fileURLWithPath:[self photoFilePath]]; + documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL]; +#if UNITY_VERSION < 500 + [documentInteractionController retain]; +#endif + + + + documentInteractionController.UTI = @"com.instagram.exclusivegram"; + documentInteractionController.delegate = delegate; + if (caption) + documentInteractionController.annotation = [NSDictionary dictionaryWithObject:caption forKey:@"InstagramCaption"]; + + [documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:view animated:YES]; + +} + + +@end + + +@implementation IOSTwitterPlugin + + +static IOSTwitterPlugin * itp_sharedInstance; + + ++ (id)sharedInstance { + + if (itp_sharedInstance == nil) { + itp_sharedInstance = [[self alloc] init]; + } + + return itp_sharedInstance; +} + + +- (void) initTwitterPlugin { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"MSP: Twitter init"]; + + NSString * status = @"0"; + + if([self IsTwitterAvaliable]) { + if([self IsTwitterAuthed]) { + status = @"1"; + } + } + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"MSP: Status init %@", status]; + UnitySendMessage("IOSTwitterManager", "OnInited", [ISN_DataConvertor NSStringToChar:status]); + +} + +-(void) authificateUser { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"MSP: authificateUser"]; + ACAccountStore *account = [[ACAccountStore alloc] init]; + ACAccountType *twitterAccountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; + + [account requestAccessToAccountsWithType:twitterAccountType options:NULL completion:^(BOOL granted, NSError *error) { + if (granted) { + NSArray *twitterAccounts = [account accountsWithAccountType:twitterAccountType]; + if ([twitterAccounts count] > 0) { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"MSP: OnAuthSuccess"]; + UnitySendMessage("IOSTwitterManager", "OnAuthSuccess", [ISN_DataConvertor NSStringToChar:@""]); + + } else { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"MSP: OnAuthFailed no aacounts"]; + UnitySendMessage("IOSTwitterManager", "OnAuthFailed", [ISN_DataConvertor NSStringToChar:@"0"]); + } + + } else { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"MSP: OnAuthFailed no accses"]; + UnitySendMessage("IOSTwitterManager", "OnAuthFailed", [ISN_DataConvertor NSStringToChar:@"1"]); + } + }]; + + +} + + +-(void) loadUserData { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"MSP: loadUserData"]; + ACAccountStore *account = [[ACAccountStore alloc] init]; + ACAccountType *twitterAccountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; + + [account requestAccessToAccountsWithType:twitterAccountType options:NULL completion:^(BOOL granted, NSError *error) { + if (granted) { + NSArray *twitterAccounts = [account accountsWithAccountType:twitterAccountType]; + if ([twitterAccounts count] > 0) { + ACAccount *twitterAccount = [twitterAccounts objectAtIndex:0]; + + // Creating a request to get the info about a user on Twitter + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"MSP: Using twitter acc with name: %@", twitterAccount.username]; + + SLRequest *twitterInfoRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:[NSURL URLWithString:@"https://api.twitter.com/1.1/users/show.json"] parameters:[NSDictionary dictionaryWithObject:twitterAccount.username forKey:@"screen_name"]]; + [twitterInfoRequest setAccount:twitterAccount]; + + + + + // Making the request + [twitterInfoRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"MSP: twitterInfoRequest finished"]; + + + // Check if we reached the reate limit + if ([urlResponse statusCode] == 429) { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"MSP: Rate limit reached"]; + UnitySendMessage("IOSTwitterManager", "OnUserDataLoadFailed", [ISN_DataConvertor NSStringToChar:@""]); + return; + } + + // Check if there was an error + if (error) { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"MSP: Error: %@", error.localizedDescription]; + UnitySendMessage("IOSTwitterManager", "OnUserDataLoadFailed", [ISN_DataConvertor NSStringToChar:@""]); + return; + } + + // Check if there is some response data + if (responseData) { + NSString *resp = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"MSP: Request Succsesful: %@", resp]; + + UnitySendMessage("IOSTwitterManager", "OnUserDataLoaded", [ISN_DataConvertor NSStringToChar:resp]); + + + } else { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"MSP: No respoce data founded"]; + + UnitySendMessage("IOSTwitterManager", "OnUserDataLoadFailed", [ISN_DataConvertor NSStringToChar:@""]); + } + }); + }]; + + + } else { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"MSP: OnUserDataLoadFailed no accounts founded"]; + UnitySendMessage("IOSTwitterManager", "OnUserDataLoadFailed", [ISN_DataConvertor NSStringToChar:@""]); + } + + } else { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"MSP: OnUserDataLoadFailed no access"]; + UnitySendMessage("IOSTwitterManager", "OnUserDataLoadFailed", [ISN_DataConvertor NSStringToChar:@""]); + } + }]; + +} + + +-(void) postWithMedia:(NSString *)status media:(NSString *)media { + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"postWithMedia"]; + + NSData *imageData = [[NSData alloc] initWithBase64Encoding:media]; + UIImage *image = [[UIImage alloc] initWithData:imageData]; + + SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; + [tweetSheet setInitialText:status]; + [tweetSheet addImage:image]; + + UIViewController *vc = UnityGetGLViewController(); + + [vc presentViewController:tweetSheet animated:YES completion:nil]; + + tweetSheet.completionHandler = ^(SLComposeViewControllerResult result) { + switch(result) { + // This means the user cancelled without sending the Tweet + case SLComposeViewControllerResultCancelled: + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"Tweet message was cancelled"]; + UnitySendMessage("IOSTwitterManager", "OnPostFailed", [ISN_DataConvertor NSStringToChar:@""]); + [tweetSheet dismissViewControllerAnimated:YES completion:nil]; + break; + // This means the user hit 'Send' + case SLComposeViewControllerResultDone: + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"Done pressed successfully"]; + UnitySendMessage("IOSTwitterManager", "OnPostSuccess", [ISN_DataConvertor NSStringToChar:@""]); + [tweetSheet dismissViewControllerAnimated:YES completion:nil]; + break; + } + }; + +} + +- (void) post:(NSString *)status { + + SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; + [tweetSheet setInitialText:status]; + + + UIViewController *vc = UnityGetGLViewController(); + + [vc presentViewController:tweetSheet animated:YES completion:nil]; + + tweetSheet.completionHandler = ^(SLComposeViewControllerResult result) { + switch(result) { + // This means the user cancelled without sending the Tweet + case SLComposeViewControllerResultCancelled: + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"Tweet message was cancelled"]; + + UnitySendMessage("IOSTwitterManager", "OnPostFailed", [ISN_DataConvertor NSStringToChar:@""]); + [tweetSheet dismissViewControllerAnimated:YES completion:nil]; + break; + // This means the user hit 'Send' + case SLComposeViewControllerResultDone: + [[ISN_NativeUtility sharedInstance] ISN_NativeLog: @"Done pressed successfully"]; + UnitySendMessage("IOSTwitterManager", "OnPostSuccess", [ISN_DataConvertor NSStringToChar:@""]); + [tweetSheet dismissViewControllerAnimated:YES completion:nil]; + break; + } + }; +} + + +-(BOOL) IsTwitterAvaliable { + return [SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]; +} + +-(BOOL) IsTwitterAuthed { + ACAccountStore *account = [[ACAccountStore alloc] init]; + ACAccountType *twitterAccountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; + + NSArray *twitterAccounts = [account accountsWithAccountType:twitterAccountType]; + + if(twitterAccounts.count > 0) { + return true; + } else { + return false; + } +} + +@end + + +extern "C" { + + + //-------------------------------------- + // IOS Plugin Section + //-------------------------------------- + + + void _ISN_TwPost(char* text, char* url, char* encodedMedia) { + [[ISN_SocialGate sharedInstance] twitterPost:[ISN_DataConvertor charToNSString:text] url:[ISN_DataConvertor charToNSString:url] media:[ISN_DataConvertor charToNSString:encodedMedia]]; + } + + + void _ISN_TwPostGIF(char* text, char* url) { + [[ISN_SocialGate sharedInstance] twitterPostGif:[ISN_DataConvertor charToNSString:text] url:[ISN_DataConvertor charToNSString:url]]; + } + + + void _ISN_FbPost(char* text, char* url, char* encodedMedia) { + [[ISN_SocialGate sharedInstance] fbPost:[ISN_DataConvertor charToNSString:text] url:[ISN_DataConvertor charToNSString:url] media:[ISN_DataConvertor charToNSString:encodedMedia]]; + } + + + + void _ISN_MediaShare(char* text, char* encodedMedia) { + NSString *status = [ISN_DataConvertor charToNSString:text]; + NSString *media = [ISN_DataConvertor charToNSString:encodedMedia]; + + [[ISN_SocialGate sharedInstance] mediaShare:status media:media]; + + } + + + void _ISN_SendMail(char* subject, char* body, char* recipients, char* encodedMedia) { + NSString *mailSubject = [ISN_DataConvertor charToNSString:subject]; + NSString *mailBody = [ISN_DataConvertor charToNSString:body]; + NSString *mailRecipients = [ISN_DataConvertor charToNSString:recipients]; + NSString *media = [ISN_DataConvertor charToNSString:encodedMedia]; + + + [[ISN_SocialGate sharedInstance] sendEmail:mailSubject body:mailBody recipients:mailRecipients media:media]; + } + + void _ISN_WP_ShareText(char* text) { + NSString *msg = [ISN_DataConvertor charToNSString:text]; + [[ISN_SocialGate sharedInstance] whatsappShareText:msg]; + + } + + + void _ISN_WP_ShareMedia(char* encodedMedia) { + NSString *media = [ISN_DataConvertor charToNSString:encodedMedia]; + [[ISN_SocialGate sharedInstance] whatsappShareImage:media]; + } + + //-------------------------------------- + // Mobile Social Plugin Section + //-------------------------------------- + + void _MSP_TwPost(char* text, char* url, char* encodedMedia) { + _ISN_TwPost(text, url, encodedMedia); + } + + + void _MSP_FbPost(char* text, char* url, char* encodedMedia) { + _ISN_FbPost(text, url, encodedMedia); + } + + + + void _MSP_MediaShare(char* text, char* encodedMedia) { + _ISN_MediaShare(text, encodedMedia); + } + + + void _MSP_SendMail(char* subject, char* body, char* recipients, char* encodedMedia) { + _ISN_SendMail(subject, body, recipients, encodedMedia); + } + + //-------------------------------------- + // Mobile Social Plugin Instagram + //-------------------------------------- + + void _ISN_InstaShare(char* encodedMedia, char* text) { + + NSString *status = [ISN_DataConvertor charToNSString:text]; + NSString *media = [ISN_DataConvertor charToNSString:encodedMedia]; + + [[IOSInstaPlugin sharedInstance] share:status media:media]; + + } + + void _MSP_InstaShare(char* encodedMedia, char* text) { + _ISN_InstaShare(encodedMedia, text); + } + + + + //-------------------------------------- + // Mobile Social Plugin Twitter + //-------------------------------------- + + + void _twitterInit () { + [[IOSTwitterPlugin sharedInstance] initTwitterPlugin]; + } + + + void _twitterLoadUserData() { + [[IOSTwitterPlugin sharedInstance] loadUserData]; + } + + void _twitterAuthificateUser() { + [[IOSTwitterPlugin sharedInstance] authificateUser]; + } + + + void _twitterPost(char* text) { + NSString *status = [ISN_DataConvertor charToNSString:text]; + [[IOSTwitterPlugin sharedInstance] post:status]; + } + + void _twitterPostWithMedia(char* text, char* encodedMedia) { + + NSString *status = [ISN_DataConvertor charToNSString:text]; + NSString *media = [ISN_DataConvertor charToNSString:encodedMedia]; + + [[IOSTwitterPlugin sharedInstance] postWithMedia:status media:media]; + } + + + +} + + +#endif + diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_SocialGate.mm.meta b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_SocialGate.mm.meta new file mode 100644 index 00000000..dde1fc29 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/ISN_SocialGate.mm.meta @@ -0,0 +1,131 @@ +fileFormatVersion: 2 +guid: 3e73def94b97c4038a468691abc7cd6d +timeCreated: 1505293997 +licenseType: Pro +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + iPhone: iOS + second: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: Accounts;Social;MessageUI; + data: + first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/iOS/NativeUtils.h b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/NativeUtils.h new file mode 100644 index 00000000..59373508 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/NativeUtils.h @@ -0,0 +1,13 @@ + +@interface NativeUtils : NSObject + ++ (NSString*) charToNSString: (char*)value; + ++ (NativeUtils *)sharedInstance; + +- (void) registerNotification; +- (void) scheduleNotification: (int) triggerInSeconds message: (NSString*) message alarmId:(NSString *)alarmId; +- (void) cancelAllNotifications; + +@end + diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/iOS/NativeUtils.h.meta b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/NativeUtils.h.meta new file mode 100644 index 00000000..bf00e888 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/NativeUtils.h.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 27a2f26e8e9c34413992e9f33f3cc1c6 +timeCreated: 1496660244 +licenseType: Free +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + iPhone: iOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/iOS/NativeUtils.mm b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/NativeUtils.mm new file mode 100644 index 00000000..837f2a56 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/NativeUtils.mm @@ -0,0 +1,209 @@ +// +// NativeUtils.mm +// Unity-iPhone +// +// Created by Suto Atsushi on 2016/06/05. +// +// + +#import +#import + +#import +#import "UnityAppController.h" +#import + +#import "NativeUtils.h" +#include + +#import + + +@implementation NativeUtils + ++(NSString *) charToNSString:(char *)value +{ + if (value != NULL) + { + return [NSString stringWithUTF8String: value]; + } + else + { + return [NSString stringWithUTF8String: ""]; + } +} + +static NativeUtils *_sharedInstance = nil; + ++ (NativeUtils *) sharedInstance +{ + if (!_sharedInstance) + { + _sharedInstance = [[NativeUtils alloc] init]; + } + return _sharedInstance; +} + +-(void) registerNotification +{ + [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions: + (UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert ) completionHandler:^(BOOL granted, NSError *_Nullable error) { + if (granted) { + } + }]; + + + [[UIApplication sharedApplication] registerForRemoteNotifications]; + +} + +-(void) scheduleNotification: (int) triggerInSeconds message: (NSString*) message alarmId:(NSString *)alarmId +{ + // インスタンス生成 + UNMutableNotificationContent *unMutableNotice = [UNMutableNotificationContent new]; + + unMutableNotice.body = message; + unMutableNotice.sound = [UNNotificationSound defaultSound]; + + UNTimeIntervalNotificationTrigger *triger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:triggerInSeconds repeats:NO]; + UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:alarmId content:unMutableNotice trigger:triger]; + + [UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil]; +} + +- (void) cancelAllNotifications +{ + [[UNUserNotificationCenter currentNotificationCenter] removeAllPendingNotificationRequests]; + [[UNUserNotificationCenter currentNotificationCenter] removeAllDeliveredNotifications]; +} + +- (void) showAlert: (NSString*) title message: (NSString*) message +{ + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; + + // addActionした順に左から右にボタンが配置されます + [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + }]]; + [[[[UIApplication sharedApplication]keyWindow] rootViewController] presentViewController:alertController animated:YES completion:nil]; +} + + +@end + +extern "C"{ + int _getHeight() + { + CGRect cr = [[UIScreen mainScreen] nativeBounds]; + return cr.size.height; + } + int _getWidth() + { + CGRect cr = [[UIScreen mainScreen] nativeBounds]; + return cr.size.width; + } + int _getPointHeight() + { + CGRect cr = [[UIScreen mainScreen] bounds]; + return cr.size.height; + } + int _getPointWidth() + { + CGRect cr = [[UIScreen mainScreen] bounds]; + return cr.size.width; + } + + bool _enableReviewWindow() + { + return [SKStoreReviewController class]; + } + + void _reviewWindow(char* appid) + { + if([SKStoreReviewController class]){ + [SKStoreReviewController requestReview] ; + }else{ + NSString *str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@&action=write-review",[NativeUtils charToNSString:appid]]; + NSURL *URL = [NSURL URLWithString:str]; + [[UIApplication sharedApplication] openURL:URL]; + } + } + + long _systemClockTime() + { + struct timeval boottime; + int mib[2] = {CTL_KERN, KERN_BOOTTIME}; + size_t size = sizeof(boottime); + int rc = sysctl(mib, 2, &boottime, &size, NULL, 0); + if (rc != 0) { + return 0; + } + return (long)(time(NULL) - boottime.tv_sec); + } + + bool _canOpenTwitter() + { + if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitter://"]]) + { + return true; + } + return false; + } + + bool _canOpenFacebook() + { + if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]]) + { + return true; + } + return false; + } + + void _registerNotification() + { + [[NativeUtils sharedInstance] registerNotification]; + } + void _scheduleNotification (int triggerInSeconds, char* message, char* alarmId) + { + [[NativeUtils sharedInstance] scheduleNotification:triggerInSeconds message:[NativeUtils charToNSString:message] alarmId:[NativeUtils charToNSString:alarmId]]; + } + void _cancelAllNotifications() + { + [[NativeUtils sharedInstance] cancelAllNotifications]; + } + + void _PlayVibration(int id) + { + AudioServicesPlaySystemSound(id); + } + void _PlayVibrationOnce(){ + UIImpactFeedbackGenerator *generator = [[UIImpactFeedbackGenerator alloc] initWithStyle:(UIImpactFeedbackStyleMedium)]; + [generator impactOccurred]; + } + void _PlayVibrationOnceStrong(){ + UIImpactFeedbackGenerator *generator = [[UIImpactFeedbackGenerator alloc] initWithStyle:(UIImpactFeedbackStyleHeavy)]; + [generator impactOccurred]; + } + void _PlayVibrationOnceWeak(){ + UIImpactFeedbackGenerator *generator = [[UIImpactFeedbackGenerator alloc] initWithStyle:(UIImpactFeedbackStyleLight)]; + [generator impactOccurred]; + } + void _PlayVibrationDoubleStrong(){ + UINotificationFeedbackGenerator *generator = [[UINotificationFeedbackGenerator alloc] init]; + [generator notificationOccurred: UINotificationFeedbackTypeSuccess]; + } + void _PlayVibrationDoubleWeak(){ + UINotificationFeedbackGenerator *generator = [[UINotificationFeedbackGenerator alloc] init]; + [generator notificationOccurred: UINotificationFeedbackTypeWarning]; + } + void _PlayVibrationTriple(){ + UINotificationFeedbackGenerator *generator = [[UINotificationFeedbackGenerator alloc] init]; + [generator notificationOccurred: UINotificationFeedbackTypeError]; + } + + void _showAlert(char* title, char* message) + { + [[NativeUtils sharedInstance] showAlert:[NativeUtils charToNSString:title] message:[NativeUtils charToNSString:message]]; + } +} + + diff --git a/popcorn/Assets/USAYAUnityLib/Plugins/iOS/NativeUtils.mm.meta b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/NativeUtils.mm.meta new file mode 100644 index 00000000..cc972aa1 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Plugins/iOS/NativeUtils.mm.meta @@ -0,0 +1,117 @@ +fileFormatVersion: 2 +guid: 4383d909a0f3e411c9de1bb3b60ad6e4 +timeCreated: 1496660244 +licenseType: Free +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + iPhone: iOS + second: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: Social;StoreKit; + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Prefabs.meta b/popcorn/Assets/USAYAUnityLib/Prefabs.meta new file mode 100644 index 00000000..913ca13e --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Prefabs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4e0f755fc6a614e65966b115582417d1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Prefabs/ApplicationExitConfirmDialog.prefab b/popcorn/Assets/USAYAUnityLib/Prefabs/ApplicationExitConfirmDialog.prefab new file mode 100644 index 00000000..6bef3a50 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Prefabs/ApplicationExitConfirmDialog.prefab @@ -0,0 +1,947 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &3319645817038381674 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3319645817038381675} + - component: {fileID: 3319645817038381672} + - component: {fileID: 3319645817038381673} + m_Layer: 8 + m_Name: Window + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &3319645817038381675 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3319645817038381674} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 7839734813038113992} + - {fileID: 7839734813212713713} + - {fileID: 7839734813352544528} + - {fileID: 7839734813724911295} + m_Father: {fileID: 7839734813684466944} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 670.7, y: 801} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &3319645817038381672 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3319645817038381674} + m_CullTransparentMesh: 0 +--- !u!114 &3319645817038381673 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3319645817038381674} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 2 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!1 &7839734813038113993 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7839734813038113992} + - component: {fileID: 7839734813038113999} + - component: {fileID: 7839734813038113998} + m_Layer: 8 + m_Name: Title + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7839734813038113992 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813038113993} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 3319645817038381675} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 270} + m_SizeDelta: {x: 470, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &7839734813038113999 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813038113993} + m_CullTransparentMesh: 0 +--- !u!114 &7839734813038113998 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813038113993} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c629da42a3848417ea0d4f194de4d7bc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 50 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 50 + m_MaxSize: 68 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Title +--- !u!1 &7839734813104273340 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7839734813104273331} + - component: {fileID: 7839734813104273330} + m_Layer: 8 + m_Name: TextLocalizer + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7839734813104273331 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813104273340} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 7839734813297013598} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &7839734813104273330 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813104273340} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 35221347b2fcf4632a7c2051c2b83ebc, type: 3} + m_Name: + m_EditorClassIdentifier: + localizeDataArray: + - textLocalizeDataArray: + - localizeTextId: 10001 + textArray: + - {fileID: 7839734813038113998} + - textLocalizeDataArray: + - localizeTextId: 10002 + textArray: + - {fileID: 7839734813212713719} + - textLocalizeDataArray: + - localizeTextId: 10003 + textArray: + - {fileID: 7839734813639560264} + - textLocalizeDataArray: + - localizeTextId: 10004 + textArray: + - {fileID: 7839734813440976406} +--- !u!1 &7839734813155995861 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7839734813155995883} + - component: {fileID: 7839734813155995860} + m_Layer: 8 + m_Name: Managers + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7839734813155995883 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813155995861} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 7839734813297013598} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &7839734813155995860 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813155995861} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a92bc7e900b03479f90dc7f8c85fc351, type: 3} + m_Name: + m_EditorClassIdentifier: + dialogAnimator: {fileID: 0} +--- !u!1 &7839734813212713714 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7839734813212713713} + - component: {fileID: 7839734813212713712} + - component: {fileID: 7839734813212713719} + m_Layer: 8 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7839734813212713713 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813212713714} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 3319645817038381675} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 1, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: -200, y: 400} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &7839734813212713712 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813212713714} + m_CullTransparentMesh: 0 +--- !u!114 &7839734813212713719 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813212713714} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c629da42a3848417ea0d4f194de4d7bc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 50 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 50 + m_MaxSize: 68 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +--- !u!1 &7839734813297013599 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7839734813297013598} + m_Layer: 8 + m_Name: ApplicationExitConfirmDialog + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7839734813297013598 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813297013599} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 7839734813684466944} + - {fileID: 7839734813155995883} + - {fileID: 7839734813104273331} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &7839734813352544529 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7839734813352544528} + - component: {fileID: 7839734813352544533} + - component: {fileID: 7839734813352544534} + - component: {fileID: 7839734813352544535} + m_Layer: 8 + m_Name: YesButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7839734813352544528 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813352544529} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 7839734813639560266} + m_Father: {fileID: 3319645817038381675} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0} + m_AnchorMax: {x: 0.5, y: 0} + m_AnchoredPosition: {x: 150, y: 124.99997} + m_SizeDelta: {x: 218.77, y: 120} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &7839734813352544533 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813352544529} + m_CullTransparentMesh: 0 +--- !u!114 &7839734813352544534 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813352544529} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!114 &7839734813352544535 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813352544529} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 7839734813352544534} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 7839734813155995860} + m_MethodName: OnExit + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!1 &7839734813440976407 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7839734813440976404} + - component: {fileID: 7839734813440976405} + - component: {fileID: 7839734813440976406} + m_Layer: 8 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7839734813440976404 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813440976407} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 7839734813724911295} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: -10, y: -10} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &7839734813440976405 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813440976407} + m_CullTransparentMesh: 0 +--- !u!114 &7839734813440976406 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813440976407} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c629da42a3848417ea0d4f194de4d7bc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 50 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 50 + m_MaxSize: 50 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: No +--- !u!1 &7839734813639560267 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7839734813639560266} + - component: {fileID: 7839734813639560265} + - component: {fileID: 7839734813639560264} + m_Layer: 8 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7839734813639560266 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813639560267} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 7839734813352544528} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: -10, y: -10} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &7839734813639560265 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813639560267} + m_CullTransparentMesh: 0 +--- !u!114 &7839734813639560264 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813639560267} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c629da42a3848417ea0d4f194de4d7bc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 50 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 50 + m_MaxSize: 50 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Yes +--- !u!1 &7839734813684466956 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7839734813684466944} + - component: {fileID: 7839734813684466945} + - component: {fileID: 7839734813684466946} + - component: {fileID: 7839734813684466947} + - component: {fileID: 7839734813684466951} + m_Layer: 8 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7839734813684466944 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813684466956} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 7839734814505967633} + - {fileID: 3319645817038381675} + m_Father: {fileID: 7839734813297013598} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!223 &7839734813684466945 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813684466956} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 0 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 25 + m_SortingLayerID: 0 + m_SortingOrder: 100 + m_TargetDisplay: 0 +--- !u!114 &7839734813684466946 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813684466956} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 1 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 1080, y: 1920} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 1 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!114 &7839734813684466947 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813684466956} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &7839734813684466951 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813684466956} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 92aa16650eba545a0929410f151d36a9, type: 3} + m_Name: + m_EditorClassIdentifier: + canvasScaler: {fileID: 7839734813684466946} +--- !u!1 &7839734813724911288 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7839734813724911295} + - component: {fileID: 7839734813724911292} + - component: {fileID: 7839734813724911293} + - component: {fileID: 7839734813724911294} + m_Layer: 8 + m_Name: NoButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7839734813724911295 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813724911288} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 7839734813440976404} + m_Father: {fileID: 3319645817038381675} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0} + m_AnchorMax: {x: 0.5, y: 0} + m_AnchoredPosition: {x: -150, y: 124.99997} + m_SizeDelta: {x: 218.77, y: 120} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &7839734813724911292 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813724911288} + m_CullTransparentMesh: 0 +--- !u!114 &7839734813724911293 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813724911288} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!114 &7839734813724911294 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734813724911288} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 7839734813724911293} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 7839734813155995860} + m_MethodName: OnHide + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!1 &7839734814505967634 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7839734814505967633} + - component: {fileID: 7839734814505967638} + - component: {fileID: 7839734814505967639} + m_Layer: 8 + m_Name: GraphicCast + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7839734814505967633 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734814505967634} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 7839734813684466944} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &7839734814505967638 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734814505967634} + m_CullTransparentMesh: 0 +--- !u!114 &7839734814505967639 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7839734814505967634} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ee012d4774ae943b49c2443232200135, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 diff --git a/popcorn/Assets/USAYAUnityLib/Prefabs/ApplicationExitConfirmDialog.prefab.meta b/popcorn/Assets/USAYAUnityLib/Prefabs/ApplicationExitConfirmDialog.prefab.meta new file mode 100644 index 00000000..1acd83ea --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Prefabs/ApplicationExitConfirmDialog.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 05efaebdd6d4f473db78a4f4da8885ac +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer.meta b/popcorn/Assets/USAYAUnityLib/ReferenceViewer.meta new file mode 100644 index 00000000..e98eb2a2 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b67778d3accd84e89902ad726ad6cb8b +folderAsset: yes +timeCreated: 1468566071 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor.meta b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor.meta new file mode 100644 index 00000000..3fcbcfef --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 679cd5a0f1029439cb2120f17004c2c7 +folderAsset: yes +timeCreated: 1468566072 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData.meta b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData.meta new file mode 100644 index 00000000..2e864f50 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 391a76639dcf94348bc1427cf9bbbc7e +folderAsset: yes +timeCreated: 1505800351 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/AnimationControllerAssetData.cs b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/AnimationControllerAssetData.cs new file mode 100755 index 00000000..0b947f00 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/AnimationControllerAssetData.cs @@ -0,0 +1,54 @@ +using System.Linq; +using UnityEditor; +using UnityEditor.Animations; +using UnityEngine; + +namespace ReferenceViewer +{ + [System.Serializable] + public class AnimationControllerAssetData : AssetData + { + public new const string extension = ".controller"; + private readonly AnimatorController animatorController; + + public AnimationControllerAssetData(string assetPath) : base(assetPath) + { + animatorController = + AssetDatabase.LoadAssetAtPath(assetPath, typeof(AnimatorController)) as AnimatorController; + } + + public override void AddAssetData(Object obj) + { + var guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(obj)); + reference.Add(guid); + foreach (var animationClip in animatorController.animationClips) + { + AddReference(animationClip); + } + + foreach (var animatorControllerLayer in animatorController.layers) + { + AddReferenceForStateMachine(animatorControllerLayer.stateMachine); + } + } + + private void AddReferenceForStateMachine(AnimatorStateMachine stateMachine) + { + foreach (var stateMachineBehaviour in stateMachine.states + .SelectMany(childAnimatorState => childAnimatorState.state.behaviours)) + { + AddReference(stateMachineBehaviour); + } + + foreach (var stateMachineBehaviour in stateMachine.behaviours) + { + AddReference(stateMachineBehaviour); + } + + foreach (var childAnimatorStateMachine in stateMachine.stateMachines) + { + AddReferenceForStateMachine(childAnimatorStateMachine.stateMachine); + } + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/AnimationControllerAssetData.cs.meta b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/AnimationControllerAssetData.cs.meta new file mode 100755 index 00000000..acb517dc --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/AnimationControllerAssetData.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2a3a7737579aa41b7ac418c817934ac2 +timeCreated: 1489317777 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/AssetData.cs b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/AssetData.cs new file mode 100755 index 00000000..ab968a08 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/AssetData.cs @@ -0,0 +1,129 @@ +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; +using System.Linq; + +namespace ReferenceViewer +{ + [System.Serializable] + public class AssetData + { + public const string extension = ""; + + public string assetPath; + public string guid; + + public List reference = new List(); + public List subAssets = new List(); + public List sceneData = new List(); + + public AssetData(string assetPath) + { + this.assetPath = assetPath; + guid = AssetDatabase.AssetPathToGUID(assetPath); + } + + public virtual void AddAssetData(Object obj) + { + AddReference(obj); + } + + protected void AddReference(Object obj) + { + var guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(obj)); + if (string.IsNullOrEmpty(guid) == false) + { + if (reference.Contains(guid) == false && this.guid != guid) + { + reference.Add(guid); + } + } + + foreach (var o in EditorUtility.CollectDependencies(new[] {obj})) + { + if (o == null) + { + continue; + } + guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(o)); + if (string.IsNullOrEmpty(guid) == false) + { + if (reference.Contains(guid) == false && this.guid != guid) + { + reference.Add(guid); + } + } + } + } + + protected void AddSubAssetReference(Object obj) + { + var guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(obj)); + if (string.IsNullOrEmpty(guid) || AssetDatabase.IsSubAsset(obj) == false) + { + return; + } + + + var sub = new SubAssetData + { + name = obj.name, + guid = guid, + typeName = obj.GetType().FullName + }; + if (subAssets.Count(s => s.guid == sub.guid && s.name == sub.name && + s.typeName == sub.typeName) == 0) + { + subAssets.Add(sub); + } + } + + protected void AddSceneReference(GameObject go, Object obj, string sceneGUID) + { + var guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(obj)); + + if (string.IsNullOrEmpty(guid)) + { + guid = sceneGUID; + } + + var transform = go.transform; + + sceneData.Add(new SceneData + { + guid = guid, + name = GetPathName(transform), + typeName = obj.GetType().FullName + }); + } + + protected void CollectDependencies(GameObject go, SerializedObject so, string scenGuid, bool skipLoop = false) + { + + var property = so.GetIterator(); + while (property.Next(true)) + { + if ((property.propertyType == SerializedPropertyType.ObjectReference) && + (property.objectReferenceValue != null)) + { + if (skipLoop == false) + { + CollectDependencies(go, new SerializedObject(property.objectReferenceValue), scenGuid, true); + } + AddReference(property.objectReferenceValue); + AddSceneReference(go, property.objectReferenceValue, scenGuid); + } + } + } + private static string GetPathName(Transform transform, string name = "") + { + while (true) + { + name = transform.name + name; + if (!transform.parent) return name; + transform = transform.parent; + name = "/" + name; + } + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/AssetData.cs.meta b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/AssetData.cs.meta new file mode 100755 index 00000000..bc2c2502 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/AssetData.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e127a7b91e1d048ec9c7204a62ebb1e9 +timeCreated: 1489317777 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/PrefabAssetData.cs b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/PrefabAssetData.cs new file mode 100755 index 00000000..44a36c8d --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/PrefabAssetData.cs @@ -0,0 +1,20 @@ +using UnityEngine; + +namespace ReferenceViewer +{ + [System.Serializable] + public class PrefabAssetData : AssetData + { + public new const string extension = ".prefab"; + + public PrefabAssetData(string assetPath) : base(assetPath) + { + } + + public override void AddAssetData(Object obj) + { + AddReference(obj); +// CollectDependencies(obj as GameObject, new SerializedObject(obj), ""); + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/PrefabAssetData.cs.meta b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/PrefabAssetData.cs.meta new file mode 100755 index 00000000..54295007 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/PrefabAssetData.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f18dd5e4b7101414495e399c436a41aa +timeCreated: 1489317777 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/SceneAssetData.cs b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/SceneAssetData.cs new file mode 100755 index 00000000..8353b206 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/SceneAssetData.cs @@ -0,0 +1,28 @@ +using UnityEditor; +using UnityEditor.SceneManagement; +using UnityEngine; + +namespace ReferenceViewer +{ + [System.Serializable] + public class SceneAssetData : AssetData + { + public new const string extension = ".unity"; + + public SceneAssetData(string assetPath) : base(assetPath) + { + } + + public override void AddAssetData(Object obj) + { + var scene = EditorSceneManager.OpenScene(assetPath, OpenSceneMode.Single); + var scenGuid = AssetDatabase.AssetPathToGUID(assetPath); + + foreach (GameObject go in Object.FindObjectsOfType(typeof(GameObject))) + { + CollectDependencies(go, new SerializedObject(go), scenGuid); + } + EditorSceneManager.CloseScene(scene, true); + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/SceneAssetData.cs.meta b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/SceneAssetData.cs.meta new file mode 100755 index 00000000..6fbc6ba8 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/AssetData/SceneAssetData.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b7675bad2ac904c0db7912fee09c2f42 +timeCreated: 1489317777 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/CompareSelector.cs b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/CompareSelector.cs new file mode 100755 index 00000000..09c51b4f --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/CompareSelector.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace ReferenceViewer +{ + public class CompareSelector : IEqualityComparer + { + private Func selector; + + public CompareSelector(Func selector) + { + this.selector = selector; + } + + public bool Equals(T x, T y) + { + return selector(x).Equals(selector(y)); + } + + public int GetHashCode(T obj) + { + return selector(obj).GetHashCode(); + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/CompareSelector.cs.meta b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/CompareSelector.cs.meta new file mode 100755 index 00000000..acc61af8 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/CompareSelector.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8991d2947d1ae4b408f4e2c61a5bac59 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Creator.cs b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Creator.cs new file mode 100755 index 00000000..b16e7a54 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Creator.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization.Formatters.Binary; +using UnityEditor; +using UnityEditor.SceneManagement; +using System.IO; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace ReferenceViewer +{ + public class Creator + { + public static void Build(Action callback = null) + { + if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) return; + + var currentScenes = EditorSceneManager.GetSceneManagerSetup().Select(sm => sm.path).ToArray(); + + + Generate.Build(AssetDatabase.GetAllAssetPaths(), assetData => + { + var data = ScriptableObject.CreateInstance(); + + data.assetData.AddRange(assetData); + Export(data); + + if (!currentScenes.Any()) + EditorSceneManager.NewScene(NewSceneSetup.EmptyScene); + else + { + EditorSceneManager.OpenScene(currentScenes[0]); + + foreach (var currentScene in currentScenes.Skip(0)) + { + EditorSceneManager.OpenScene(currentScene, OpenSceneMode.Additive); + } + } + + EditorUtility.UnloadUnusedAssetsImmediate(); + if (callback != null) + callback(); + }); + } + + private static void Export(Data data) + { + data.assetData = data.assetData.OrderBy(d => Path.GetExtension(d.assetPath)).ToList(); + const string directory = "build/ReferenceViewer"; + + Directory.CreateDirectory(directory); + + foreach (var assetData in data.assetData.Where(assetData => assetData.sceneData.Count != 0)) + { + assetData.sceneData = + assetData.sceneData.Distinct(new CompareSelector(s => s.name + s.guid)).ToList(); + } + File.Delete(directory + "/data.dat"); + UnityEditorInternal.InternalEditorUtility.SaveToSerializedFileAndForget(new Object[] {data}, + directory + "/data.dat", true); + AssetDatabase.CreateAsset(data, "Assets/Test.asset"); + } + + static byte[] ObjectToByteArray(object obj) + { + if (obj == null) + return null; + var bf = new BinaryFormatter(); + var ms = new MemoryStream(); + bf.Serialize(ms, obj); + return ms.ToArray(); + } + } + + public static class Extensions + { + public static HashSet ToHashSet(this IEnumerable source) + { + return new HashSet(source); + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Creator.cs.meta b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Creator.cs.meta new file mode 100755 index 00000000..bc2c8569 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Creator.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f95f3cdfe53c64f89a6e66649584369d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Data.cs b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Data.cs new file mode 100755 index 00000000..3df9638b --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Data.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace ReferenceViewer +{ + [System.Serializable] + public class Data : ScriptableObject + { + public List assetData = new List(); + } + + [System.Serializable] + public class SceneData + { + public string guid; + public string typeName; + public string name; + } + + [System.Serializable] + public class SubAssetData + { + public string guid = ""; + public string name = ""; + public string typeName = ""; + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Data.cs.meta b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Data.cs.meta new file mode 100755 index 00000000..adad8436 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Data.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 23ab6792f3dae4170a95384b2819a6e6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Generate.cs b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Generate.cs new file mode 100755 index 00000000..c360733b --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Generate.cs @@ -0,0 +1,64 @@ +using System; +using System.IO; +using System.Linq; +using UnityEditor; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace ReferenceViewer +{ + public class Generate + { + private static float progress; + + + public static void Build(string[] assetPaths, Action callback = null) + { + EditorUtility.ClearProgressBar(); + var result = new AssetData[0]; + EditorApplication.LockReloadAssemblies(); + assetPaths = assetPaths.OrderBy(path => Path.GetExtension(path)).ToArray(); + for (var i = 0; i < assetPaths.Length; i++) + { + var assetPath = assetPaths[i]; + + if (assetPath.StartsWith("Assets/") == false) + continue; + progress = (float) i / assetPaths.Length; + + var obj = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object)); + DisplayProgressBar(assetPath, progress); + + AssetData assetData = null; + + switch (Path.GetExtension(assetPath)) + { + case PrefabAssetData.extension: + assetData = new PrefabAssetData(assetPath); + break; + case SceneAssetData.extension: + assetData = new SceneAssetData(assetPath); + break; + case AnimationControllerAssetData.extension: + assetData = new AnimationControllerAssetData(assetPath); + break; + default: + assetData = new AssetData(assetPath); + break; + } + + assetData.AddAssetData(obj); + ArrayUtility.Add(ref result, assetData); + } + callback(result); + EditorApplication.UnlockReloadAssemblies(); + EditorUtility.ClearProgressBar(); + } + + protected static void DisplayProgressBar(string path, float progress) + { + EditorUtility.DisplayProgressBar(Path.GetFileName(path), + Mathf.FloorToInt(progress * 100) + "% - " + Path.GetFileName(path), progress); + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Generate.cs.meta b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Generate.cs.meta new file mode 100755 index 00000000..22614243 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/Generate.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e07e51672a9d642d78b9aeb444e7f622 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/ReferenceViewer.cs b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/ReferenceViewer.cs new file mode 100755 index 00000000..1264df5e --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/ReferenceViewer.cs @@ -0,0 +1,370 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Runtime.Serialization.Formatters.Binary; +using UnityEngine; +using UnityEditor; +using System.IO; +using System.Linq; +using Object = UnityEngine.Object; + +namespace ReferenceViewer +{ + public class ReferenceViewer : EditorWindow + { + private List items = new List(); + private Vector2 pos = Vector2.zero; + private int selectedFilter; + + static Dictionary> sceneReference = new Dictionary>(); + + static Dictionary foldouts = new Dictionary(); + + [MenuItem("Window/ReferenceViewer")] + private static void Open() + { + GetWindow(); + } + + [MenuItem("Assets/Find References In Project", true)] + private static bool FindValidate() + { + return Selection.objects.Length != 0; + } + + [MenuItem("Assets/Find References In Project")] + private static void Find() + { + sceneReference.Clear(); + var path = "build/ReferenceViewer/data.dat"; + + var selectedObjects = Selection.objects; + + Action find = () => + { + var data = UnityEditorInternal.InternalEditorUtility.LoadSerializedFileAndForget(path)[0] as Data; + Find(data, selectedObjects); + }; + + if (File.Exists(path)) + { + find(); + } + else + { + if (EditorUtility.DisplayDialog("必要なデータがありません", "データを作成します。\nデータ作成に時間がかかりますがよろしいですか?", "はい", "いいえ")) + { + Creator.Build(find); + } + } + } + + private static void Find(Data data, params Object[] selectedObjects) + { + var items = new List(); + var guids = new List(); + foreach (var selectedObject in selectedObjects) + { + var guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(selectedObject)); + if (AssetDatabase.IsSubAsset(selectedObject)) + { + var item = new Item + { + searchedGUIContent = GetGUIContent(selectedObject), + type = selectedObject.GetType() + }; + + foreach (var assetData in data.assetData) + { + foreach (var subAssetData in assetData.subAssets) + { + var type = Assembly.Load("UnityEngine.dll").GetType(subAssetData.typeName); + + if (subAssetData.guid == guid && type == selectedObject.GetType()) + { + item.referencedGUIContents.Add(GetGUIContent(assetData.guid)); + } + } + } + item.referencedGUIContents = item.referencedGUIContents.Distinct( + new CompareSelector(i => i.tooltip)) + .ToList(); + + items.Add(item); + } + else + { + guids.Add(guid); + + foreach (var assetData in data.assetData.Where(assetData => guid == assetData.guid)) + { + foreach (var subAssetData in assetData.subAssets) + { + var type = Assembly.Load("UnityEngine.dll").GetType(subAssetData.typeName); + var tex = AssetPreview.GetMiniTypeThumbnail(type); + + var item = + items.FirstOrDefault( + _item => _item.searchedGUIContent.tooltip == GetGUIContent(selectedObject).tooltip); + if (item == null) + { + item = new Item {searchedGUIContent = GetGUIContent(selectedObject)}; + items.Add(item); + } + item.type = type; + item.referenceGUIContents.Add(new GUIContent(subAssetData.name, tex, + AssetDatabase.GUIDToAssetPath(subAssetData.guid))); + item.referenceGUIContents = item.referenceGUIContents.Distinct( + new CompareSelector(i => i.text)) + .ToList(); + } + } + } + } + + items.AddRange(guids + .Select(guid => new + { + type = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), typeof(Object)).GetType(), + searched = GetGUIContent(guid), + referenced = + data.assetData.Where(assetData => assetData.reference.Contains(guid)) + .Select(assetData => GetGUIContent(assetData.guid)) + .Where(c => c != null) + .Where(c => c.image && guid != AssetDatabase.AssetPathToGUID(c.tooltip)) + .OrderBy(c => c.image.name) + .ToList(), + reference = + data.assetData.Find(item => item.guid == guid) + .reference.Where(g => g != guid) + .Select(g => GetGUIContent(g)) + .Where(c => c != null) + .Where(c => c.image) + .OrderBy(c => c.image.name) + .ToList() + }) + .Where(item => (item.referenced.Count != 0 || item.reference.Count != 0) && item.searched.image) + .OrderBy(item => item.searched.image.name) + .Select(item => new Item + { + type = item.type, + searchedGUIContent = item.searched, + referencedGUIContents = item.referenced, + referenceGUIContents = item.reference + }) + .ToList()); + items.Distinct(new CompareSelector(i => i.searchedGUIContent.tooltip)); + + foreach (var item in items) + { + foreach (var i in item.referencedGUIContents) + { + if (Path.GetExtension(i.tooltip) == ".unity") + { + var d = data.assetData.Find(asset => asset.assetPath == i.tooltip).sceneData; + var key = item.searchedGUIContent.tooltip + " - " + i.tooltip; + if (sceneReference.ContainsKey(key)) + { + sceneReference[key] + .AddRange(d.Select(s => new GUIContent(s.name, AssetDatabase.GUIDToAssetPath(s.guid))) + .ToList()); + } + else + { + sceneReference.Add(key, + d.Select(s => new GUIContent(s.name, AssetDatabase.GUIDToAssetPath(s.guid))).ToList()); + } + } + } + } + var window = GetWindow(); + window.selectedFilter = 0; + window.Results(items); + } + + + private void Results(List items) + { + this.items = items; + } + + private void OnGUI() + { + EditorGUILayout.BeginHorizontal(); + + if (GUILayout.Button("Update", EditorStyles.toolbarButton)) + { + Creator.Build(); + EditorGUIUtility.ExitGUI(); + } + + EditorGUI.BeginChangeCheck(); + var types = items.Select(item => item.type).ToArray(); + + var display = types.Select(t => t.Name).ToArray(); + for (var i = 0; i < display.Length; i++) + { + switch (display[i]) + { + case "Object": + display[i] = "Scene"; + break; + case "GameObject": + display[i] = "Prefab"; + break; + } + } + ArrayUtility.Insert(ref display, 0, "All"); + var selected = EditorGUILayout.Popup(selectedFilter, display, EditorStyles.toolbarPopup); + if (EditorGUI.EndChangeCheck()) + { + selectedFilter = selected; + } + EditorGUILayout.EndHorizontal(); + + if (items.Count == 0) return; + + pos = EditorGUILayout.BeginScrollView(pos); + + var groupBy = items.GroupBy(item => item.searchedGUIContent.tooltip); + foreach (var group in groupBy) + { + var enumerator = @group.GetEnumerator(); + var item = new Item(); + while (enumerator.MoveNext()) + { + item.type = enumerator.Current.type; + item.searchedGUIContent = enumerator.Current.searchedGUIContent; + item.referenceGUIContents.AddRange(enumerator.Current.referenceGUIContents); + item.referencedGUIContents.AddRange(enumerator.Current.referencedGUIContents); + } + + if (selectedFilter != 0 && item.type != types[selectedFilter - 1]) + { + continue; + } + + EditorGUILayout.BeginHorizontal("box", GUILayout.Width(position.width * 0.96f)); + DrawGUIContents(item.searchedGUIContent, item.referenceGUIContents); + var iconSize = EditorGUIUtility.GetIconSize(); + EditorGUIUtility.SetIconSize(Vector2.one * 32); + GUILayout.Label(item.searchedGUIContent, GUILayout.Width(position.width * 0.3f), + GUILayout.ExpandWidth(false)); + EditorGUIUtility.SetIconSize(iconSize); + PingObjectIfOnMouseDown(item.searchedGUIContent.tooltip); + + DrawGUIContents(item.searchedGUIContent, item.referencedGUIContents); + EditorGUILayout.EndHorizontal(); + EditorGUILayout.Space(); + } + EditorGUILayout.EndScrollView(); + } + + private void DrawGUIContents(GUIContent searched, List contents) + { + if (contents.Count != 0) + { + EditorGUILayout.BeginVertical(GUILayout.Width(position.width * 0.3f)); + + foreach (var content in contents) + { + if (IsScene(content)) + { + var key = searched.tooltip + " - " + content.tooltip; + + if (!foldouts.ContainsKey(key)) + { + foldouts.Add(key, false); + } + + foldouts[key] = EditorGUILayout.Foldout(foldouts[key], content); + + if (foldouts[key]) + { + if (sceneReference.ContainsKey(key)) + { + EditorGUI.indentLevel++; + foreach (var sceneData in sceneReference[key]) + { + if (searched.tooltip == sceneData.tooltip) + EditorGUILayout.LabelField(sceneData, EditorStyles.miniLabel, + GUILayout.Width(position.width * 0.3f), GUILayout.ExpandWidth(true)); + } + EditorGUI.indentLevel--; + } + } + } + else + { + EditorGUILayout.LabelField(content, GUILayout.Width(position.width * 0.3f), + GUILayout.ExpandWidth(true)); + } + + PingObjectIfOnMouseDown(content.tooltip); + } + EditorGUILayout.EndVertical(); + } + else + { + GUILayout.Space(position.width * 0.3f + 16); + } + } + + + private static bool IsScene(GUIContent content) + { + return Path.GetExtension(content.tooltip) == ".unity"; + } + + private static void PingObjectIfOnMouseDown(string path) + { + if (Event.current.type != EventType.MouseDown) return; + if (!GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) return; + + var obj = AssetDatabase.LoadAssetAtPath(path, typeof(Object)); + Selection.activeObject = obj; + EditorGUIUtility.PingObject(obj); + } + + private static GUIContent GetGUIContent(string guidOrAssetPath) + { + var assetPath = File.Exists(guidOrAssetPath) + ? guidOrAssetPath + : AssetDatabase.GUIDToAssetPath(guidOrAssetPath); + + var asset = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object)); + return asset ? GetGUIContent(asset) : null; + } + + private static GUIContent GetGUIContent(Object obj) + { + if (!obj) return new GUIContent(); + return new GUIContent(EditorGUIUtility.ObjectContent(obj, obj.GetType())) + { + tooltip = AssetDatabase.GetAssetPath(obj) + }; + } + + private static T ByteArrayToObject(byte[] arrBytes) + { + T obj; + using (var memStream = new MemoryStream()) + { + var binForm = new BinaryFormatter(); + memStream.Write(arrBytes, 0, arrBytes.Length); + memStream.Seek(0, SeekOrigin.Begin); + obj = (T) binForm.Deserialize(memStream); + } + + return obj; + } + + private class Item + { + public Type type; + public GUIContent searchedGUIContent; + public List referencedGUIContents = new List(); + public List referenceGUIContents = new List(); + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/ReferenceViewer.cs.meta b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/ReferenceViewer.cs.meta new file mode 100755 index 00000000..3b3fe313 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/Editor/ReferenceViewer.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 84a160f95c5904927b278e772dd2c5d5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/LICENSE b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/LICENSE new file mode 100755 index 00000000..ccb39896 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2014 kyusyukeigo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/LICENSE.meta b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/LICENSE.meta new file mode 100644 index 00000000..57dc9962 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/LICENSE.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4c3b6f159cd204f2889b25d40ce3cb97 +timeCreated: 1468566072 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/README.md b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/README.md new file mode 100755 index 00000000..f136835e --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/README.md @@ -0,0 +1,4 @@ +ReferenceViewer +=============== + +Unity5対応 diff --git a/popcorn/Assets/USAYAUnityLib/ReferenceViewer/README.md.meta b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/README.md.meta new file mode 100644 index 00000000..b715ecdb --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/ReferenceViewer/README.md.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 95d6e48d07fb04c0b99c39b699a5bea0 +timeCreated: 1468566072 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts.meta b/popcorn/Assets/USAYAUnityLib/Scripts.meta new file mode 100644 index 00000000..1ffa01f2 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 80f8b68d606e74b65b2df5a3113815b0 +folderAsset: yes +timeCreated: 1447677936 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/ApiRequest.meta b/popcorn/Assets/USAYAUnityLib/Scripts/ApiRequest.meta new file mode 100644 index 00000000..9379770c --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/ApiRequest.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 653f1ac7e1ef94522859a35f0bd6853e +folderAsset: yes +timeCreated: 1501494875 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/ApiRequest/NtpRequest.cs b/popcorn/Assets/USAYAUnityLib/Scripts/ApiRequest/NtpRequest.cs new file mode 100644 index 00000000..0ca05787 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/ApiRequest/NtpRequest.cs @@ -0,0 +1,126 @@ +using UnityEngine; +using UnityEngine.Events; +using System; +using System.Collections; +using System.Net; +using System.Net.Sockets; +using System.Threading; + +// NTP同期時刻を返却するクラス +public class NtpRequest { + + private DateTime ntpDateTime; + private Thread thread; + private Socket socket; + private volatile bool threadRunning = false; + private int timeout = 3000; // ms + + private int retryCount = 0; + + private string[] NTP_SERVER = { + "time.google.com", + "cn.pool.ntp.org", + }; + + void OnApplicationQuit() { + CloseRequest (); + } + + public Coroutine GetNetworkTime(MonoBehaviour behaviour, Action succeededCallback, Action failedCallback, int timeout = 3000) + { + if (threadRunning) return null; + + // リクエスト実行 + retryCount = 0; + this.timeout = timeout; + ntpDateTime = DateTime.MinValue; + _threadStart(); + return behaviour.StartCoroutine(WaitForRequest(succeededCallback, failedCallback)); + } + private void _threadStart() + { + threadRunning = true; + thread = new Thread(new ThreadStart(NetworkRequest)); + thread.Start(); + } + + private IEnumerator WaitForRequest(Action succeededCallback, Action failedCallback) + { + int startTickCount = Environment.TickCount; + bool isTimeouted = false; + while ( threadRunning ) { + if (ntpDateTime > DateTime.MinValue){ + break; + } + // タイムアウト + else if (Environment.TickCount - startTickCount > timeout) { + isTimeouted = true; + break; + } + yield return 0; + } + + CloseRequest (); + threadRunning = false; + + if(!isTimeouted){ + if(succeededCallback != null) + succeededCallback (ntpDateTime); + // リトライ + }else if(retryCount < NTP_SERVER.Length-1){ + retryCount++; + isTimeouted = false; + _threadStart(); + yield return WaitForRequest(succeededCallback, failedCallback); + }else{ + failedCallback(); + } + } + + private void NetworkRequest() + { + try{ + string ntpServer = NTP_SERVER[retryCount]; + + var ntpData = new byte[48]; + //Setting the Leap Indicator, Version Number and Mode values + ntpData[0] = 0x1B; //LI = 0 (no warning), VN = 3 (IPv4 only), Mode = 3 (Client Mode) + + var addresses = Dns.GetHostEntry(ntpServer).AddressList; + var ipEndPoint = new IPEndPoint(addresses[0], 123); + + socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); + + // ソケット通信開始 + socket.Connect(ipEndPoint); + socket.Send(ntpData); + socket.Receive(ntpData); + socket.Close(); + + ulong intPart = (ulong)ntpData[40] << 24 | (ulong)ntpData[41] << 16 | (ulong)ntpData[42] << 8 | (ulong)ntpData[43]; + ulong fractPart = (ulong)ntpData[44] << 24 | (ulong)ntpData[45] << 16 | (ulong)ntpData[46] << 8 | (ulong)ntpData[47]; + + var milliseconds = (intPart * 1000) + ((fractPart * 1000) / 0x100000000L); + var networkDateTime = (new DateTime(1900, 1, 1)).AddMilliseconds((long)milliseconds); + + ntpDateTime = networkDateTime; + + }catch(SocketException){ + // TODO 例外フィルタでSocketException: Access deniedのみ取りたいが、C#のバージョンが足りない + // https://docs.microsoft.com/ja-jp/dotnet/csharp/language-reference/keywords/try-catch + }catch(ThreadAbortException){ + } + } + + private void CloseRequest(){ + if ( thread != null ) { + thread.Abort(); + } + if ( socket != null ) { + socket.Close(); + } + } +} + + + diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/ApiRequest/NtpRequest.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/ApiRequest/NtpRequest.cs.meta new file mode 100644 index 00000000..177d6fba --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/ApiRequest/NtpRequest.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c1f2cf14b25d64e8981c82fd8d159d53 +timeCreated: 1501494885 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions.meta new file mode 100644 index 00000000..ff18bdb1 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 00b448bec4646442a83c12538b510c45 +folderAsset: yes +timeCreated: 1447677936 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ActionExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ActionExtensions.cs new file mode 100644 index 00000000..6c05384c --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ActionExtensions.cs @@ -0,0 +1,8 @@ +using System; + +public static class ActionExtensions { + + public static Action EmptyAction = () => {}; + public static Action EmptyActionFloat = f => {}; + public static Action EmptyActionBool = b => {}; +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ActionExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ActionExtensions.cs.meta new file mode 100644 index 00000000..eb685ecc --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ActionExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1203317084b7343bea16e83c9d6abdd8 +timeCreated: 1519707277 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/AnimationCurveExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/AnimationCurveExtensions.cs new file mode 100644 index 00000000..296ff55c --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/AnimationCurveExtensions.cs @@ -0,0 +1,33 @@ +using UnityEngine; + +public static class AnimationCurveExtensions { + + public static AnimationCurve Smooth01; + public static AnimationCurve Smooth10; + + static AnimationCurveExtensions(){ + Smooth01 = AnimationCurve.EaseInOut(0.0f, 0.0f, 1.0f, 1.0f); + Smooth10 = AnimationCurve.EaseInOut(0.0f, 1.0f, 1.0f, 0.0f); + } + + // HACK tangentを見ていないので完璧ではない + public static float GetMax(this AnimationCurve ac){ + float result = 0.0f; + foreach(var keyframe in ac.keys){ + if(result < keyframe.value){ + result = keyframe.value; + } + } + return result; + } + // HACK tangentを見ていないので完璧ではない + public static float GetMin(this AnimationCurve ac){ + float result = float.MaxValue; + foreach(var keyframe in ac.keys){ + if(result > keyframe.value){ + result = keyframe.value; + } + } + return result; + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/AnimationCurveExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/AnimationCurveExtensions.cs.meta new file mode 100644 index 00000000..b8bb49e3 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/AnimationCurveExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6dfe80c8e1cd455c8a9e80efb8af6e0 +timeCreated: 1450922858 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/AnimatorExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/AnimatorExtensions.cs new file mode 100644 index 00000000..3638c14e --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/AnimatorExtensions.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using System; + +public static class AnimatorExtensions { + + /// GetBehaviourで取得出来ればfuncに渡す + public static bool FindBehaviour(this Animator t, Action func) where T : StateMachineBehaviour { + T behaviour = t.GetBehaviour(); + if(behaviour != null){ + func(behaviour); + return true; + }else{ + return false; + } + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/AnimatorExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/AnimatorExtensions.cs.meta new file mode 100644 index 00000000..c8e591ba --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/AnimatorExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4573ce8f8eb7d4226b5e5be91bfcb58d +timeCreated: 1489651712 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ArrayExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ArrayExtensions.cs new file mode 100644 index 00000000..a40da7f6 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ArrayExtensions.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public static class ArrayExtensions { + + public static T RandomChoose(this T[] array){ + return array[Random.Range(0, array.Length)]; + } + + public static T RandomChoose(this T[] array, System.Random rand){ + return array[rand.Next(array.Length)]; + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ArrayExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ArrayExtensions.cs.meta new file mode 100644 index 00000000..75b4640c --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ArrayExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6a289489ad7fb4be99c4c063e0eaea83 +timeCreated: 1510812961 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/BoolExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/BoolExtensions.cs new file mode 100644 index 00000000..6a4d52dd --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/BoolExtensions.cs @@ -0,0 +1,11 @@ + + +public static class BoolExtensions { + + public static int ToInt(this bool b){ + return b ? 1 : 0; + } + public static int ToIntPlusMinus(this bool b){ + return b ? 1 : -1; + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/BoolExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/BoolExtensions.cs.meta new file mode 100644 index 00000000..cae63fb9 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/BoolExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d88c00a093e4d4a079533103376f7f41 +timeCreated: 1528956662 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ColorExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ColorExtensions.cs new file mode 100644 index 00000000..9be97a8c --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ColorExtensions.cs @@ -0,0 +1,54 @@ +using UnityEngine; + +public static class ColorExtensions { + + public static Color invisibleWhite = Color.white - Color.black; + + public static Color Add(this Color c1, Color c2){ + c1 += c2; + c1.r = Mathf.Clamp(c1.r, 0.0f, 1.0f); + c1.g = Mathf.Clamp(c1.g, 0.0f, 1.0f); + c1.b = Mathf.Clamp(c1.b, 0.0f, 1.0f); + c1.a = Mathf.Clamp(c1.a, 0.0f, 1.0f); + return c1; + } + + public static Color AddR(this Color c, float f){ + return c.SetR(c.r + f); + } + public static Color SetR(this Color c, float f){ + c.r = Mathf.Clamp(f, 0.0f, 1.0f); + return c; + } + public static Color AddG(this Color c, float f){ + return c.SetG(c.g + f); + } + public static Color SetG(this Color c, float f){ + c.g = Mathf.Clamp(f, 0.0f, 1.0f); + return c; + } + public static Color AddB(this Color c, float f){ + return c.SetB(c.b + f); + } + public static Color SetB(this Color c, float f){ + c.b = Mathf.Clamp(f, 0.0f, 1.0f); + return c; + } + public static Color AddA(this Color c, float f){ + return c.SetA(c.a + f); + } + public static Color SetA(this Color c, float f){ + c.a = Mathf.Clamp(f, 0.0f, 1.0f); + return c; + } + + private static string Slice(this string aString, int num){ + return aString.Substring(num, aString.Length - 1); + } + + public static string ToColorCode(this Color color){ + var color32 = (Color32)color; + int x = (((256 + ((int)color32.r) << 8) + ((int)color32.g) << 8) + ((int)color32.b)); + return "#" + x.ToString("X").Slice(1); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ColorExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ColorExtensions.cs.meta new file mode 100644 index 00000000..f715cdae --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ColorExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 98f5aa83b229a4cee85ef63c243a0607 +timeCreated: 1447677936 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/DictionaryExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/DictionaryExtensions.cs new file mode 100644 index 00000000..00cf00df --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/DictionaryExtensions.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +public static class DictionaryExtensions { + + public static U GetOrDefault(this Dictionary dict, T key, U defaultValue){ + if(dict.ContainsKey(key)){ + return dict[key]; + }else{ + return defaultValue; + } + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/DictionaryExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/DictionaryExtensions.cs.meta new file mode 100644 index 00000000..b53f677d --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/DictionaryExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: db73fbe5df0ae4cd89353a9881e3e57d +timeCreated: 1531902965 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/FloatExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/FloatExtensions.cs new file mode 100644 index 00000000..6d0e74cd --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/FloatExtensions.cs @@ -0,0 +1,241 @@ +using System; +using UnityEngine; + +public static class FloatExtentions { + + static public float Epsilon = 1.192093E-07f; + + static public string ToTimeString(this float f){ + TimeSpan time = TimeSpan.FromSeconds(f); + string result = string.Format("{0:D2}'{1:D2}\"{2:D3}", time.Minutes, time.Seconds, time.Milliseconds); + if(time.Hours > 0){ + result = string.Format("{0:D2}:{1}", time.Hours, result); + } + return result; + } + static public string ToTimeString(this float f, string secondsStr = "", string minutesStr = "", string hoursStr = "", string daysStr = "", bool isFull = false){ + TimeSpan time = TimeSpan.FromSeconds(f); + string result = ""; + int days = time.Days; + int hours = time.Hours; + int minutes = time.Minutes; + int seconds = time.Seconds; + if(daysStr.Length > 0){ + if(days > 0){ + result = string.Format("{0}{1}", days, daysStr); + } + }else{ + hours += days * 24; + } + if(hoursStr.Length > 0){ + if(hours > 0 || (isFull && result.Length > 0)){ + if(result.Length > 0){ + result = string.Format("{0}{1:D2}{2}", result, hours, hoursStr); + }else{ + result = string.Format("{0}{1}", hours, hoursStr); + } + } + }else{ + minutes += hours * 60; + } + if(minutesStr.Length > 0){ + if(minutes > 0 || (isFull && result.Length > 0)){ + if(result.Length > 0){ + result = string.Format("{0}{1:D2}{2}", result, minutes, minutesStr); + }else{ + result = string.Format("{0}{1}", minutes, minutesStr); + } + } + }else{ + seconds += minutes * 60; + } + if(secondsStr.Length > 0){ + if(result.Length == 0 || seconds > 0 || (isFull && result.Length > 0)){ + if(result.Length > 0){ + result = string.Format("{0}{1:D2}{2}", result, seconds, secondsStr); + }else{ + result = string.Format("{0}{1}", seconds, secondsStr); + } + } + } + return result; + } + static public string ToTimerString(this float f){ + TimeSpan time = TimeSpan.FromSeconds(f); + string result = string.Format("{0:D2}", time.Seconds); + if(time.Minutes > 0 || time.Hours > 0){ + result = string.Format("{0:D2}:{1}", time.Minutes, result); + } + if(time.Hours > 0){ + result = string.Format("{0:D2}:{1}", time.Hours, result); + } + return result; + } + static public string ToTimerString(this float f, string secondsStr, string minutesStr, string hoursStr, string daysStr, bool isFull = true){ + TimeSpan time = TimeSpan.FromSeconds(f); + string result = ""; + int days = time.Days; + int hours = time.Hours; + int minutes = time.Minutes; + int seconds = time.Seconds; + if(daysStr.Length > 0){ + if(days > 0){ + if(isFull){ + result = string.Format("{0}{1}", days, daysStr); + }else{ + return string.Format("{0}{1}", days + 1, daysStr); + } + } + }else{ + hours += days * 24; + } + if(hoursStr.Length > 0){ + if(hours > 0 || (isFull && result.Length > 0)){ + if(result.Length > 0){ + result = string.Format("{0}{1:D2}{2}", result, hours, hoursStr); + }else{ + if(isFull){ + result = string.Format("{0}{1}", hours, hoursStr); + }else{ + return string.Format("{0}{1}", hours + 1, hoursStr); + } + } + } + }else{ + minutes += hours * 60; + } + if(minutesStr.Length > 0){ + if(minutes > 0 || (isFull && result.Length > 0)){ + if(result.Length > 0){ + result = string.Format("{0}{1:D2}{2}", result, minutes, minutesStr); + }else{ + if(isFull){ + result = string.Format("{0}{1}", minutes, minutesStr); + }else{ + return string.Format("{0}{1}", minutes + 1, minutesStr); + } + } + } + }else{ + seconds += minutes * 60; + } + if(secondsStr.Length > 0){ + if(result.Length == 0 || seconds > 0 || (isFull && result.Length > 0)){ + if(result.Length > 0){ + result = string.Format("{0}{1:D2}{2}", result, seconds + 1, secondsStr); + }else{ + result = string.Format("{0}{1}", seconds + 1, secondsStr); + } + } + } + return result; + } + + static public string ToTimeStringJ(this float f, bool isFull = false){ + return f.ToTimeString("秒", "分", "時間", "日", isFull); + } + static public string ToTimerStringJ(this float f){ + return (f + 1.0f).ToTimeStringJ(true); + } + + public static float Floor(this float f, uint i){ + if(i == 0){ + return Mathf.Floor(f); + }else{ + return Mathf.Floor(f * Mathf.Pow(10.0f, i)) * Mathf.Pow(10.0f, -i); + } + } + + + public static float EaseInQuadratic(this float t){ + return t * t; + } + public static float EaseOutQuadratic(this float t){ + return -t * (t - 2.0f); + } + public static float EaseInOutQuadratic(this float t){ + t *= 2.0f; + if(t < 1.0f) return 0.5f * t * t; + t -= 1.0f; + return -0.5f * (t * (t - 2.0f) - 1.0f); + } + + public static float EaseInCubic(this float t){ + return t * t * t; + } + public static float EaseOutCubic(this float t){ + t -= 1.0f; + return t * t * t + 1; + } + public static float EaseInOutCubic(this float t){ + t *= 2.0f; + if(t < 1.0f) return 0.5f * t * t * t; + t -= 2.0f; + return 0.5f * (t * t * t + 2); + } + + public static float EaseInQuartic(this float t){ + return t * t * t * t; + } + public static float EaseOutQuartic(this float t){ + t -= 1.0f; + return -(t * t * t * t - 1); + } + public static float EaseInOutQuartic(this float t){ + t *= 2.0f; + if(t < 1.0f) return 0.5f * t * t * t * t; + t -= 2.0f; + return -0.5f * (t * t * t * t - 2); + } + + public static float EaseInQuintic(this float t){ + return t * t * t * t * t; + } + public static float EaseOutQuintic(this float t){ + t -= 1.0f; + return t * t * t * t * t + 1; + } + public static float EaseInOutQuintic(this float t){ + t *= 2.0f; + if(t < 1.0f) return 0.5f * t * t * t * t * t; + t -= 2.0f; + return 0.5f * (t * t * t * t * t + 2); + } + + public static float EaseInSinusoidal(this float t){ + return -Mathf.Cos(Mathf.PI / 2.0f * t) + 1.0f; + } + public static float EaseOutSinusoidal(this float t){ + return Mathf.Sin(Mathf.PI / 2.0f * t); + } + public static float EaseInOutSinusoidal(this float t){ + return -0.5f * (Mathf.Cos(Mathf.PI * t) - 1.0f); + } +/* + public static float EaseInExponential(this float t){ + return 2.0f ** (10.0f * (t - 1.0f)); + } + public static float EaseOutExponential(this float t){ + return -(2.0f ** (-10.0f * t)) + 1.0f; + } + public static float EaseInOutExponential(this float t){ + t *= 2.0f; + if(t < 1.0f) return 0.5f * 2.0f ** (10.0f * (t - 1.0f)); + t -= 2.0f; + return 0.5f * (-(2.0f ** (-10.0f * t)) + 2 ); + } +*/ + public static float EaseInCircular(this float t){ + return -(Mathf.Sqrt(1 - t * t) - 1); + } + public static float EaseOutCircular(this float t){ + t -= 1.0f; + return Mathf.Sqrt(1 - t * t); + } + public static float EaseInOutCircular(this float t){ + t *= 2.0f; + if(t < 1.0f) return -0.5f * (Mathf.Sqrt(1 - t * t) - 1); + t -= 2.0f; + return 0.5f * (Mathf.Sqrt(1 - t * t) + 1); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/FloatExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/FloatExtensions.cs.meta new file mode 100644 index 00000000..2bda0f7d --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/FloatExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e49c89c3c7e3842329adaab299994a37 +timeCreated: 1440878696 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/IntExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/IntExtensions.cs new file mode 100644 index 00000000..f99eace0 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/IntExtensions.cs @@ -0,0 +1,88 @@ +using UnityEngine; +using System; +using System.Linq; + +public static class IntExtensions { + + public static int RandomPlusMinus(){ + return UnityEngine.Random.Range(0, 2) * 2 - 1; + } + public static int RandomChooseRatio(params int[] ratioArray){ + return RandomChooseRatio(new System.Random(), ratioArray); + } + public static int RandomChooseRatio(System.Random rand, params int[] ratioArray){ + var totalRatio = ratioArray.Sum(); + var value = rand.Next(1, totalRatio + 1); + var result = -1; + for(var i = 0; i < ratioArray.Length; ++i){ + if(value <= ratioArray[i]){ + result = i; + break; + } + value -= ratioArray[i]; + } + return result; + } + + public static int PickUp(this int value, int i){ + switch(i){ + case 0: + return 0; + case 1: + return value % 10; + default: + return (value / (int)Math.Pow(10, i - 1)) % 10; + } + } + + public static string ToStringWithDigitCommas(this int value){ + return string.Format("{0:#,0}", value); + } + + public static string ToTimeString(this int value){ + int minute = value / 60; + int second = value % 60; + return string.Format ("{0:D2}:{1:D2}", minute, second); + } + /// 負数未対応 + public static string ToChineseNumerals(this int number){ + return ((long)number).ToChineseNumerals(); + } + public static string ToChineseNumerals(this long number){ + if(number < 0) return number.ToString(); + if(number == 0) return "〇"; + + string[] digit = new string[] { "", "一", "二", "三", "四", "五", "六", "七", "八", "九" }; + string[] subUnit = new string[] { "", "十", "百", "千" }; + string[] unit = new string[] { "", "万", "億", "兆", "京" }; + string str = ""; + int keta = 0; + while(number > 0){ + int k = keta % 4; + int n = (int)(number % 10); + + if(k == 0 && number % 10000 > 0){ + str = unit[keta / 4] + str; + } + + if(k != 0 && n == 1){ + str = subUnit[k] + str; + }else if(n != 0){ + str = digit[n] + subUnit[k] + str; + } + + ++keta; + number /= 10; + } + return str; + } + + public static string ToMetricPrefix(this ulong value, int decimalPoint = 1){ + string str = string.Format("{0:#,0}", value); + if(str.Length < 4) return str; + string result = str.Substring(0, str.IndexOf(',') + 2).Replace(',', '.'); + string[] unit = new string[] { "", "k", "M", "G", "T", "P", "E", "Z", "Y" }; + result = string.Format("{0}{1}", result, unit[Mathf.Min(str.Count(c => c == ','), unit.Length - 1)]); + return result; + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/IntExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/IntExtensions.cs.meta new file mode 100644 index 00000000..29d8f572 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/IntExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 680b7832fb5f847e09eac98cc9cf1e02 +timeCreated: 1447677936 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ListExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ListExtensions.cs new file mode 100644 index 00000000..c932624a --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ListExtensions.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +[Serializable] +public abstract class ChooseData { + public float ratio; +} + +public static class ListExtensions{ + + public static T Head(this List list){ + return list[0]; + } + public static List Tail(this List list){ + return new List(list.Skip(1)); + } + public static T Front(this List list){ + return list[0]; + } + public static T Back(this List list){ + return list[list.Count - 1]; + } + + public static bool Empty(this List list){ + return list.Count == 0; + } + + public static List Shuffle(this List list){ + return Shuffle(list, new System.Random()); + } + public static List Shuffle(this List list, System.Random rand){ + int n = list.Count; + while (n > 1) { + --n; + int k = rand.Next(n + 1); + T value = list[k]; + list[k] = list[n]; + list[n] = value; + } + return list; + } + + public static T RandomChoose(this IList list){ + return list.RandomChoose(new System.Random()); + } + public static T RandomChoose(this IList list, System.Random rand){ + return list[rand.Next(list.Count)]; + } + public static List RandomChoose(this IList list, int count){ + return list.RandomChoose(count, new System.Random()); + } + public static List RandomChoose(this IList list, int count, System.Random rand){ + if(count <= 0){ + return new List(); + } + var tempList = new List(list); + if(list.Count < count){ + return tempList; + } + + var resultList = new List(); + for(int i = 0; i < count; ++i){ + var result = tempList.RandomChoose(rand); + tempList.Remove(result); + resultList.Add(result); + } + return resultList; + } + + public static T RandomChooseRatio(this IEnumerable list) where T : ChooseData{ + return list.RandomChooseRatio(new System.Random()); + } + public static T RandomChooseRatio(this IEnumerable list, System.Random rand) where T : ChooseData{ + float totalRatio = list.Sum(i => i.ratio); + float targetRatio = (float)rand.NextDouble() * totalRatio; + float r = 0.0f; + T result = null; + foreach(var item in list){ + r += item.ratio; + if(r > targetRatio){ + result = item; + break; + } + } + return result; + } + public static List RandomChooseRatio(this List list, int count) where T : ChooseData { + return list.RandomChooseRatio(count, new System.Random()); + } + public static List RandomChooseRatio(this List list, int count, System.Random rand) where T : ChooseData { + if(list.Count < count) return list; + var chooseList = new List(list); + var resultList = new List(); + for(int i = 0; i < count; ++i){ + var result = chooseList.RandomChooseRatio(rand); + chooseList.Remove(result); + resultList.Add(result); + } + return resultList; + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ListExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ListExtensions.cs.meta new file mode 100644 index 00000000..c60e78b6 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ListExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 02f3f4759ad5c460bad17d00bd8e5a2a +timeCreated: 1447677936 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/MonoBehaviourExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/MonoBehaviourExtensions.cs new file mode 100644 index 00000000..8891fe48 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/MonoBehaviourExtensions.cs @@ -0,0 +1,259 @@ +using UnityEngine; +using System; +using System.Collections; + +public static class MonoBehaviourExtensions { + + public static void SafeStopCoroutine(this MonoBehaviour monoBehaviour, Coroutine c){ + if(c != null) monoBehaviour.StopCoroutine(c); + } + + /// 1フレーム待機してからActionデリゲートを呼び出す + public static Coroutine CallWaitForOneFrame(this MonoBehaviour monoBehaviour, Action act){ + return monoBehaviour.StartCoroutine(DoCallWaitForOneFrame(act)); + } + private static IEnumerator DoCallWaitForOneFrame(Action act){ + yield return null; + act(); + } + /// 指定フレーム数待機してからActionデリゲートを呼び出す + public static Coroutine CallWaitForFrame(this MonoBehaviour monoBehaviour, int frameCount, Action act){ + return monoBehaviour.StartCoroutine(DoCallWaitForFrame(frameCount, act)); + } + private static IEnumerator DoCallWaitForFrame(int frameCount, Action act){ + for(int i = 0; i < frameCount; ++i) yield return null; + act(); + } + + /// 1FixedUpdate待機してからActionデリゲートを呼び出す + public static Coroutine CallWaitForOneFixedUpdate(this MonoBehaviour monoBehaviour, Action act){ + return monoBehaviour.StartCoroutine(DoCallWaitForOneFixedUpdate(act)); + } + private static IEnumerator DoCallWaitForOneFixedUpdate(Action act){ + yield return new WaitForFixedUpdate(); + act(); + } + /// 指定FixedUpdate数待機してからActionデリゲートを呼び出す + public static Coroutine CallWaitForFixedUpdate(this MonoBehaviour monoBehaviour, int frameCount, Action act){ + return monoBehaviour.StartCoroutine(DoCallWaitForFixedUpdate(frameCount, act)); + } + private static IEnumerator DoCallWaitForFixedUpdate(int frameCount, Action act){ + for(int i = 0; i < frameCount; ++i) yield return new WaitForFixedUpdate(); + act(); + } + + /// 指定秒数待機してからActionデリゲートを呼び出す + public static Coroutine CallWaitForSeconds(this MonoBehaviour monoBehaviour, float seconds, Action act){ + return monoBehaviour.StartCoroutine(DoCallWaitForSeconds(seconds, act)); + } + private static IEnumerator DoCallWaitForSeconds(float seconds, Action act){ + yield return new WaitForSeconds(seconds); + act(); + } + public static Coroutine CallWaitForSeconds(this MonoBehaviour monoBehaviour, float seconds, Action act, Action callback){ + return monoBehaviour.StartCoroutine(DoCallWaitForSeconds(seconds, act, callback)); + } + private static IEnumerator DoCallWaitForSeconds(float seconds, Action act, Action callback){ + float t = 0.0f; + act(t); + do{ + yield return null; + t += Time.deltaTime; + act(t); + }while(t < seconds); + callback(); + } + public static Coroutine CallWaitForRealTimeSeconds(this MonoBehaviour monoBehaviour, float seconds, Action callback){ + return monoBehaviour.StartCoroutine(DoCallWaitForRealTimeSeconds(seconds, ActionExtensions.EmptyActionFloat, callback)); + } + public static Coroutine CallWaitForRealTimeSeconds(this MonoBehaviour monoBehaviour, float seconds, Action act, Action callback){ + return monoBehaviour.StartCoroutine(DoCallWaitForRealTimeSeconds(seconds, act, callback)); + } + private static IEnumerator DoCallWaitForRealTimeSeconds(float seconds, Action act, Action callback){ + float startupTime = Time.realtimeSinceStartup; + float t = 0.0f; + act(t); + while(true){ + yield return null; + t = (Time.realtimeSinceStartup - startupTime); + if(t >= seconds){ + act(seconds); + break; + }else{ + act(t); + } + } + callback(); + } + + public static Coroutine CallLerp(this MonoBehaviour monoBehaviour, float duration, Action act){ + return monoBehaviour.CallLerp(duration, act, ActionExtensions.EmptyAction); + } + public static Coroutine CallLerp(this MonoBehaviour monoBehaviour, float duration, Action act, Action callback){ + return monoBehaviour.StartCoroutine(DoCallLerp(duration, act, callback)); + } + public static IEnumerator DoCallLerp(float duration, Action act){ + return DoCallLerp(duration, act, ActionExtensions.EmptyAction); + } + public static IEnumerator DoCallLerp(float duration, Action act, Action callback){ + float t = 0.0f; + act(t); + while(true){ + yield return null; + t += Time.deltaTime / duration; + if(t >= 1.0f){ + act(1.0f); + break; + }else{ + act(t); + } + } + callback(); + } + public static Coroutine CallFixedLerp(this MonoBehaviour monoBehaviour, float duration, Action act){ + return monoBehaviour.CallFixedLerp(duration, act, ActionExtensions.EmptyAction); + } + public static Coroutine CallFixedLerp(this MonoBehaviour monoBehaviour, float duration, Action act, Action callback){ + return monoBehaviour.StartCoroutine(DoCallFixedLerp(duration, act, callback)); + } + public static IEnumerator DoCallFixedLerp(float duration, Action act){ + return DoCallFixedLerp(duration, act, ActionExtensions.EmptyAction); + } + public static IEnumerator DoCallFixedLerp(float duration, Action act, Action callback){ + float t = 0.0f; + act(t); + while(true){ + yield return new WaitForFixedUpdate(); + t += Time.fixedDeltaTime / duration; + if(t >= 1.0f){ + act(1.0f); + break; + }else{ + act(t); + } + } + callback(); + } + public static Coroutine CallFixedLerpRealTime(this MonoBehaviour monoBehaviour, float duration, Action act){ + return monoBehaviour.CallFixedLerpRealTime(duration, act, ActionExtensions.EmptyAction); + } + public static Coroutine CallFixedLerpRealTime(this MonoBehaviour monoBehaviour, float duration, Action act, Action callback){ + return monoBehaviour.StartCoroutine(DoCallFixedLerpRealTime(duration, act, callback)); + } + public static IEnumerator DoCallFixedLerpRealTime(float duration, Action act){ + return DoCallFixedLerpRealTime(duration, act, ActionExtensions.EmptyAction); + } + public static IEnumerator DoCallFixedLerpRealTime(float duration, Action act, Action callback){ + float t = 0.0f; + act(t); + while(true){ + yield return new WaitForFixedUpdate(); + t += Time.fixedUnscaledDeltaTime / duration; + if(t >= 1.0f){ + act(1.0f); + break; + }else{ + act(t); + } + } + callback(); + } + public static Coroutine CallLerpSmooth(this MonoBehaviour monoBehaviour, float duration, Action act){ + return monoBehaviour.CallLerpSmooth(duration, act, ActionExtensions.EmptyAction); + } + public static Coroutine CallLerpSmooth(this MonoBehaviour monoBehaviour, float duration, Action act, Action callback){ + return monoBehaviour.StartCoroutine(DoCallLerpSmooth(duration, act, callback)); + } + public static IEnumerator DoCallLerpSmooth(float duration, Action act){ + return DoCallLerpSmooth(duration, act, ActionExtensions.EmptyAction); + } + public static IEnumerator DoCallLerpSmooth(float duration, Action act, Action callback){ + float t = 0.0f; + act(t); + while(true){ + yield return null; + t += Time.smoothDeltaTime / duration; + if(t >= 1.0f){ + act(1.0f); + break; + }else{ + act(t); + } + } + callback(); + } + + public static Coroutine CallLerpRealtime(this MonoBehaviour monoBehaviour, float duration, Action act){ + return monoBehaviour.CallLerpRealtime(duration, act, ActionExtensions.EmptyAction); + } + public static Coroutine CallLerpRealtime(this MonoBehaviour monoBehaviour, float duration, Action act, Action callback){ + return monoBehaviour.StartCoroutine(DoCallLerpRealtime(duration, act, callback)); + } + public static IEnumerator DoCallLerpRealtime(float duration, Action act){ + return DoCallLerpRealtime(duration, act, ActionExtensions.EmptyAction); + } + public static IEnumerator DoCallLerpRealtime(float duration, Action act, Action callback){ + float startupTime = Time.realtimeSinceStartup; + float t = 0.0f; + act(t); + while(true){ + yield return null; + t = (Time.realtimeSinceStartup - startupTime); + if(t >= duration){ + act(1.0f); + break; + }else{ + act(t / duration); + } + } + callback(); + } + + /// 指定秒間、指定秒間隔でactionを行う + public static Coroutine CallTimer(this MonoBehaviour monoBehaviour, float seconds, float interval, Action action){ + return monoBehaviour.CallTimer(seconds, 0.0f, interval, action, ActionExtensions.EmptyAction); + } + public static Coroutine CallTimer(this MonoBehaviour monoBehaviour, float seconds, float interval, Action action, Action callback){ + return monoBehaviour.StartCoroutine(DoCallTimer(seconds, 0.0f, interval, action, callback)); + } + public static Coroutine CallTimer(this MonoBehaviour monoBehaviour, float seconds, float firstTime, float interval, Action action){ + return monoBehaviour.CallTimer(seconds, firstTime, interval, action, ActionExtensions.EmptyAction); + } + public static Coroutine CallTimer(this MonoBehaviour monoBehaviour, float seconds, float firstTime, float interval, Action action, Action callback){ + return monoBehaviour.StartCoroutine(DoCallTimer(seconds, firstTime, interval, action, callback)); + } + private static IEnumerator DoCallTimer(float seconds, float firstTime, float interval, Action action, Action callback){ + float t = 0.0f; + float timer = firstTime; + int counter = 1; + do{ + yield return null; + t += Time.deltaTime; + timer += Time.deltaTime; + while(timer >= interval){ + timer -= interval; + action(++counter); + } + }while(t < seconds); + callback(); + } + public static Coroutine CallTimerRealtime(this MonoBehaviour monoBehaviour, float seconds, float interval, Action action, Action callback){ + return monoBehaviour.StartCoroutine(DoCallTimerRealtime(seconds, interval, action, callback)); + } + private static IEnumerator DoCallTimerRealtime(float seconds, float interval, Action action, Action callback){ + float startupTime = Time.realtimeSinceStartup; + float t = 0.0f; + int counter = 0; + action(counter + 1); + do{ + yield return null; + t = (Time.realtimeSinceStartup - startupTime); + int count = (int)(t / interval); + if(counter != count){ + counter = count; + action(counter + 1); + } + }while(t < seconds); + callback(); + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/MonoBehaviourExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/MonoBehaviourExtensions.cs.meta new file mode 100644 index 00000000..a19f5a63 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/MonoBehaviourExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 08ce09e9ed079448faf483e6565acd3b +timeCreated: 1468288501 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/QueueExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/QueueExtensions.cs new file mode 100644 index 00000000..9ff27c35 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/QueueExtensions.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +public static class QueueExtensions { + + public static void EnqueueEnd(this Queue queue, T obj){ + int count = queue.Count; + queue.Enqueue(obj); + for(int i = 0; i < count; ++i) queue.Enqueue(queue.Dequeue()); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/QueueExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/QueueExtensions.cs.meta new file mode 100644 index 00000000..1ddc40ed --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/QueueExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 23e5f9cee5a334f19a3699609d87f36a +timeCreated: 1472625404 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/RandomExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/RandomExtensions.cs new file mode 100644 index 00000000..53ee3d0a --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/RandomExtensions.cs @@ -0,0 +1,8 @@ +using System; + +public static class RandomExtensions { + + public static float NextFloat(this Random random){ + return (float)random.NextDouble(); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/RandomExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/RandomExtensions.cs.meta new file mode 100644 index 00000000..5503fc64 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/RandomExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7f94de11fcc884114a64c9cbebc4369f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/RaycastExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/RaycastExtensions.cs new file mode 100644 index 00000000..908a814b --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/RaycastExtensions.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using UnityEngine; + +public static class RaycastExtensions { + public static RaycastHit[] ConeCastAll(Vector3 origin, Vector3 direction, float coneAngle, float maxRadius, float maxDistance = Mathf.Infinity, int layerMask = Physics.DefaultRaycastLayers){ + var sphereCastHits = Physics.SphereCastAll(origin - new Vector3(0,0,maxRadius), maxRadius, direction, maxDistance); + if(sphereCastHits.Length > 0){ + var coneCastHitList = new List(); + for(int i = 0; i < sphereCastHits.Length; ++i){ + var hitPoint = sphereCastHits[i].point; + var directionToHit = hitPoint - origin; + var angleToHit = Vector3.Angle(direction, directionToHit); + if(angleToHit < coneAngle){ + coneCastHitList.Add(sphereCastHits[i]); + } + } + return coneCastHitList.ToArray(); + }else{ + return new RaycastHit[0]; + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/RaycastExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/RaycastExtensions.cs.meta new file mode 100644 index 00000000..a0adc6e5 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/RaycastExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dc63a9c062a0d430584024026c757296 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ScreenExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ScreenExtensions.cs new file mode 100644 index 00000000..e620a19d --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ScreenExtensions.cs @@ -0,0 +1,135 @@ +using UnityEngine; + +public enum ScreenRotateState { + Free, + LandscapeOnly, + PortraitOnly +} + +public enum SimpleDeviceOrientation { + Unkown, + Portrait, + Landscape, +} + +public static class ScreenExtensions { + + public static bool IsNarrowScreen(){ + float height = Screen.height; + float width = Screen.width; + if(height > width){ + return 16.1f / 9.0f < height / width; + }else{ + return 16.1f / 9.0f < width / height; + } + } + + public static bool HasSafeArea(){ + float height = Screen.height; + float width = Screen.width; + if(height > width){ +#if UNITY_EDITOR + return Screen.height != (int)GetSafeArea().height; +#else + return Screen.height != (int)Screen.safeArea.height; +#endif + }else{ +#if UNITY_EDITOR + return Screen.width != (int)GetSafeArea().width; +#else + return Screen.width != (int)Screen.safeArea.width; +#endif + } + } + + public static Rect GetSafeArea(){ +#if UNITY_EDITOR + if((Screen.width == 1125 && Screen.height == 2436) || + (Screen.width == 2436 && Screen.height == 1125)){ + var safeArea = Screen.safeArea; + if(safeArea.height > safeArea.width){ + safeArea.height = 2202; + safeArea.y = 102; + safeArea.width = 1125; + }else{ + safeArea.height = 1062; + safeArea.y = 63; + safeArea.width = 2172; + safeArea.x = 132; + } + return safeArea; + }else{ + return Screen.safeArea; + } +#else + return Screen.safeArea; +#endif + } + public static int GetSafeAreaTop(){ + var safeArea = GetSafeArea(); + return (int)((Screen.height - safeArea.height - safeArea.y) / safeArea.height * 1136.0f); + } + public static int GetSafeAreaBottom(){ + var safeArea = GetSafeArea(); + return (int)(safeArea.y / safeArea.height * 1136.0f); + } + + public static bool IsiPhoneX(){ + return (NativeUtils.getWidth() == 1125 && NativeUtils.getHeight() == 2436) // iPhone X XS + || (NativeUtils.getWidth() == 2436 && NativeUtils.getHeight() == 1125) // iPhone X XS + || (NativeUtils.getWidth() == 828 && NativeUtils.getHeight() == 1792) // iPhone XR + || (NativeUtils.getWidth() == 1792 && NativeUtils.getHeight() == 828) // iPhone XR + || (NativeUtils.getWidth() == 1242 && NativeUtils.getHeight() == 2688) // iPhone XSMax + || (NativeUtils.getWidth() == 2688 && NativeUtils.getHeight() == 1242); // iPhone XSMax + } + + public static void ChangeScreenRotateState(MonoBehaviour behaviour, ScreenRotateState state){ + switch(state){ + case ScreenRotateState.Free: + Screen.autorotateToLandscapeLeft = true; + Screen.autorotateToLandscapeRight = true; + Screen.autorotateToPortrait = true; + Screen.autorotateToPortraitUpsideDown = true; + break; + case ScreenRotateState.LandscapeOnly: + Screen.autorotateToLandscapeLeft = true; + Screen.autorotateToLandscapeRight = true; + Screen.autorotateToPortrait = false; + Screen.autorotateToPortraitUpsideDown = false; +#if UNITY_ANDROID + // Portrait時に自動でLandscapeにならないので強制変更してからの自動化 + if(Screen.orientation == ScreenOrientation.Portrait || Screen.orientation == ScreenOrientation.PortraitUpsideDown){ + Screen.orientation = ScreenOrientation.LandscapeLeft; + behaviour.CallWaitForOneFrame(() => Screen.orientation = ScreenOrientation.AutoRotation); + } +#endif + break; + case ScreenRotateState.PortraitOnly: + Screen.autorotateToLandscapeLeft = false; + Screen.autorotateToLandscapeRight = false; + Screen.autorotateToPortrait = true; + Screen.autorotateToPortraitUpsideDown = true; +#if UNITY_ANDROID + // Landscape時に自動でPortraitにならないので強制変更してからの自動化 + if(Screen.orientation == ScreenOrientation.LandscapeLeft || Screen.orientation == ScreenOrientation.LandscapeRight){ + Screen.orientation = ScreenOrientation.Portrait; + behaviour.CallWaitForOneFrame(() => Screen.orientation = ScreenOrientation.AutoRotation); + } +#endif + break; + } + } + + public static SimpleDeviceOrientation DeviceOrientationToSimpleDeviceOrientation(DeviceOrientation deviceOrientation){ + switch(deviceOrientation){ + case DeviceOrientation.Portrait: + case DeviceOrientation.PortraitUpsideDown: + return SimpleDeviceOrientation.Portrait; + case DeviceOrientation.LandscapeLeft: + case DeviceOrientation.LandscapeRight: + return SimpleDeviceOrientation.Landscape; + default: + return Screen.width < Screen.height ? SimpleDeviceOrientation.Portrait : SimpleDeviceOrientation.Landscape; + } + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ScreenExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ScreenExtensions.cs.meta new file mode 100644 index 00000000..7a41e384 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ScreenExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 48c7e8fb55b704635adffa60ce8b5bb3 +timeCreated: 1501742506 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ShaderExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ShaderExtensions.cs new file mode 100644 index 00000000..d8c2ba6c --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ShaderExtensions.cs @@ -0,0 +1,10 @@ +using UnityEngine; + +public static class ShaderExtensions { + + public static Material CreateHiddenMaterial(this Shader shader){ + var material = new Material(shader); + material.hideFlags = HideFlags.HideAndDontSave; + return material; + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ShaderExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ShaderExtensions.cs.meta new file mode 100644 index 00000000..0f59fc88 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/ShaderExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5a375436608784dbfaee14455c98f957 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/StringExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/StringExtensions.cs new file mode 100644 index 00000000..f8ab53a6 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/StringExtensions.cs @@ -0,0 +1,117 @@ +using Unity.IO.Compression; +using UnityEngine; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; + +public static class StringExtensions { + + public static int ToInt(this string str){ + return int.Parse(str); + } + public static Color ToColor(this string str){ + var color = default(Color); + if(ColorUtility.TryParseHtmlString(str, out color)){ + return color; + }else{ +#if UNITY_EDITOR + UnityEditor.EditorApplication.isPlaying = false; + Debug.LogError(string.Format("無効な色指定 {0} があるので修正して下さい。フォーマットは #000000 です。", str)); +#endif + return Color.magenta; + } + } + public static int ToLayer(this string str){ + return LayerMask.NameToLayer(str); + } + public static int ToLayerMask(this string str){ + return 1 << ToLayer(str); + } + public static int ToLayerMask(params string[] strArray){ + int result = 0; + foreach(var str in strArray){ + result |= ToLayerMask(str); + } + return result; + } + public static List ToIntList(this string str){ + if(str == null){ + return new List(); + }else{ + return str.Split(',').Select(Int32.Parse).ToList(); + } + } + + static public bool CheckPictograph(this string text){ + Encoding sjisEncode = Encoding.GetEncoding("Shift_JIS"); + return text != sjisEncode.GetString(sjisEncode.GetBytes(text)); + } + + static public int CompareVersion(this string a, string b){ + if(a == b) return 0; + string[] splitA = a.Split('.'); + string[] splitB = b.Split('.'); + int max = Math.Max(splitA.Length, splitB.Length); + for(int i = 0; i < max; ++i){ + if(i >= splitA.Length) return 1; + if(i >= splitB.Length) return -1; + int result = Int32.Parse(splitA[i]) - Int32.Parse(splitB[i]); + if(result != 0) return result; // 1に正規化すべきかどうか + } + return 0; + } + + public static bool IsVersion(this string str){ + System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"[0-9]+\.[0-9]+\.[0-9]+"); + return regex.IsMatch(str); + } + + public static string Compression(this string str){ + byte[] source = Encoding.UTF8.GetBytes(str); + byte[] resultBytes; + using(MemoryStream ms = new MemoryStream()){ + DeflateStream CompressedStream = new DeflateStream(ms, CompressionMode.Compress, true); + CompressedStream.Write(source, 0, source.Length); + CompressedStream.Close(); + resultBytes = ms.ToArray(); + } + return Convert.ToBase64String(resultBytes, Base64FormattingOptions.InsertLineBreaks); + } + + public static string DeCompression(this string str){ + byte[] source = Convert.FromBase64String(str); + byte[] resultBytes; + using(MemoryStream ms = new MemoryStream(source)) + using(MemoryStream ms2 = new MemoryStream()){ + DeflateStream CompressedStream = new DeflateStream(ms, CompressionMode.Decompress); + while(true){ + int rb = CompressedStream.ReadByte(); + if(rb == -1) break; + ms2.WriteByte((byte)rb); + } + resultBytes = ms2.ToArray(); + } + return Encoding.UTF8.GetString(resultBytes); + } + + public static string DataToXML(T data, bool isShorten = true){ + DataContractSerializer serializer = new DataContractSerializer(typeof(T)); + using(MemoryStream memoryStream = new MemoryStream()){ + serializer.WriteObject(memoryStream, data); + return Encoding.UTF8.GetString(memoryStream.ToArray(), 0, (int)memoryStream.Length); + } + } + + public static T XMLToData(string xml) where T : class { + DataContractSerializer serializer = new DataContractSerializer(typeof(T)); + using(MemoryStream memoryStream = new MemoryStream()){ + byte[] data = Encoding.UTF8.GetBytes(xml); + memoryStream.Write(data, 0, data.Length); + memoryStream.Seek(0, SeekOrigin.Begin); + return serializer.ReadObject(memoryStream) as T; + } + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/StringExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/StringExtensions.cs.meta new file mode 100644 index 00000000..8459a968 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/StringExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1d4065c4f846749f5a98942b7de0de76 +timeCreated: 1482397392 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/Texture2DExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/Texture2DExtensions.cs new file mode 100644 index 00000000..ae458a87 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/Texture2DExtensions.cs @@ -0,0 +1,7 @@ +using UnityEngine; + +public static class Texture2DExtensions { + public static Sprite ToSprite(this Texture2D tex){ + return Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/Texture2DExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/Texture2DExtensions.cs.meta new file mode 100644 index 00000000..7245bd32 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/Texture2DExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 05ab237f5e34d4cb3bbaf671e249e0a2 +timeCreated: 1464338990 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/TextureExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/TextureExtensions.cs new file mode 100644 index 00000000..52dbeabb --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/TextureExtensions.cs @@ -0,0 +1,23 @@ +using UnityEngine; + +public static class TextureExtensions { + + public static bool isBogus(this Texture tex){ + if(!tex) return true; + + byte[] png = (tex as Texture2D).EncodeToPNG(); + byte[] questionMarkPNG = new byte[]{ 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 8, 0, 0, 0, 8, 8, 2, 0, 0, 0, 75, 109, 41, 220, 0, 0, 0, 65, 73, 68, 65, 84, 8, 29, 85, 142, 81, 10, 0, 48, 8, 66, 107, 236, 254, 87, 110, 106, 35, 172, 143, 74, 243, 65, 89, 85, 129, 202, 100, 239, 146, 115, 184, 183, 11, 109, 33, 29, 126, 114, 141, 75, 213, 65, 44, 131, 70, 24, 97, 46, 50, 34, 72, 25, 39, 181, 9, 251, 205, 14, 10, 78, 123, 43, 35, 17, 17, 228, 109, 164, 219, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130 }; + + return Equivalent(png, questionMarkPNG); + } + + public static bool Equivalent(byte[] bytes1, byte[] bytes2){ + if(bytes1.Length != bytes2.Length) return false; + for(int i = 0; i < bytes1.Length; ++i){ + if(!bytes1[i].Equals(bytes2[i])){ + return false; + } + } + return true; + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/TextureExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/TextureExtensions.cs.meta new file mode 100644 index 00000000..5c4a89b1 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/TextureExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c628dadde81304f10bf390a38f9ea515 +timeCreated: 1524449450 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/TransformExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/TransformExtensions.cs new file mode 100644 index 00000000..f58773bb --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/TransformExtensions.cs @@ -0,0 +1,406 @@ +using UnityEngine; +using System; + +public static class TransformExtensions { + + public static float ForwardToTargetPositionXZAngle(this Transform transform, Transform target){ + return transform.ForwardToTargetPositionXZAngle(target.position); + } + public static float ForwardToTargetPositionXZAngle(this Transform transform, Vector3 targetPosition){ + Vector2 t = (targetPosition - transform.position).ToVector2XZ().normalized; + Vector2 f = transform.forward.ToVector2XZ().normalized; + return Mathf.Atan2(t.Cross(f), t.Dot(f)) * Mathf.Rad2Deg; + } + + // position + public static void SetPositionX(this Transform t, float f){ + t.position = t.position.SetX(f); + } + public static void SetPositionY(this Transform t, float f){ + t.position = t.position.SetY(f); + } + public static void SetPositionZ(this Transform t, float f){ + t.position = t.position.SetZ(f); + } + + public static void AddPositionX(this Transform t, float f){ + t.SetPositionX(t.position.x + f); + } + public static void AddPositionY(this Transform t, float f){ + t.SetPositionY(t.position.y + f); + } + public static void AddPositionZ(this Transform t, float f){ + t.SetPositionZ(t.position.z + f); + } + + // localPosition + public static void SetLocalPositionX(this Transform t, float f){ + t.localPosition = t.localPosition.SetX(f); + } + public static void SetLocalPositionY(this Transform t, float f){ + t.localPosition = t.localPosition.SetY(f); + } + public static void SetLocalPositionZ(this Transform t, float f){ + t.localPosition = t.localPosition.SetZ(f); + } + + public static void AddLocalPositionX(this Transform t, float f){ + t.SetLocalPositionX(t.localPosition.x + f); + } + public static void AddLocalPositionY(this Transform t, float f){ + t.SetLocalPositionY(t.localPosition.y + f); + } + public static void AddLocalPositionZ(this Transform t, float f){ + t.SetLocalPositionZ(t.localPosition.z + f); + } + + // eulerAngles + public static void SetEulerAnglesX(this Transform t, float f){ + t.eulerAngles = t.eulerAngles.SetX(f); + } + public static void SetEulerAnglesY(this Transform t, float f){ + t.eulerAngles = t.eulerAngles.SetY(f); + } + public static void SetEulerAnglesZ(this Transform t, float f){ + t.eulerAngles = t.eulerAngles.SetZ(f); + } + + public static void AddEulerAnglesX(this Transform t, float f){ + t.SetEulerAnglesX(t.eulerAngles.x + f); + } + public static void AddEulerAnglesY(this Transform t, float f){ + t.SetEulerAnglesY(t.eulerAngles.y + f); + } + public static void AddEulerAnglesZ(this Transform t, float f){ + t.SetEulerAnglesZ(t.eulerAngles.z + f); + } + + // localEulerAngles + public static void SetLocalEulerAnglesX(this Transform t, float f){ + t.localEulerAngles = t.localEulerAngles.SetX(f); + } + public static void SetLocalEulerAnglesY(this Transform t, float f){ + t.localEulerAngles = t.localEulerAngles.SetY(f); + } + public static void SetLocalEulerAnglesZ(this Transform t, float f){ + t.localEulerAngles = t.localEulerAngles.SetZ(f); + } + + public static void AddLocalEulerAnglesX(this Transform t, float f){ + t.SetLocalEulerAnglesX(t.localEulerAngles.x + f); + } + public static void AddLocalEulerAnglesY(this Transform t, float f){ + t.SetLocalEulerAnglesY(t.localEulerAngles.y + f); + } + public static void AddLocalEulerAnglesZ(this Transform t, float f){ + t.SetLocalEulerAnglesZ(t.localEulerAngles.z + f); + } + + // localScale + public static void SetLocalScaleX(this Transform t, float f){ + t.localScale = t.localScale.SetX(f); + } + public static void SetLocalScaleY(this Transform t, float f){ + t.localScale = t.localScale.SetY(f); + } + public static void SetLocalScaleZ(this Transform t, float f){ + t.localScale = t.localScale.SetZ(f); + } + + public static void MulLocalScaleX(this Transform t, float f){ + t.localScale = t.localScale.MulX(f); + } + public static void MulLocalScaleY(this Transform t, float f){ + t.localScale = t.localScale.MulY(f); + } + public static void MulLocalScaleZ(this Transform t, float f){ + t.localScale = t.localScale.MulZ(f); + } + + public static void AddLocalScale(this Transform t, float f){ + t.localScale += Vector3.one * f; + } + public static void SetLocalScale(this Transform t, float f){ + t.localScale = Vector3.one * f; + } + + + public static bool NearCheckX(this Transform t1, Transform t2, float max){ + return t1.position.NearCheckX(t2.position, max); + } + public static bool NearCheckY(this Transform t1, Transform t2, float max){ + return t1.position.NearCheckY(t2.position, max); + } + public static bool NearCheckZ(this Transform t1, Transform t2, float max){ + return t1.position.NearCheckZ(t2.position, max); + } + public static bool NearCheck(this Transform t1, Transform t2, float max){ + return t1.position.NearCheck(t2.position, max); + } + public static bool NearCheck(this Transform t, Vector3 p, float max){ + return t.position.NearCheck(p, max); + } + + public static bool LocalNearCheckX(this Transform t1, Transform t2, float max){ + return t1.localPosition.NearCheckX(t2.localPosition, max); + } + public static bool LocalNearCheckY(this Transform t1, Transform t2, float max){ + return t1.localPosition.NearCheckY(t2.localPosition, max); + } + public static bool LocalNearCheckZ(this Transform t1, Transform t2, float max){ + return t1.localPosition.NearCheckZ(t2.localPosition, max); + } + public static bool LocalNearCheck(this Transform t1, Transform t2, float max){ + return t1.localPosition.NearCheck(t2.localPosition, max); + } + public static bool LocalNearCheck(this Transform t, Vector3 p, float max){ + return t.localPosition.NearCheck(p, max); + } + + public static void AddChild(this Transform t, Transform child){ + child.SetParent(t); + child.localPosition = Vector3.zero; + child.localEulerAngles = Vector3.zero; + child.localScale = Vector3.one; + } + + public static void SetParentKeepState(this Transform t, Transform parent){ + parent.AddChildKeepState(t); + } + public static void AddChildKeepState(this Transform t, Transform child){ + Vector3 position = child.position; + Vector3 angles = child.eulerAngles; + Vector3 scale = child.localScale; + child.SetParent(t); + child.position = position; + child.eulerAngles = angles; + child.localScale = scale; + } + + public static bool FindAllParentsComponent(this Transform t, Action func) { + var parent = t.parent; + if(parent != null){ + var component = parent.GetComponent(); + var result = false; + if(!System.Object.ReferenceEquals(component, null)){ + func(component); + result = true; + } + return parent.FindAllParentsComponent(func) || result; + }else{ + return false; + } + } + public static bool FindParentsComponent(this Transform t, Action func) { + var parent = t.parent; + if(parent != null){ + var component = parent.GetComponent(); + if(!System.Object.ReferenceEquals(component, null)){ + func(component); + return true; + }else{ + return parent.FindParentsComponent(func); + } + }else{ + return false; + } + } + public static bool FindParentByName(this Transform t, string name, Action func){ + var parent = t.parent; + if(parent == null){ + return false; + }else{ + if(parent.name == name){ + func(parent); + return true; + }else{ + return parent.FindParentByName(name, func); + } + } + } + public static bool FindParentByContainsName(this Transform t, string name, Action func){ + var parent = t.parent; + if(parent == null){ + return false; + }else{ + if(parent.name.Contains(name)){ + func(parent); + return true; + }else{ + return parent.FindParentByContainsName(name, func); + } + } + } + /// GetComponentで取得出来ればfuncに渡す + public static bool FindComponent(this Transform t, Action func) { + T component = t.GetComponent(); + if(component is UnityEngine.Object){ + if((component as UnityEngine.Object) != null){ + func(component); + return true; + }else{ + return false; + } + }else{ + if(component != null){ + func(component); + return true; + }else{ + return false; + } + } + } + public static bool FindComponents(this Transform t, Action func){ + var result = false; + var components = t.GetComponents(); + foreach(var component in components){ + if(component is UnityEngine.Object){ + if((component as UnityEngine.Object) != null){ + func(component); + result = true; + } + }else{ + if(component != null){ + func(component); + result = true; + } + } + } + return result; + } + /// 子オブジェクト達の中からGetComponentで最初に取得出来たものだけをfuncに渡す + public static bool FindChildComponent(this Transform t, Action func) { + bool result = false; + for(int i = 0; i < t.childCount; ++i){ + Transform transform = t.GetChild(i); + if(transform.FindComponent(func)){ + result = true; + break; + } + } + return result; + } + /// 子オブジェクト達の中からGetComponentで取得出来たもの全てをfuncに渡す + public static bool FindAllChildComponent(this Transform t, Action func) { + bool result = false; + for(int i = 0; i < t.childCount; ++i){ + Transform transform = t.GetChild(i); + if(transform.FindComponent(func)){ + result = true; + } + } + return result; + } + /// 下階層全てのオブジェクト達の中からGetComponentで最初に取得出来たものだけをfuncに渡す + public static bool FindChildrensComponent(this Transform t, Action func) { + for(int i = 0; i < t.childCount; ++i){ + Transform transform = t.GetChild(i); + if(transform.FindComponent(func)){ + return true; + } + } + for(int i = 0; i < t.childCount; ++i){ + Transform transform = t.GetChild(i); + if(transform.FindChildrensComponent(func)){ + return true; + } + } + return false; + } + /// 下階層全てのオブジェクト達の中からGetComponentで取得出来たもの全てをfuncに渡す + public static bool FindAllChildrensComponent(this Transform t, Action func) { + bool result = false; + for(int i = 0; i < t.childCount; ++i){ + Transform transform = t.GetChild(i); + if(transform.FindComponents(func)){ + result = true; + } + if(transform.FindAllChildrensComponent(func)){ + result = true; + } + } + return result; + } + + /// 子オブジェクト達の中から同じ名前で最初に取得出来たものだけをfuncに渡す + public static bool FindChildByName(this Transform t, string name, Action func){ + bool result = false; + for(int i = 0; i < t.childCount; ++i){ + Transform child = t.GetChild(i); + if(child.name == name){ + func(child); + result = true; + break; + } + } + return result; + } + public static bool FindChildrensByName(this Transform t, string name, Action func){ + for(int i = 0; i < t.childCount; ++i){ + Transform child = t.GetChild(i); + if(child.name == name){ + func(child); + return true; + } + } + for(int i = 0; i < t.childCount; ++i){ + Transform child = t.GetChild(i); + if(child.FindChildrensByName(name, func)){ + return true; + } + } + return false; + } + + public static void AllChildrens(this Transform t, Action func){ + for(int i = 0; i < t.childCount; ++i){ + Transform child = t.GetChild(i); + func(child); + child.AllChildrens(func); + } + } + public static void DestroyAllChildrens(this Transform t){ + while(t.childCount > 0){ + GameObject.DestroyImmediate(t.GetChild(0).gameObject); + } + } + + public static void SetLayer(this Transform t, string layerName){ + t.SetLayer(LayerMask.NameToLayer(layerName)); + } + public static void SetLayer(this Transform t, int layer){ + t.gameObject.layer = layer; + t.AllChildrens(c => { + c.gameObject.layer = layer; + }); + } + + public static Bounds TransformBounds(this Transform t, Bounds bounds) + { + var ret = new Bounds(); + ret.center = t.TransformPoint(bounds.center); + var max = t.TransformPoint(bounds.max); + var size = (max - ret.center) * 2; + ret.size = size; + return ret; + } + public static Bounds InverseTransformBounds(this Transform t, Bounds bounds) + { + var ret = new Bounds(); + ret.center = t.InverseTransformPoint(bounds.center); + var max = t.InverseTransformPoint(bounds.max); + var size = (max - ret.center) * 2; + ret.size = size; + return ret; + } + + public static string GetPath(this Transform t){ + var path = t.gameObject.name; + var parent = t.parent; + while(parent != null){ + path = parent.name + "/" + path; + parent = parent.parent; + } + return path; + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/TransformExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/TransformExtensions.cs.meta new file mode 100644 index 00000000..d3ce505f --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/TransformExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 910f6874bfce640908e0cc769898e5d9 +timeCreated: 1447677936 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/VectorExtensions.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/VectorExtensions.cs new file mode 100644 index 00000000..1aa72c1e --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/VectorExtensions.cs @@ -0,0 +1,263 @@ +using UnityEngine; + +public static class Vector3Extensions { + + public static readonly Vector3 upright = new Vector3(0.85090352f, 0.85090352f, 0.0f); + public static readonly Vector3 upleft = new Vector3(-0.85090352f, 0.85090352f, 0.0f); + public static readonly Vector3 downright = new Vector3(0.85090352f, -0.85090352f, 0.0f); + public static readonly Vector3 downleft = new Vector3(-0.85090352f, -0.85090352f, 0.0f); + + public static Vector2 ToVector2XZ(this Vector3 v){ + return new Vector2(v.x, v.z); + } + + public static Vector2 ToVector2(this Vector3 v){ + return v; + } + + public static float ForwardToTargetPositionXZAngle(this Vector3 position, Vector3 forward, Vector3 targetPosition){ + return position.ForwardToTargetPositionXZAngle(forward.ToVector2XZ(), targetPosition); + } + public static float ForwardToTargetPositionXZAngle(this Vector3 position, Vector2 forward, Vector3 targetPosition){ + Vector2 t = (targetPosition - position).ToVector2XZ().normalized; + Vector2 f = forward.normalized; + return Mathf.Atan2(t.Cross(f), t.Dot(f)) * Mathf.Rad2Deg; + } + public static float ForwardToVectorXZAngle(this Vector3 forward, Vector3 vector){ + return ForwardToVectorXZAngle(forward.ToVector2XZ(), vector); + } + public static float ForwardToVectorXZAngle(this Vector2 forward, Vector3 vector){ + Vector2 t = vector.ToVector2XZ().normalized; + Vector2 f = forward.normalized; + return Mathf.Atan2(t.Cross(f), t.Dot(f)) * Mathf.Rad2Deg; + } + + public static Vector3 Center(this Vector3 v1, Vector3 v2){ + return v1 + (v2 - v1) * 0.5f; + } + + public static float MagnitudeNotSqrt(this Vector3 v){ + return v.x * v.x + v.y * v.y + v.z * v.z; + } + + public static bool NearCheckX(this Vector3 v1, Vector3 v2, float max){ + return (v1.x - v2.x) * (v1.x - v2.x) <= max * max; + } + public static bool NearCheckY(this Vector3 v1, Vector3 v2, float max){ + return (v1.y - v2.y) * (v1.y - v2.y) <= max * max; + } + public static bool NearCheckZ(this Vector3 v1, Vector3 v2, float max){ + return (v1.z - v2.z) * (v1.z - v2.z) <= max * max; + } + public static bool NearCheck(this Vector3 v1, Vector3 v2, float max){ + return (v1 - v2).MagnitudeNotSqrt() <= max * max; + } + public static bool NearCheck(this Vector3 v1, Vector3 v2, float min, float max){ + float dist = (v1 - v2).MagnitudeNotSqrt(); + return dist >= min * min && dist <= max * max; + } + + public static Vector3 Mul(this Vector3 v1, Vector3 v2){ + return Vector3.Scale(v1, v2); + } + + public static Vector3 Div(this Vector3 v1, Vector3 v2){ + return new Vector3(v1.x / v2.x, v1.y / v2.y, v1.z / v2.z); + } + + public static Vector3 Rotate(this Vector3 v, Vector3 eulerAngles){ + Vector3 z = v.RotateZDeg(eulerAngles.z); + Vector3 x = z.RotateXDeg(eulerAngles.x); + return x.RotateYDeg(eulerAngles.y); + } + + public static Vector3 RotateXDeg(this Vector3 v, float angle){ + return v.RotateXRad(angle * Mathf.Deg2Rad); + } + public static Vector3 RotateXRad(this Vector3 v, float angle){ + Vector3 result = v; + float cos = Mathf.Cos(angle); + float sin = Mathf.Sin(angle); + result.y = v.y * cos - v.z * sin; + result.z = v.y * sin + v.z * cos; + return result; + } + + public static Vector3 RotateYDeg(this Vector3 v, float angle){ + return v.RotateYRad(angle * Mathf.Deg2Rad); + } + public static Vector3 RotateYRad(this Vector3 v, float angle){ + Vector3 result = v; + float cos = Mathf.Cos(angle); + float sin = Mathf.Sin(angle); + result.z = v.z * cos - v.x * sin; + result.x = v.z * sin + v.x * cos; + return result; + } + + public static Vector3 RotateZDeg(this Vector3 v, float angle){ + return v.RotateZRad(angle * Mathf.Deg2Rad); + } + public static Vector3 RotateZRad(this Vector3 v, float angle){ + Vector3 result = v; + float cos = Mathf.Cos(angle); + float sin = Mathf.Sin(angle); + result.x = v.x * cos - v.y * sin; + result.y = v.x * sin + v.y * cos; + return result; + } + + public static Vector3 FixIfNaN(this Vector3 v){ + if(float.IsNaN(v.x)){ + v.x = 0; + } + if(float.IsNaN(v.y)){ + v.y = 0; + } + if(float.IsNaN(v.z)){ + v.z = 0; + } + return v; + } + + public static Vector3 SetX(this Vector3 v, float f){ + v.x = f; + return v; + } + public static Vector3 SetY(this Vector3 v, float f){ + v.y = f; + return v; + } + public static Vector3 SetZ(this Vector3 v, float f){ + v.z = f; + return v; + } + public static Vector3 AddX(this Vector3 v, float f){ + v.x += f; + return v; + } + public static Vector3 AddY(this Vector3 v, float f){ + v.y += f; + return v; + } + public static Vector3 AddZ(this Vector3 v, float f){ + v.z += f; + return v; + } + public static Vector3 MulX(this Vector3 v, float f){ + return v.SetX(v.x * f); + } + public static Vector3 MulY(this Vector3 v, float f){ + return v.SetY(v.y * f); + } + public static Vector3 MulZ(this Vector3 v, float f){ + return v.SetZ(v.z * f); + } + + public static Vector3 Min(this Vector3 v1, Vector3 v2){ + if(v1.MagnitudeNotSqrt() < v2.MagnitudeNotSqrt()){ + return v1; + }else{ + return v2; + } + } + public static Vector3 Max(this Vector3 v1, Vector3 v2){ + if(v1.MagnitudeNotSqrt() > v2.MagnitudeNotSqrt()){ + return v1; + }else{ + return v2; + } + } + + public static Vector3 Round (this Vector3 v1 , Vector3 v2){ + v1.x = Mathf.Round(v1.x + v2.x); + v1.y = Mathf.Round(v1.y + v2.y); + v1.z = Mathf.Round(v1.z + v2.z); + return v1; + } + + public static Vector3 RandomInsideCone(this Vector3 v, Transform t, float conicAngle){ + return v.RandomInsideCone(t.up, t.forward, conicAngle); + } + public static Vector3 RandomInsideCone(this Vector3 v, Vector3 up, Vector3 forward, float conicAngle){ + return Quaternion.AngleAxis(Random.Range(0f, 360f), forward) * Quaternion.AngleAxis(Random.Range(0f, conicAngle), up) * v; + } +} + +public static class Vector2Extensions { + + public static Vector3 ToVector3XZ(this Vector2 v){ + return new Vector3(v.x, 0.0f, v.y); + } + + public static float Dot(this Vector2 v1, Vector2 v2){ + return v1.x * v2.x + v1.y * v2.y; + } + + public static float Cross(this Vector2 v1, Vector2 v2){ + return v1.x * v2.y - v1.y * v2.x; + } + + public static Vector2 RandomRotateDeg(this Vector2 v, float randomAngle){ + return v.RandomRotateRad(randomAngle * Mathf.Deg2Rad); + } + public static Vector2 RotateDeg(this Vector2 v, float angle){ + return v.RotateRad(angle * Mathf.Deg2Rad); + } + public static Vector2 RandomRotateRad(this Vector2 v, float randomAngle){ + return v.RotateRad(UnityEngine.Random.Range(-randomAngle, randomAngle)); + } + public static Vector2 RotateRad(this Vector2 v, float angle){ + return new Vector2( + v.x * Mathf.Cos(angle) - v.y * Mathf.Sin(angle), + v.x * Mathf.Sin(angle) + v.y * Mathf.Cos(angle) + ); + } + + public static float ForwardToTargetPositionAngle(this Vector2 position, Vector2 forward, Vector2 targetPosition){ + return forward.TargetAngle(targetPosition - position); + } + + public static float TargetAngle(this Vector2 vector, Vector2 targetVector){ + Vector2 t = targetVector.normalized; + Vector2 f = vector.normalized; + return Mathf.Atan2(t.Cross(f), t.Dot(f)) * Mathf.Rad2Deg; + } + + public static float MagnitudeNotSqrt(this Vector2 v){ + return v.x * v.x + v.y * v.y; + } + public static bool NearCheck(this Vector2 v1, Vector2 v2, float max){ + return (v1 - v2).MagnitudeNotSqrt() <= max * max; + } + public static Vector2 SetX(this Vector2 v, float f){ + v.x = f; + return v; + } + public static Vector2 SetY(this Vector2 v, float f){ + v.y = f; + return v; + } + + public static Vector2 AddX(this Vector2 v, float f){ + v.x += f; + return v; + } + public static Vector2 AddY(this Vector2 v, float f){ + v.y += f; + return v; + } + public static Vector2 Add(this Vector2 v, float f){ + v.x += f; + v.y += f; + return v; + } + + public static Vector2 Mul(this Vector2 v1, Vector2 v2){ + return Vector2.Scale(v1, v2); + } + + public static Vector2 Div(this Vector2 v1, Vector2 v2){ + return new Vector2(v1.x / v2.x, v1.y / v2.y); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/VectorExtensions.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/VectorExtensions.cs.meta new file mode 100644 index 00000000..440ddbda --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Extensions/VectorExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e96205ac7d2184232af37793ece2bd31 +timeCreated: 1447677940 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/InitializeUnityEditorChecker.cs b/popcorn/Assets/USAYAUnityLib/Scripts/InitializeUnityEditorChecker.cs new file mode 100644 index 00000000..d9233eef --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/InitializeUnityEditorChecker.cs @@ -0,0 +1,18 @@ +using UnityEngine; + +public sealed class InitializeUnityEditorChecker : MonoBehaviour { + + [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] + static void Initialize(){ +#if UNITY_EDITOR + if(Application.unityVersion != Const.UnityVersion){ + Debug.LogError("現在開いているUnityのVersionが " + Const.UnityVersion + " ではない為停止します。UnityのVersionは必ず合わせて下さい。"); + UnityEditor.EditorApplication.isPlaying = false; + } + + var unityChecker = new GameObject("UnityChecker"); + DontDestroyOnLoad(unityChecker); + unityChecker.AddComponent(); +#endif + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/InitializeUnityEditorChecker.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/InitializeUnityEditorChecker.cs.meta new file mode 100644 index 00000000..9a4c61f6 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/InitializeUnityEditorChecker.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d9e7f64b6552748b980dc0f65955fca0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Managers.meta new file mode 100644 index 00000000..4306e72c --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1615079ca59554b4491a8d16a0650920 +folderAsset: yes +timeCreated: 1447677936 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/AssetBundleManager.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/AssetBundleManager.cs new file mode 100644 index 00000000..b7a4ecb2 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/AssetBundleManager.cs @@ -0,0 +1,63 @@ +using UnityEngine; +using System; + +public class AssetLoader { +#if UNITY_EDITOR + private string assetBundleName; + public AssetLoader(string assetBundleName){ + this.assetBundleName = assetBundleName.ToLower(); + } + + public T LoadAsset(string assetName) where T : UnityEngine.Object { + string[] assetPaths = UnityEditor.AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(assetBundleName.ToLower(), assetName); + if(assetPaths.Length > 0){ + return UnityEditor.AssetDatabase.LoadAssetAtPath(assetPaths[0]); + }else{ + return null; + } + } + +#elif UNITY_ANDROID + private string assetBundleName; + public AssetLoader(string assetBundleName){ + this.assetBundleName = assetBundleName; + } + + public T LoadAsset(string assetName) where T : UnityEngine.Object { + return Resources.Load(string.Format("AssetBundle/{0}/{1}", assetBundleName, assetName)); + } + +#elif UNITY_IOS + private AssetBundle assetBundle; + public AssetLoader(AssetBundle assetBundle){ + this.assetBundle = assetBundle; + } + + public T LoadAsset(string assetName) where T : UnityEngine.Object { + if(assetBundle.Contains(assetName)){ + return assetBundle.LoadAsset(assetName); + }else{ + return null; + } + } +#endif + +} + +public class AssetBundleManager : SingletonMonoBehaviour { + + void Awake(){ + if(CheckInstance()) return ; + } + + public void LoadAsset(string assetBundleName, Action action){ +#if UNITY_EDITOR || UNITY_ANDROID + action(new AssetLoader(assetBundleName)); +#elif UNITY_IOS + string path = Application.streamingAssetsPath + "/iOS/" + assetBundleName.ToLower(); + AssetBundle assetBundle = AssetBundle.LoadFromFile(path); + action(new AssetLoader(assetBundle)); + assetBundle.Unload(false); +#endif + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/AssetBundleManager.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/AssetBundleManager.cs.meta new file mode 100644 index 00000000..ac5a8daa --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/AssetBundleManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b3337f0f7c1794ac0a164e80175b718a +timeCreated: 1459401657 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/DataManager.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/DataManager.cs new file mode 100644 index 00000000..5631388f --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/DataManager.cs @@ -0,0 +1,99 @@ +#if OLD_STORAGE +using System; +using System.Runtime.InteropServices; +using UnityEngine; + +/// 古いのでMyStorageManagerを使用して下さい +public static class DataManager { + + private static readonly string defaultFilename = "SaveData"; + + public static void Save(string tag, object value){ + Save(defaultFilename, tag, value); + } + public static void Save(string filename, string tag, object value){ + string key = string.Format("{0}?tag={1}", filename, tag); + ES2.Save(value, key); + PlayerPrefs.Save(); + } + + public static T LoadOrDefault(string tag, T defaultValue){ + if(Exists(tag)){ + return Load(tag); + }else{ + return defaultValue; + } + } + public static T Load(string tag){ + return Load(defaultFilename, tag); + } + public static T Load(string filename, string tag){ + string key = string.Format("{0}?tag={1}", filename, tag); + return ES2.Load(key); + } + + public static bool Exists(string tag){ + return Exists(defaultFilename, tag); + } + public static bool Exists(string filename, string tag){ + string key = string.Format("{0}?tag={1}", filename, tag); + return ES2.Exists(key); + } + + public static void Remove(string tag){ + Remove(defaultFilename, tag); + } + public static void Remove(string filename, string tag){ + if(!Exists(filename, tag)) return ; + string key = string.Format("{0}?tag={1}", filename, tag); + ES2.Delete(key); + PlayerPrefs.Save(); + } + + + public static void SaveAndBackup(string tag, string value){ + SaveAndBackup(defaultFilename, tag, value); + } + public static void SaveAndBackup(string filename, string tag, string value){ + string key = string.Format("{0}?tag={1}", filename, tag); + ES2.Save(value, key); + PlayerPrefs.SetString(key, value); + PlayerPrefs.Save(); + } + + public static bool ExistsBackup(string tag){ + return ExistsBackup(defaultFilename, tag); + } + public static bool ExistsBackup(string filename, string tag){ + string key = string.Format("{0}?tag={1}", filename, tag); + return PlayerPrefs.HasKey(key); + } + + public static string LoadBackupOrDefault(string tag, string defaultValue){ + if(ExistsBackup(tag)){ + return LoadBackup(tag); + }else{ + return defaultValue; + } + } + public static string LoadBackup(string tag){ + return LoadBackup(defaultFilename, tag); + } + public static string LoadBackup(string filename, string tag){ + string key = string.Format("{0}?tag={1}", filename, tag); + return PlayerPrefs.GetString(key); + } + + public static void IsDiskFull(Exception ex, Func getDiskFullMessage){ + const int ERROR_HANDLE_DISK_FULL = 0x27; + const int ERROR_DISK_FULL = 0x70; + + int errorCode = Marshal.GetHRForException(ex) & 0xFFFF; + if(errorCode == ERROR_HANDLE_DISK_FULL || errorCode == ERROR_DISK_FULL){ + NativeUtils.ShowAlert(ex.Message, getDiskFullMessage()); + }else{ + throw ex; + } + } +} +#endif diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/DataManager.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/DataManager.cs.meta new file mode 100644 index 00000000..5486fd01 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/DataManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 05550248d22cf439d8dbb97bfa9c2400 +timeCreated: 1475661783 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/FadeManager.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/FadeManager.cs new file mode 100644 index 00000000..caed11d4 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/FadeManager.cs @@ -0,0 +1,102 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.SceneManagement; +using UnityEngine.Serialization; +using System; + +public class FadeManager : SingletonMonoBehaviour { + + [SerializeField, FormerlySerializedAs("fadeIn")] + private bool isAutoFadeIn = true; + public Color fadeColor = Color.black; + public UnityEvent onFadeInEnd; + public UnityEvent onFadeOutEnd; + + private Texture2D texture; + private float fadeAlpha = 0.0f; + private bool isFading = false; + public bool IsFading{ + get{ return isFading; } + } + private float timer = 0.0f; + private Action fadeFunc = ActionExtensions.EmptyActionFloat; + + void Awake(){ + if(CheckInstance()) return ; + + if(isAutoFadeIn){ + isFading = true; + fadeAlpha = 1.0f; + this.CallWaitForFrame(2, () => FadeIn(0.5f)); + } + + texture = new Texture2D(2, 2, TextureFormat.ARGB32, false); + texture.SetPixel(0, 0, Color.white); + texture.SetPixel(0, 1, Color.white); + texture.SetPixel(1, 0, Color.white); + texture.SetPixel(1, 1, Color.white); + texture.Apply(); + } + + void OnGUI(){ + if(isFading){ + timer += Time.unscaledDeltaTime; + fadeFunc(timer); + fadeColor.a = fadeAlpha; + } + if(fadeAlpha > 0.0f){ + DrawTexture(fadeColor); + } + } + + // alpha 1 to 0 + public void FadeIn(float interval = 1.0f){ + FadeIn(interval, ActionExtensions.EmptyAction); + } + public void FadeIn(float interval, Action callback){ + isFading = true; + timer = 0.0f; + fadeFunc = (t) => { + fadeAlpha = Mathf.Lerp (1.0f, 0.0f, t / interval); + if(t >= interval){ + isFading = false; + onFadeInEnd.Invoke(); + callback(); + } + }; + } + + // alpha 0 to 1 + public void FadeOut(float interval, Action callback){ + FadeOut(interval, callback, fadeColor); + } + public void FadeOut(float interval, Action callback, Color color){ + fadeColor = color; + isFading = true; + timer = 0.0f; + fadeFunc = (t) => { + fadeAlpha = Mathf.Lerp (0.0f, 1.0f, t / interval); + if(t >= interval){ + isFading = false; + onFadeOutEnd.Invoke(); + callback(); + } + }; + } + + private void DrawTexture(Color color){ + GUI.color = color; + GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), texture); + } + + public void FadeOutToTransition(float interval, string sceneName){ + FadeOut(interval, () => SceneManager.LoadScene(sceneName)); + } + + public void Show(){ + fadeAlpha = 1.0f; + } + public void Hide(){ + fadeAlpha = 0.0f; + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/FadeManager.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/FadeManager.cs.meta new file mode 100644 index 00000000..08f28fc0 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/FadeManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6bf0dacc5aa1f47f88665ce53dbb2b73 +timeCreated: 1447677936 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/LocalCacheManager.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/LocalCacheManager.cs new file mode 100644 index 00000000..25fd3c94 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/LocalCacheManager.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; + +public static class LocalCacheManager { + + private static Dictionary dictionary = new Dictionary(); + + public static void Save(string tag, object value){ + dictionary[tag] = value; + } + + public static T Load(string tag, T defaultValue){ + if(Exists(tag)){ + return Load(tag); + }else{ + return defaultValue; + } + } + public static T Load(string tag){ + return (T)dictionary[tag]; + } + + public static bool Exists(string tag){ + return dictionary.ContainsKey(tag); + } + + public static bool Remove(string tag){ + return dictionary.Remove(tag); + } + + public static void Clear(){ + dictionary.Clear(); + } +} \ No newline at end of file diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/LocalCacheManager.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/LocalCacheManager.cs.meta new file mode 100644 index 00000000..c37ac35b --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/LocalCacheManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1f95d9bd3e1d049f6ab5971a5ea713a4 +timeCreated: 1453883978 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/ScreenShotManager.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/ScreenShotManager.cs new file mode 100644 index 00000000..e1841d91 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/ScreenShotManager.cs @@ -0,0 +1,95 @@ +using UnityEngine; +using System; +using System.Collections; + +public class ScreenShotManager : SingletonMonoBehaviour { + + [SerializeField] + private Texture2D defaultScreenShotTexture = default; + + public string shareImageFileName = "ScreenShot.png"; + public string ImagePath { + get{ return string.Format("{0}/{1}", Application.persistentDataPath, shareImageFileName); } + } + +#if !UNITY_EDITOR + public bool ExistsScreenShot{ + get{ return System.IO.File.Exists(ImagePath); } + } +#else + private Texture2D texture; + public bool ExistsScreenShot{ + get{ return texture != null; } + } +#endif + + void Awake(){ + if(CheckInstance()) return ; + } + + public void CaptureScreenShot(Action justBeforeAction, Action justAfterAction, Action callback){ + StartCoroutine(_CaptureScreenShot(justBeforeAction, justAfterAction, callback)); + } + private IEnumerator _CaptureScreenShot(Action justBeforeAction, Action justAfterAction, Action callback){ +#if !UNITY_EDITOR + string imagePath = ImagePath; + if(ExistsScreenShot){ + System.IO.File.Delete(imagePath); + } + yield return null; + justBeforeAction(); + yield return new WaitForEndOfFrame(); + ScreenCapture.CaptureScreenshot(shareImageFileName); + yield return null; + justAfterAction(); + + yield return new WaitUntil(() => { return System.IO.File.Exists(imagePath); }); +#else + yield return null; + justBeforeAction(); + yield return new WaitForEndOfFrame(); + texture = new Texture2D(Screen.width, Screen.height); + texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0); + texture.Apply(); + yield return null; + justAfterAction(); +#endif + callback(); + } + + public Texture2D GetTexture(){ + try{ +#if !UNITY_EDITOR + byte[] image = System.IO.File.ReadAllBytes(ImagePath); + Texture2D texture = new Texture2D(0, 0); + texture.LoadImage(image); +#endif + if(texture.isBogus()){ + return defaultScreenShotTexture; + }else{ + return texture; + } + }catch(Exception){ + return defaultScreenShotTexture; + } + } + + public Sprite GetSprite(){ + return GetTexture().ToSprite(); + } + + public void ShareTwitter(string message, Action callback){ +#if UNITY_IOS + ShareManager.Instance.ShareTwitter(message, GetTexture(), callback); +#else + ShareManager.Instance.ShareTwitter(message, ImagePath, callback); +#endif + } + public void ShareFacebook(string message, Action callback){ +#if UNITY_IOS + ShareManager.Instance.ShareFacebook(message, GetTexture(), callback); +#else + ShareManager.Instance.ShareFacebook(message, ImagePath, callback); +#endif + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/ScreenShotManager.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/ScreenShotManager.cs.meta new file mode 100644 index 00000000..8a767cd6 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/ScreenShotManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a42fdcb3a3bf04627af1394c8af1b4ef +timeCreated: 1472209398 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/ShareManager.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/ShareManager.cs new file mode 100644 index 00000000..818e51ee --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/ShareManager.cs @@ -0,0 +1,233 @@ +using System; +using UnityEngine; +#if !UNITY_EDITOR +#if UNITY_IOS +using System.Runtime.InteropServices; +#else +using System.IO; +#endif +#endif + +// 使用方法 +// ShareManagerという名前のオブジェクトに下記コンポーネントをアタッチしてShare~~を呼び出す +public class ShareManager : SingletonMonoBehaviour { + +#if !UNITY_EDITOR + private Action callback; +#if UNITY_IOS +#else + private string TexturePath = ""; + + private AndroidJavaObject worker = null; +#endif +#endif + + + void Awake(){ + if(CheckInstance()) return ; +#if !UNITY_EDITOR +#if UNITY_IOS +#else + TexturePath = Application.persistentDataPath + "/SNSTexture.png"; + worker = new AndroidJavaObject("jp.usaya.lib.UsayaUnityPlayerActivity"); +#endif +#endif + } + + public void ShareTwitter(string message, Texture2D texture, Action callback){ +#if !UNITY_EDITOR + this.callback = callback; +#if UNITY_IOS + if(NativeUtils.GetiOSMajorVersion() >= 11){ + if(NativeUtils.canOpenTwitter()){ + callback(true); + PostTwitter(message, texture); + }else{ + callback(false); + } + this.callback = ActionExtensions.EmptyActionBool; + }else{ + PostTwitter(message, texture); + } +#else + SaveTexture(texture, TexturePath); + PostTwitter(message, TexturePath); +#endif +#else + callback(true); +#endif + } +#if UNITY_ANDROID + public void ShareTwitter(string message, string path, Action callback){ +#if !UNITY_EDITOR + this.callback = callback; + PostTwitter(message, path); +#else + callback(true); +#endif + } +#endif + + public void ShareFacebook(string message, Texture2D texture, Action callback){ +#if !UNITY_EDITOR + this.callback = callback; +#if UNITY_IOS + if(NativeUtils.GetiOSMajorVersion() >= 11){ + if(NativeUtils.canOpenFacebook()){ + callback(true); + PostFacebook(message, texture); + }else{ + callback(false); + } + this.callback = ActionExtensions.EmptyActionBool; + }else{ + PostFacebook(message, texture); + } +#else + SaveTexture(texture, TexturePath); + PostFacebook(TexturePath); +#endif +#else + callback(true); +#endif + } +#if UNITY_ANDROID + public void ShareFacebook(string message, string path, Action callback){ +#if !UNITY_EDITOR + this.callback = callback; + PostFacebook(path); +#else + callback(true); +#endif + } +#endif + +#region iOS +#if (UNITY_IOS && !UNITY_EDITOR) +/* + public static void WhatsappShare(string message, Texture2D texture){ + if(texture == null){ + Instance.WhatsAppShareText(message); + }else{ + Instance.WhatsAppShareImage(texture); + } + } +*/ + [DllImport("__Internal")] + private static extern void _MSP_TwPost(string text, string url, string encodedMedia); + + [DllImport("__Internal")] + private static extern void _MSP_FbPost(string text, string url, string encodedMedia); +/* + [DllImport("__Internal")] + private static extern void _MSP_MediaShare(string text, string encodedMedia); + + [DllImport("__Internal")] + private static extern void _ISN_WP_ShareText(string message); + + [DllImport("__Internal")] + private static extern void _ISN_WP_ShareMedia(string encodedMedia); + + public void ShareMedia(string text, Texture2D texture){ + if(texture != null){ + byte[] val = texture.EncodeToPNG(); + string bytesString = System.Convert.ToBase64String(val); + _MSP_MediaShare(text, bytesString); + }else{ + _MSP_MediaShare(text, ""); + } + } +*/ + + private void PostTwitter(string text, Texture2D texture){ + if(text == null) text = ""; + + if(texture != null){ + byte[] val = texture.EncodeToPNG(); + string encodedMedia = System.Convert.ToBase64String(val); + _MSP_TwPost(text, "", encodedMedia); + }else{ + _MSP_TwPost(text, "", ""); + } + } + + private void PostFacebook(string text, Texture2D texture){ + if(text == null) text = ""; + + if(texture != null){ + byte[] val = texture.EncodeToPNG(); + string encodedMedia = System.Convert.ToBase64String(val); + _MSP_FbPost(text, "", encodedMedia); + }else{ + _MSP_FbPost(text, "", ""); + } + } +/* + private void WhatsAppShareText(string message){ + _ISN_WP_ShareText(message); + } + private void WhatsAppShareImage(Texture2D texture){ + byte[] val = texture.EncodeToPNG(); + string bytesString = System.Convert.ToBase64String(val); + + _ISN_WP_ShareMedia(bytesString); + } +*/ + + // callbacks + private void OnTwitterPostFailed(){ + callback(false); + } + private void OnTwitterPostSuccess(){ + callback(true); + } + private void OnFacebookPostFailed(){ + callback(false); + } + private void OnFacebookPostSuccess(){ + callback(true); + } +#endif +#endregion + +#region Android +#if (UNITY_ANDROID && !UNITY_EDITOR) + + private void SaveTexture(Texture2D texture, string path){ + using(FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.Write)){ + using(BinaryWriter writer = new BinaryWriter(fileStream)){ + writer.Write(texture.EncodeToPNG()); + } + } + } + + private void PostTwitter(string message, string imagePath){ + if(message == null)message = ""; + if(imagePath == null)imagePath = ""; + worker.Call("postTwitterOrFacebook", true, message, "", imagePath); + } + + private void PostFacebook(string imagePath){ + if(imagePath == null)imagePath = ""; + worker.Call("postTwitterOrFacebook", false, "", "", imagePath); + } + + private void CreateChooser(string message, string imagePath){ + if(message == null)message = ""; + if(imagePath == null)imagePath = ""; + worker.Call("createChooser", message, imagePath); + } + + private void OnShareManagerResult(string result){ + switch(result){ + case "0": + callback(true); + break; + default: + callback(false); + break; + } + } +#endif +#endregion +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/ShareManager.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/ShareManager.cs.meta new file mode 100644 index 00000000..123ab470 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/ShareManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f5738e7868b224a0190dc3a1ce77e440 +timeCreated: 1505292700 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/SoundManager.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/SoundManager.cs new file mode 100644 index 00000000..73c12cd6 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/SoundManager.cs @@ -0,0 +1,574 @@ +using UnityEngine; +using UnityEngine.Audio; +using System; +using System.Collections; +using System.Collections.Generic; + +public enum SoundType{ + BGM, + SE, + Voice, +} +public class SoundManager : SingletonMonoBehaviour { + + private string bgmFilePath = ""; + private AudioSource bgmSource = null; + private float uniqueBGMVolume; + public float UniqueBGMVolume { + get{ return uniqueBGMVolume; } + } + private List seSourceList = new List(); + private Dictionary seLoopSourceDic = new Dictionary(); + private List voiceSourceList = new List(); + + public AudioMixerGroup defaultBGMAudioMixer; + public AudioMixerGroup defaultSEAudioMixer; + public AudioMixerGroup defaultVoiceAudioMixer; + public float bgmVolume = 1.0f; + public float seVolume = 1.0f; + public float voiceVolume = 1.0f; + public float pauseTime = 0.0f; + public float GetVolume(SoundType soundType){ + switch(soundType){ + case SoundType.BGM: + return bgmVolume; + case SoundType.Voice: + return voiceVolume; + default: + return seVolume; + } + } + + [SerializeField] + private bool enabledBGM = true; + [SerializeField] + private bool enabledSE = true; + [SerializeField] + private bool enabledVoice = true; + public void EnabledSound(SoundType soundType, bool enabled){ + switch(soundType){ + case SoundType.BGM: + enabledBGM = enabled; + break; + case SoundType.Voice: + enabledVoice = enabled; + break; + default: + enabledSE = enabled; + break; + } + } + public bool IsEnabled(SoundType soundType){ + switch(soundType){ + case SoundType.BGM: + return enabledBGM; + case SoundType.Voice: + return enabledVoice; + default: + return enabledSE; + } + } + + + void Awake(){ + if(CheckInstance()){ + return; + } +#if !OLD_STORAGE + enabledBGM = UsayaStorageManager.LoadOrDefault(UsayaStorageFilename.Settings_Data, "EnabledBGM", true); + enabledSE = UsayaStorageManager.LoadOrDefault(UsayaStorageFilename.Settings_Data, "EnabledSE", true); + enabledVoice = UsayaStorageManager.LoadOrDefault(UsayaStorageFilename.Settings_Data, "EnabledVoice", true); + + bgmVolume = UsayaStorageManager.LoadOrDefault(UsayaStorageFilename.Settings_Data, "VolumeBGM", bgmVolume); + seVolume = UsayaStorageManager.LoadOrDefault(UsayaStorageFilename.Settings_Data, "VolumeSE", seVolume); + voiceVolume = UsayaStorageManager.LoadOrDefault(UsayaStorageFilename.Settings_Data, "VolumeVoice", voiceVolume); +#else + if(UsayaStorageManager.Exists(UsayaStorageFilename.Settings_Data, "EnabledBGM")){ + enabledBGM = UsayaStorageManager.Load(UsayaStorageFilename.Settings_Data, "EnabledBGM"); + }else{ + try{ + if(StorageManager.Exists(StorageFilename.SettingsData, "EnabledBGM")){ + enabledBGM = StorageManager.Load(StorageFilename.SettingsData, "EnabledBGM"); + }else{ + enabledBGM = DataManager.LoadOrDefault("EnabledBGM", true); + } + }catch{ + enabledBGM = DataManager.LoadOrDefault("EnabledBGM", true); + } + } + if(UsayaStorageManager.Exists(UsayaStorageFilename.Settings_Data, "EnabledSE")){ + enabledSE = UsayaStorageManager.Load(UsayaStorageFilename.Settings_Data, "EnabledSE"); + }else{ + try{ + if(StorageManager.Exists(StorageFilename.SettingsData, "EnabledSE")){ + enabledSE = StorageManager.Load(StorageFilename.SettingsData, "EnabledSE"); + }else{ + enabledSE = DataManager.LoadOrDefault("EnabledSE", true); + } + }catch{ + enabledSE = DataManager.LoadOrDefault("EnabledSE", true); + } + } + if(UsayaStorageManager.Exists(UsayaStorageFilename.Settings_Data, "EnabledVoice")){ + enabledVoice = UsayaStorageManager.Load(UsayaStorageFilename.Settings_Data, "EnabledVoice"); + }else{ + try{ + if(StorageManager.Exists(StorageFilename.SettingsData, "EnabledVoice")){ + enabledVoice = StorageManager.Load(StorageFilename.SettingsData, "EnabledVoice"); + }else{ + enabledVoice = DataManager.LoadOrDefault("EnabledVoice", true); + } + }catch{ + enabledVoice = DataManager.LoadOrDefault("EnabledVoice", true); + } + } + + if(UsayaStorageManager.Exists(UsayaStorageFilename.Settings_Data, "VolumeBGM")){ + bgmVolume = UsayaStorageManager.Load(UsayaStorageFilename.Settings_Data, "VolumeBGM"); + }else{ + try{ + if(StorageManager.Exists(StorageFilename.SettingsData, "VolumeBGM")){ + bgmVolume = StorageManager.Load(StorageFilename.SettingsData, "VolumeBGM"); + }else{ + bgmVolume = DataManager.LoadOrDefault("VolumeBGM", bgmVolume); + } + }catch{ + bgmVolume = DataManager.LoadOrDefault("VolumeBGM", bgmVolume); + } + } + if(UsayaStorageManager.Exists(UsayaStorageFilename.Settings_Data, "VolumeSE")){ + seVolume = UsayaStorageManager.Load(UsayaStorageFilename.Settings_Data, "VolumeSE"); + }else{ + try{ + if(StorageManager.Exists(StorageFilename.SettingsData, "VolumeSE")){ + seVolume = StorageManager.Load(StorageFilename.SettingsData, "VolumeSE"); + }else{ + seVolume = DataManager.LoadOrDefault("VolumeSE", seVolume); + } + }catch{ + seVolume = DataManager.LoadOrDefault("VolumeSE", seVolume); + } + } + if(UsayaStorageManager.Exists(UsayaStorageFilename.Settings_Data, "VolumeVoice")){ + voiceVolume = UsayaStorageManager.Load(UsayaStorageFilename.Settings_Data, "VolumeVoice"); + }else{ + try{ + if(StorageManager.Exists(StorageFilename.SettingsData, "VolumeVoice")){ + voiceVolume = StorageManager.Load(StorageFilename.SettingsData, "VolumeVoice"); + }else{ + voiceVolume = DataManager.LoadOrDefault("VolumeVoice", voiceVolume); + } + }catch{ + voiceVolume = DataManager.LoadOrDefault("VolumeVoice", voiceVolume); + } + } +#endif + } + public void SaveEnabledBGM(bool enabled){ + UsayaStorageManager.Save(UsayaStorageFilename.Settings_Data, "EnabledBGM", enabled); + enabledBGM = enabled; + if(bgmSource != null){ + bgmSource.mute = !enabledBGM; + } + } + public void SaveEnabledSE(bool enabled){ + UsayaStorageManager.Save(UsayaStorageFilename.Settings_Data, "EnabledSE", enabled); + enabledSE = enabled; + seSourceList.ForEach(se => se.ChangeMute(!enabledSE)); + } + + public void SaveVolumeBGM(){ + SaveVolumeBGM(bgmVolume); + } + public void SaveVolumeBGM(float volume){ + UsayaStorageManager.Save(UsayaStorageFilename.Settings_Data, "VolumeBGM", volume); + ChangeVolumeBGM(volume); + } + public void ChangeVolumeBGM(float volume){ + bgmVolume = volume; + if(bgmSource != null){ + bgmSource.volume = uniqueBGMVolume * volume; + bgmSource.mute = bgmSource.volume <= 0.0f; + } + } + public void ChangeVolumeUniqueBGM(float volume){ + uniqueBGMVolume = volume; + if(bgmSource != null){ + bgmSource.volume = uniqueBGMVolume * bgmVolume; + } + } + public void SaveVolumeSE(){ + SaveVolumeSE(seVolume); + } + public void SaveVolumeSE(float volume){ + UsayaStorageManager.Save(UsayaStorageFilename.Settings_Data, "VolumeSE", volume); + ChangeVolumeSE(volume); + } + public void ChangeVolumeSE(float volume){ + seVolume = volume; + seSourceList.ForEach(se => se.ChangeVolume(volume)); + foreach(KeyValuePair pair in seLoopSourceDic){ + pair.Value.ChangeVolume(volume); + } + } + public void SaveVolumeVoice(){ + SaveVolumeVoice(voiceVolume); + } + public void SaveVolumeVoice(float volume){ + UsayaStorageManager.Save(UsayaStorageFilename.Settings_Data, "VolumeVoice", volume); + ChangeVolumeVoice(volume); + } + public void ChangeVolumeVoice(float volume){ + voiceVolume = volume; + voiceSourceList.ForEach(voice => voice.ChangeVolume(volume)); + } + + public void ChangeVolume(SoundType soundType, float volume){ + switch(soundType){ + case SoundType.BGM: + ChangeVolumeBGM(volume); + break; + case SoundType.Voice: + ChangeVolumeVoice(volume); + break; + default: + ChangeVolumeSE(volume); + break; + } + } + + void LateUpdate(){ + for(int i = seSourceList.Count - 1; i >= 0; --i){ + if(!seSourceList[i].IsPlaying()){ + seSourceList[i].PlayCallBack(); + seSourceList.RemoveAt(i); + } + } + for(int i = voiceSourceList.Count - 1; i >= 0; --i){ + if(!voiceSourceList[i].IsPlaying()){ + voiceSourceList[i].PlayCallBack(); + voiceSourceList.RemoveAt(i); + } + } + } + + public void PauseBGM() { + if(bgmSource) bgmSource.Pause(); + } + public void UnPauseBGM() { + if(bgmSource) bgmSource.UnPause(); + } + public void PauseTimeBGM() { + if(bgmSource){ + pauseTime = bgmSource.time; + bgmSource.Pause(); + } + } + public void UnPauseTimeBGM() { + if(bgmSource){ + bgmSource.UnPause(); + bgmSource.time = pauseTime; + } + } + + public void ReplayBGM(){ + if(!bgmSource) return ; + bgmSource.Stop(); + bgmSource.Play(); + } + + public void StopBGM(){ + if(!bgmSource) return ; + bgmFilePath = ""; + bgmSource.Stop(); + bgmSource.clip = null; + } + public void StopSE(){ + foreach(PlayingAudio playing in seSourceList){ + playing.Stop(); + } + seSourceList.Clear(); + } + public void StopSELoop(){ + foreach(KeyValuePair pair in seLoopSourceDic){ + pair.Value.StopDestroy(); + } + seLoopSourceDic.Clear(); + } + public void StopSELoop(string filePath){ + if(!seLoopSourceDic.ContainsKey(filePath)) return ; + PlayingAudio audioSource = seLoopSourceDic[filePath]; + audioSource.StopDestroy(); + seLoopSourceDic.Remove(filePath); + } + public void StopVoice(){ + foreach(PlayingAudio playing in voiceSourceList){ + playing.Stop(); + } + voiceSourceList.Clear(); + } + public void StopAll(){ + StopBGM(); + StopSE(); + StopSELoop(); + StopVoice(); + } + public void StopAllFade(float interval){ + FadeOut(interval, StopAll); + } + + public void ChangeFadeBGM(string filePath, float interval, float volume = 1.0f, bool loop = true){ + if(bgmFilePath.Contains(filePath)) return ; + if(bgmFilePath.Length > 0){ + FadeOut(interval * 0.5f, () => { + PlayBGM(filePath, volume); + FadeIn(interval * 0.5f, ActionExtensions.EmptyAction); + }); + }else{ + PlayBGM(filePath, volume, loop); + } + } + public void PlayBGM(string filePath, float volume = 1.0f, bool loop = true){ + if(bgmFilePath.Contains(filePath)) return ; + bgmFilePath = filePath; + PlayBGM(LoadAudioClip(filePath, SoundType.BGM), volume, loop); + } + public void PlayBGM(AudioClip clip, float volume = 1.0f, bool loop = true){ + if(bgmSource == null){ + bgmSource = gameObject.AddComponent(); + } + if(bgmSource.clip == clip) return ; + + uniqueBGMVolume = volume; + pauseTime = 0.0f; + bgmSource.time = 0.0f; + bgmSource.Stop(); + bgmSource.clip = clip; + bgmSource.loop = loop; + bgmSource.volume = uniqueBGMVolume * bgmVolume; + bgmSource.mute = !enabledBGM; + bgmSource.Play(); + + bgmSource.outputAudioMixerGroup = defaultBGMAudioMixer; + } + + public void PlaySE(string filePath, int maxCount = 0, float volume = 1.0f, float pitch = 1.0f){ + PlaySE(LoadAudioClip(filePath, SoundType.SE), maxCount, volume, pitch); + } + public void PlaySE(AudioClip clip, int maxCount = 0, float volume = 1.0f, float pitch = 1.0f){ + if(clip == null) return ; + PlaySE(clip, ActionExtensions.EmptyAction, maxCount, volume, pitch); + } + public void PlaySE(string filePath, Action callBack, int maxCount = 0, float volume = 1.0f){ + PlaySE(LoadAudioClip(filePath, SoundType.SE), callBack, maxCount, volume); + } + public void PlaySE(AudioClip clip, Action callBack, int maxCount = 0, float volume = 1.0f, float pitch = 1.0f){ + if(clip == null || isPausing) return ; + PlaySE(clip, maxCount, volume, pitch, callBack, seSourceList); + } + private void PlaySE(AudioClip clip, int maxCount, float volume, float pitch, Action callBack, List list){ + string clipName = clip.name; + var result = FindCountOverPlayingAudio(clipName, maxCount, list); + if(result != null){ + result.audioSource.Stop(); + result.audioSource.Play(); + }else{ + AudioSource source = CreateAudioSource(clip, volume * seVolume, pitch, !enabledSE, defaultSEAudioMixer); + list.Add(new PlayingAudio(clipName, source, volume, callBack)); + } + } + + public AudioSource PlaySELoop(string filePath, float volume = 1.0f, float pitch = 1.0f){ + if(seLoopSourceDic.ContainsKey(filePath)) return seLoopSourceDic[filePath].audioSource; + AudioClip clip = LoadAudioClip(filePath, SoundType.SE); + AudioSource source = CreateAudioSource(clip, volume * seVolume, pitch, !enabledSE, defaultSEAudioMixer); + source.loop = true; + seLoopSourceDic.Add(filePath, new PlayingAudio(clip.name, source, volume, ActionExtensions.EmptyAction)); + return source; + } + + public void PlayVoice(string filePath, int maxCount = 0, float volume = 1.0f, float pitch = 1.0f){ + PlayVoice(LoadAudioClip(filePath, SoundType.Voice), maxCount, volume, pitch); + } + public void PlayVoice(AudioClip clip, int maxCount = 0, float volume = 1.0f, float pitch = 1.0f){ + if(clip == null) return ; + PlayVoice(clip, ActionExtensions.EmptyAction, maxCount, volume, pitch); + } + public void PlayVoice(string filePath, Action callBack, int maxCount = 0, float volume = 1.0f){ + PlayVoice(LoadAudioClip(filePath, SoundType.Voice), callBack, maxCount, volume); + } + public void PlayVoice(AudioClip clip, Action callBack, int maxCount = 0, float volume = 1.0f, float pitch = 1.0f){ + if(clip == null || isPausing){ + callBack(); + }else{ + PlayVoice(clip, maxCount, volume, pitch, callBack, voiceSourceList); + } + } + private void PlayVoice(AudioClip clip, int maxCount, float volume, float pitch, Action callBack, List list){ + string clipName = clip.name; + var result = FindCountOverPlayingAudio(clipName, maxCount, list); + if(result != null){ + result.audioSource.Stop(); + result.audioSource.Play(); + }else{ + AudioSource source = CreateAudioSource(clip, volume * voiceVolume, pitch, !enabledVoice, defaultVoiceAudioMixer); + list.Add(new PlayingAudio(clipName, source, volume, callBack)); + } + } + private PlayingAudio FindCountOverPlayingAudio(string clipName, int maxCount, List list){ + if(maxCount > 0){ + int counter = 0; + foreach(var pa in list){ + if(pa.Name == clipName && ++counter >= maxCount){ + foreach(var p in list){ + if(p.Name == clipName){ + return p; + } + } + } + } + } + return null; + } + private AudioSource CreateAudioSource(AudioClip clip, float volume, float pitch, bool mute, AudioMixerGroup audioMixerGroup){ + AudioSource source = gameObject.AddComponent(); + source.Stop(); + source.clip = clip; + source.volume = volume; + source.pitch = pitch; + source.mute = mute; + source.Play(); + source.outputAudioMixerGroup = defaultVoiceAudioMixer; + return source; + } + + public class PlayingAudio { + private string name; + public string Name { + get{ return name; } + } + public AudioSource audioSource = null; + private Action callBack = null; + private float uniqueVolume; + + public PlayingAudio(string name, AudioSource audioSource, float uniqueVolume, Action callBack){ + this.name = name; + this.audioSource = audioSource; + this.uniqueVolume = uniqueVolume; + this.callBack = callBack; + } + + public bool IsPlaying(){ + return audioSource.isPlaying; + } + + public void PlayCallBack(){ + callBack(); + Destroy(audioSource); + } + + public void Stop(){ + audioSource.Stop(); + } + public void StopDestroy(){ + audioSource.Stop(); + Destroy(audioSource); + } + + public void ChangeVolume(float volume){ + audioSource.volume = volume * uniqueVolume; + } + public void ChangeMute(bool mute){ + audioSource.mute = mute; + } + } + + private Dictionary audioClipDict = new Dictionary(); + private AudioClip LoadAudioClip(string filePath, SoundType soundType){ + if(!filePath.Contains("/")){ + switch(soundType){ + case SoundType.BGM: filePath = "Sounds/BGM/" + filePath; break; + case SoundType.SE: filePath = "Sounds/SE/" + filePath; break; + case SoundType.Voice: filePath = "Sounds/Voice/" + filePath; break; + } + } + AudioClip result = null; + if(!audioClipDict.TryGetValue(filePath, out result)){ + result = Resources.Load(filePath, typeof(AudioClip)) as AudioClip; +#if UNITY_EDITOR + if(result == null){ + Debug.LogError("鳴らそうとしているファイル(" + filePath + ")が存在しません。"); + UnityEditor.EditorApplication.isPlaying = false; + } +#endif + audioClipDict.Add(filePath, result); + } + return result; + } + + private void UpdateMute(){ + if(bgmSource != null){ + bgmSource.mute = !enabledBGM; + } + seSourceList.ForEach(se => se.ChangeMute(!enabledSE)); + voiceSourceList.ForEach(voice => voice.ChangeMute(!enabledVoice)); + } + + public void ChangeBGMAudioMixerGroup(AudioMixerGroup amg){ + bgmSource.outputAudioMixerGroup = amg; + } + public void ResetBGMAudioMixerGroup(){ + bgmSource.outputAudioMixerGroup = defaultBGMAudioMixer; + } + + private bool isPause = false; + void OnApplicationPause(bool pauseStatus){ + if(!bgmSource) return ; + if(pauseStatus){ + isPause = true; + bgmSource.volume = 0.0f; + PauseBGM(); + isPausing = true; + }else if(isPause){ + isPause = false; + StartCoroutine(ReturnPause()); + } + } + + private bool isPausing = false; + private IEnumerator ReturnPause(){ + int i = 0; + // 素通りだと起動時にFadeIn後のVolumeから開始される + int waitFrameCounter = 20; + while(i++ < waitFrameCounter){ + yield return null; + } + isPausing = false; + UnPauseBGM(); + FadeIn(1.0f, ActionExtensions.EmptyAction); + } + + private void FadeIn(float duration, Action callback){ + Fade(duration, lerp => Mathf.Lerp(0.0f, 1.0f, lerp * lerp), callback); + } + private void FadeOut(float duration, Action callback){ + Fade(duration, lerp => 1.0f - Mathf.Lerp(0.0f, 1.0f, lerp * lerp), callback); + } + private void Fade(float duration, Func lerpToVolume, Action callback){ + this.CallLerpSmooth(duration, lerp => { + float v = lerpToVolume(lerp); + bgmSource.volume = v * uniqueBGMVolume * bgmVolume; + float se = v * seVolume; + foreach(PlayingAudio playing in seSourceList){ + playing.ChangeVolume(se); + } + foreach(KeyValuePair pair in seLoopSourceDic){ + pair.Value.ChangeVolume(se); + } + float voice = v * voiceVolume; + foreach(PlayingAudio playing in voiceSourceList){ + playing.ChangeVolume(voice); + } + }, callback); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/SoundManager.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/SoundManager.cs.meta new file mode 100644 index 00000000..d2c06098 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/SoundManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 98c9d1a2074d64c48b1cf9fae5e1c210 +timeCreated: 1447677936 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/StorageManager.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/StorageManager.cs new file mode 100644 index 00000000..9c75099d --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/StorageManager.cs @@ -0,0 +1,73 @@ +#if OLD_STORAGE +using System; +using System.Runtime.InteropServices; +using UnityEngine; + +public enum StorageFilename { + MainData, + SettingsData, + WalletData, + PurchaserData, +} + +/// 古いのでMyStorageManagerを使用して下さい +public static class StorageManager { + +// public static void Save(StorageFilename filename, string tag, T value){ +// ES3.Save(tag, value, filename.ToString()); +// } + + public static T LoadOrDefault(StorageFilename filename, string tag, T defaultValue){ + return ES3.Load(tag, filename.ToString(), defaultValue); + } + public static T Load(StorageFilename filename, string tag){ + return ES3.Load(tag, filename.ToString()); + } + + public static bool Exists(StorageFilename filename, string tag){ + return ES3.FileExists(filename.ToString()) && ES3.KeyExists(tag, filename.ToString()); + } + +// public static void Remove(StorageFilename filename, string tag){ +// if(!Exists(filename, tag)) return ; +// ES3.DeleteKey(tag, filename.ToString()); +// } + + +// public static void SaveAndBackup(StorageFilename filename, string tag, string value){ +// ES3.Save(tag, value, filename.ToString()); +// string key = string.Format("{0}?tag={1}", filename.ToString(), tag); +// PlayerPrefs.SetString(key, value); +// PlayerPrefs.Save(); +// } + + public static bool ExistsBackup(StorageFilename filename, string tag){ + string key = string.Format("{0}?tag={1}", filename.ToString(), tag); + return PlayerPrefs.HasKey(key); + } + + public static string LoadBackup(StorageFilename filename, string tag){ + string key = string.Format("{0}?tag={1}", filename.ToString(), tag); + return PlayerPrefs.GetString(key); + } + + public static void IsDiskFull(Exception ex, Func getDiskFullMessage){ + const int ERROR_HANDLE_DISK_FULL = 0x27; + const int ERROR_DISK_FULL = 0x70; + + int errorCode = Marshal.GetHRForException(ex) & 0xFFFF; + if(errorCode == ERROR_HANDLE_DISK_FULL || errorCode == ERROR_DISK_FULL){ + NativeUtils.ShowAlert(ex.Message, getDiskFullMessage()); + }else{ + throw ex; + } + } + + public static string LoadRawString(StorageFilename filename){ + return ES3.LoadRawString(filename.ToString()); + } + public static void SaveRawString(StorageFilename filename, string str){ + ES3.SaveRaw(str, filename.ToString()); + } +} +#endif diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/StorageManager.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/StorageManager.cs.meta new file mode 100644 index 00000000..27fe86a4 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/StorageManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: dbffb9fe402bf406595af642d4930f48 +timeCreated: 1538450082 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/UsayaStorageManager.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/UsayaStorageManager.cs new file mode 100644 index 00000000..12191bfb --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/UsayaStorageManager.cs @@ -0,0 +1,230 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using UnityEngine; + +public enum UsayaStorageFilename { + Main_Data, + Settings_Data, + Wallet_Data, + Purchaser_Data, +} + +public class UsayaStorageManager { + + [Serializable] + protected class DataSet { + public string tag; + public string data; + + public static DataSet CreateInstance(string tag, T value){ + DataSet dataSet = new DataSet(); + dataSet.Save(tag, value); + return dataSet; + } + public void Save(string tag, T value){ + this.tag = tag; + this.data = JsonUtility.ToJson(new Serialization(new List{ value })); + } + public T Load(){ + return JsonUtility.FromJson>(data).ToList()[0]; + } + } + private const string FileExtension = ".usaya"; + + private static Dictionary> dataSetDictionary = new Dictionary>(); + + private static string ToPath(UsayaStorageFilename filename){ + return Application.persistentDataPath + "/" + filename.ToString() + FileExtension; + } + + public static void Reset(){ + dataSetDictionary.Clear(); + } + private static List GetDataSetList(UsayaStorageFilename filename){ + var key = filename.ToString(); + if(dataSetDictionary.ContainsKey(key)){ + return dataSetDictionary[key]; + }else{ + try{ + List list; + if(Exists(filename)){ + list = LoadList(filename); + }else{ + list = new List(); + } + dataSetDictionary[key] = list; + return list; + }catch(Exception e){ + dataSetDictionary[key] = new List(); + if(filename == UsayaStorageFilename.Settings_Data){ + return dataSetDictionary[key]; + }else{ + throw e; + } + } + } + } + private static List SaveDataSet(UsayaStorageFilename filename, string tag, T value){ + var dataSetList = GetDataSetList(filename); + bool isExists = false; + foreach(var dataSet in dataSetList){ + if(dataSet.tag == tag){ + dataSet.Save(tag, value); + isExists = true; + break; + } + } + if(!isExists){ + dataSetList.Add(DataSet.CreateInstance(tag, value)); + } + return dataSetList; + } + private static DataSet LoadDataSet(UsayaStorageFilename filename, string tag){ + var dataSetList = GetDataSetList(filename); + foreach(var dataSet in dataSetList){ + if(dataSet.tag == tag) return dataSet; + } + return null; + } + private static bool ExistsDataSet(UsayaStorageFilename filename, string tag){ + var dataSetList = GetDataSetList(filename); + foreach(var dataSet in dataSetList){ + if(dataSet.tag == tag) return true; + } + return false; + } + + public static void Save(UsayaStorageFilename filename, string tag, T value){ + var list = SaveDataSet(filename, tag, value); + SaveList(filename, list); + } + private static void SaveList(UsayaStorageFilename filename, List list){ + var path = ToPath(filename); + var json = JsonUtility.ToJson(new Serialization(list)); + using(StreamWriter writer = new StreamWriter(path, false)){ + writer.Write(json); + writer.Flush(); + writer.Close(); + } + } + + public static T LoadOrDefault(UsayaStorageFilename filename, string tag, T defaultValue){ + if(Exists(filename, tag)){ + return Load(filename, tag); + }else{ + return defaultValue; + } + } + public static T Load(UsayaStorageFilename filename, string tag){ + var dataSet = LoadDataSet(filename, tag); + return dataSet.Load(); + } + private static List LoadList(UsayaStorageFilename filename){ + var path = ToPath(filename); + var fileInfo = new FileInfo(path); + string json = LoadJson(fileInfo); + var result = Deserialize>(json); + return SerializationToList(result); + } + private static string LoadJson(FileInfo fileInfo){ + string json; + using(var fileStream = fileInfo.OpenRead()){ + using(var streamReader = new StreamReader(fileStream, Encoding.UTF8)){ + json = streamReader.ReadToEnd(); + streamReader.Close(); + } + } + return json; + } + private static T Deserialize(string json){ + return JsonUtility.FromJson(json); + } + private static List SerializationToList(Serialization serialization){ + return serialization.ToList(); + } + + public static bool Exists(UsayaStorageFilename filename, string tag){ + return ExistsDataSet(filename, tag); + } + public static bool Exists(UsayaStorageFilename filename){ + var path = ToPath(filename); + return File.Exists(path); + } + + public static void Remove(UsayaStorageFilename filename, string tag){ + var list = GetDataSetList(filename); + DataSet result = null; + foreach(var dataSet in list){ + if(dataSet.tag == tag){ + result = dataSet; + break; + } + } + if(result != null){ + list.Remove(result); + SaveList(filename, list); + } + } + + + public static void SaveAndBackup(UsayaStorageFilename filename, string tag, string value){ +// bool isMainSaved = false; + try{ + Save(filename, tag, value); +// isMainSaved = true; + }catch(Exception){ + // TODO ログサーバが出来たらExceptionを送りたい + }finally{ + SaveBackup(filename, tag, value); + } + } + public static void SaveBackup(UsayaStorageFilename filename, string tag, string value){ + string key = string.Format("{0}?tag={1}", filename.ToString(), tag); + PlayerPrefs.SetString(key, value); + PlayerPrefs.Save(); + } + + public static bool ExistsBackup(UsayaStorageFilename filename, string tag){ + string key = string.Format("{0}?tag={1}", filename.ToString(), tag); + return PlayerPrefs.HasKey(key); + } + + public static string LoadBackup(UsayaStorageFilename filename, string tag){ + string key = string.Format("{0}?tag={1}", filename.ToString(), tag); + return PlayerPrefs.GetString(key); + } + + public static void IsDiskFull(Exception ex, Func getDiskFullMessage){ + const int ERROR_HANDLE_DISK_FULL = 0x27; + const int ERROR_DISK_FULL = 0x70; + + int errorCode = Marshal.GetHRForException(ex) & 0xFFFF; + if(errorCode == ERROR_HANDLE_DISK_FULL || errorCode == ERROR_DISK_FULL){ + NativeUtils.ShowAlert(ex.Message, getDiskFullMessage()); + }else{ + throw ex; + } + } + + public static string LoadRawString(UsayaStorageFilename filename){ + var path = ToPath(filename); + var fileInfo = new FileInfo(path); + string json; + using(var streamReader = new StreamReader(fileInfo.OpenRead(), Encoding.UTF8)){ + json = streamReader.ReadToEnd(); + streamReader.Close(); + } + return json; + } + public static void SaveRawString(UsayaStorageFilename filename, string str){ + var path = ToPath(filename); + using(StreamWriter writer = new StreamWriter(path, false)){ + writer.Write(str); + writer.Flush(); + writer.Close(); + } + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/UsayaStorageManager.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/UsayaStorageManager.cs.meta new file mode 100644 index 00000000..3f024e2b --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/UsayaStorageManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e0f6204f9381e42f4a605f7388c72138 +timeCreated: 1540187791 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/VibrationManager.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/VibrationManager.cs new file mode 100644 index 00000000..813b4742 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/VibrationManager.cs @@ -0,0 +1,59 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class VibrationManager : SingletonMonoBehaviour { + + private bool isEnable = true; + public bool IsEnable { + get{ return isEnable; } + } + + void Awake(){ + if(CheckInstance()){ + return; + } + isEnable = UsayaStorageManager.LoadOrDefault(UsayaStorageFilename.Settings_Data, Const.VibrationTag, true); + } + + public void SaveEnable(bool enable){ + UsayaStorageManager.Save(UsayaStorageFilename.Settings_Data, Const.VibrationTag, enable); + isEnable = enable; + } + + public void PlayVibrationOnce(){ + if(isEnable){ + NativeUtils.PlayVibrationOnce(); + } + } + public void PlayVibrationOnceStrong(){ + if(isEnable){ + NativeUtils.PlayVibrationOnceStrong(); + } + } + public void PlayVibrationOnceWeak(){ + if(isEnable){ + NativeUtils.PlayVibrationOnceWeak(); + } + } + public void PlayVibrationDoubleStrong(){ + if(isEnable){ + NativeUtils.PlayVibrationDoubleStrong(); + } + } + public void PlayVibrationDoubleWeak(){ + if(isEnable){ + NativeUtils.PlayVibrationDoubleWeak(); + } + } + public void PlayVibrationTriple(){ + if(isEnable){ + NativeUtils.PlayVibrationTriple(); + } + } + public void PlayVibration(VibrationType vibrationType){ + if(isEnable){ + NativeUtils.PlayVibration(vibrationType); + } + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Managers/VibrationManager.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/VibrationManager.cs.meta new file mode 100644 index 00000000..acf9d7d9 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Managers/VibrationManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 85ce2c3363c344d92b98a939b21f1fae +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/ScriptableObjects.meta b/popcorn/Assets/USAYAUnityLib/Scripts/ScriptableObjects.meta new file mode 100644 index 00000000..eeb7b42d --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/ScriptableObjects.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5b5951b1088af4cadae7f49c6dfbf86c +folderAsset: yes +timeCreated: 1464839971 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/ScriptableObjects/AnimatorParameter.cs b/popcorn/Assets/USAYAUnityLib/Scripts/ScriptableObjects/AnimatorParameter.cs new file mode 100644 index 00000000..d9882404 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/ScriptableObjects/AnimatorParameter.cs @@ -0,0 +1,75 @@ +using UnityEngine; + +[CreateAssetMenuAttribute] +public class AnimatorParameter : ScriptableObject +{ + [SerializeField] + RuntimeAnimatorController animatorController = default; + + public AnimatorParameterInfo[] parameterInfos; + + [System.Serializable] + public struct AnimatorParameterInfo + { + public ParameterType type; + public int hashName; + public string name; + public enum ParameterType + { + NONE, + BOOL, + FLOAT, + INT, + TRIGGER + } + } + #if UNITY_EDITOR + [ContextMenu("Setup")] + void Setup() + { + UnityEditor.Animations.AnimatorController controller = animatorController as UnityEditor.Animations.AnimatorController; + parameterInfos = new AnimatorParameterInfo[controller.parameters.Length]; + + + UnityEditor.AssetDatabase.RenameAsset(UnityEditor.AssetDatabase.GetAssetPath(this), animatorController.name); + name = animatorController.name; + + for (int i=0; i(); + } + + private void Lerp(float lerp){ + image.color = Color.Lerp(fromColor, targetColor, lerp); + } + + public void ChangeColor(Color targetColor){ + image.color = targetColor; + } + public void ChangeColor(Color targetColor, float interval){ + ChangeColor(targetColor, interval, ActionExtensions.EmptyAction); + } + public void ChangeColor(Color targetColor, float interval, Action callback){ + this.targetColor = targetColor; + this.fromColor = image.color; + + Begin(Lerp, interval, callback); + } + + public void ChangeColor(Color fromColor, Color targetColor, float interval){ + ChangeColor(fromColor, targetColor, interval, ActionExtensions.EmptyAction); + } + public void ChangeColor(Color fromColor, Color targetColor, float interval, Action callback){ + image.color = fromColor; + ChangeColor(targetColor, interval, callback); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/ImageColorTo.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/ImageColorTo.cs.meta new file mode 100644 index 00000000..1465ec1d --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/ImageColorTo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 033813179dbfb48a89d9e5ca5f90bd5c +timeCreated: 1447677936 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/LocalScaleTo.cs b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/LocalScaleTo.cs new file mode 100644 index 00000000..9c1346df --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/LocalScaleTo.cs @@ -0,0 +1,26 @@ +using UnityEngine; +using System; + +public class LocalScaleTo : SomethingTo { + + private Vector3 fromLocalScale; + private Vector3 targetLocalScale; + private void Lerp(float lerp){ + transform.localScale = Vector3.Lerp(fromLocalScale, targetLocalScale, lerp); + } + + public void ChangeLocalScale(Vector3 targetLocalScale, float interval, EasingType easingType = EasingType.Linear){ + ChangeLocalScale(targetLocalScale, interval, ActionExtensions.EmptyAction, easingType); + } + public void ChangeLocalScale(Vector3 targetLocalScale, float interval, Action callback, EasingType easingType = EasingType.Linear){ + ChangeLocalScale(transform.localScale, targetLocalScale, interval, callback, easingType); + } + public void ChangeLocalScale(Vector3 fromLocalScale, Vector3 targetLocalScale, float interval, EasingType easingType = EasingType.Linear){ + ChangeLocalScale(fromLocalScale, targetLocalScale, interval, ActionExtensions.EmptyAction, easingType); + } + public void ChangeLocalScale(Vector3 fromLocalScale, Vector3 targetLocalScale, float interval, Action callback, EasingType easingType = EasingType.Linear){ + this.targetLocalScale = targetLocalScale; + this.fromLocalScale = fromLocalScale; + Begin(Lerp, interval, callback, easingType); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/LocalScaleTo.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/LocalScaleTo.cs.meta new file mode 100644 index 00000000..03f974fa --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/LocalScaleTo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 25b5a0a48494449dab70b69c92143efd +timeCreated: 1455079954 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/MoveTo.cs b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/MoveTo.cs new file mode 100644 index 00000000..d22c128e --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/MoveTo.cs @@ -0,0 +1,35 @@ +using UnityEngine; +using System; + +public class MoveTo : SomethingTo { + + private Vector3 fromPosition; + private Vector3 targetPosition; + private Vector3 initializePosition; + public Vector3 InitializePosition{ + get{ return initializePosition; } + } + + void Awake(){ + initializePosition = transform.position; + } + + private void Lerp(float lerp){ + transform.position = Vector3.Lerp(fromPosition, targetPosition, lerp); + } + + public void ChangePosition(Vector3 targetPosition, float interval, EasingType easingType = EasingType.Linear){ + ChangePosition(transform.position, targetPosition, interval, ActionExtensions.EmptyAction, easingType); + } + public void ChangePosition(Vector3 fromPosition, Vector3 targetPosition, float interval, EasingType easingType = EasingType.Linear){ + ChangePosition(fromPosition, targetPosition, interval, ActionExtensions.EmptyAction, easingType); + } + public void ChangePosition(Vector3 targetPosition, float interval, Action callback, EasingType easingType = EasingType.Linear){ + ChangePosition(transform.position, targetPosition, interval, ActionExtensions.EmptyAction, easingType); + } + public void ChangePosition(Vector3 fromPosition, Vector3 targetPosition, float interval, Action callback, EasingType easingType = EasingType.Linear){ + this.targetPosition = targetPosition; + this.fromPosition = fromPosition; + Begin(Lerp, interval, callback, easingType); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/MoveTo.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/MoveTo.cs.meta new file mode 100644 index 00000000..76cf1d4a --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/MoveTo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 057ffb080ec2a48cab6ed10dce809c79 +timeCreated: 1450778706 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/RotateTo.cs b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/RotateTo.cs new file mode 100644 index 00000000..f44aca72 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/RotateTo.cs @@ -0,0 +1,22 @@ +using UnityEngine; +using System; + +public class RotateTo : SomethingTo { + + private Quaternion fromQuaternion; + private Quaternion targetQuaternion; + + private void Lerp(float lerp){ + transform.rotation = Quaternion.Lerp(fromQuaternion, targetQuaternion, lerp); + } + + public void ChangeRotation(Quaternion targetQuaternion, float interval, EasingType easingType = EasingType.Linear){ + ChangeRotation(targetQuaternion, interval, ActionExtensions.EmptyAction, easingType); + } + + public void ChangeRotation(Quaternion targetQuaternion, float interval, Action callback, EasingType easingType = EasingType.Linear){ + this.targetQuaternion = targetQuaternion; + this.fromQuaternion = transform.rotation; + Begin(Lerp, interval, callback, easingType); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/RotateTo.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/RotateTo.cs.meta new file mode 100644 index 00000000..833e2db1 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/RotateTo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 814890b93440d4c3a989c02c0e997a2e +timeCreated: 1453119609 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/RotateToZ.cs b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/RotateToZ.cs new file mode 100644 index 00000000..322fc544 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/RotateToZ.cs @@ -0,0 +1,22 @@ +using UnityEngine; +using System; + +public class RotateToZ : SomethingTo { + + private Quaternion fromQuaternion; + private float targetAngle; + + private void Lerp(float lerp){ + transform.rotation = fromQuaternion * Quaternion.AngleAxis(Mathf.Lerp(0.0f, targetAngle, lerp), Vector3.forward); + } + + public void ChangeRotation(float targetAngle, float interval, EasingType easingType = EasingType.Linear){ + ChangeRotation(targetAngle, interval, ActionExtensions.EmptyAction, easingType); + } + + public void ChangeRotation(float targetAngle, float interval, Action callback, EasingType easingType = EasingType.Linear){ + this.targetAngle = targetAngle; + this.fromQuaternion = transform.rotation; + Begin(Lerp, interval, callback, easingType); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/RotateToZ.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/RotateToZ.cs.meta new file mode 100644 index 00000000..5123584f --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/RotateToZ.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: bc9365a6bcd744d83abb2723604a0c99 +timeCreated: 1457329711 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/SomethingTo.cs b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/SomethingTo.cs new file mode 100644 index 00000000..024cd1a6 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/SomethingTo.cs @@ -0,0 +1,55 @@ +using UnityEngine; +using System; + +public enum EasingType{ + Linear, + Smooth, +} + +public abstract class SomethingTo : MonoBehaviour { + + + private float lerp = 1.0f; + private float speed = 1.0f; + protected Action update = ActionExtensions.EmptyActionFloat; + protected Action callback = ActionExtensions.EmptyAction; + + protected void Begin(Actionupdate, float interval, Action callback, EasingType easingType = EasingType.Linear){ + SetUpdate(update, easingType); + this.callback = callback; + speed = 1.0f / interval; + lerp = 0.0f; + } + + private void SetUpdate(Actionupdate, EasingType easingType){ + switch(easingType){ + case EasingType.Smooth: + this.update = lerp => { + update(AnimationCurveExtensions.Smooth01.Evaluate(lerp)); + }; + break; + default: + this.update = update; + break; + } + } + + public void Stop(){ + lerp = 1.0f; +// update(lerp); +// callback(); + } + + void Update(){ + if(lerp < 1.0f){ + lerp += Time.deltaTime * speed; + if(lerp >= 1.0f){ + lerp = 1.0f; + update(lerp); + callback(); + }else{ + update(lerp); + } + } + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/SomethingTo.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/SomethingTo.cs.meta new file mode 100644 index 00000000..531e175c --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/SomethingTo/SomethingTo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 20cccb7a532a541d8a1b8792668afc2d +timeCreated: 1447677936 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Timeline.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Timeline.meta new file mode 100644 index 00000000..00b43983 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Timeline.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: eb729c76fc40848c39445b6acb2556c8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Timeline/PlaySEPlayableAsset.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Timeline/PlaySEPlayableAsset.cs new file mode 100644 index 00000000..25a4b5f9 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Timeline/PlaySEPlayableAsset.cs @@ -0,0 +1,14 @@ +using UnityEngine; +using UnityEngine.Playables; + +[System.Serializable] +public sealed class PlaySEPlayableAsset : PlayableAsset { + [SerializeField] + private string playSEFilename = default; + + public override Playable CreatePlayable(PlayableGraph graph, GameObject go){ + var behaviour = new PlaySEPlayableBehaviour(); + behaviour.PlaySEFilename = playSEFilename; + return ScriptPlayable.Create(graph, behaviour); + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Timeline/PlaySEPlayableAsset.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Timeline/PlaySEPlayableAsset.cs.meta new file mode 100644 index 00000000..59b46d33 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Timeline/PlaySEPlayableAsset.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 179586359073e410c9b13bd97e10af80 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Timeline/PlaySEPlayableBehaviour.cs b/popcorn/Assets/USAYAUnityLib/Scripts/Timeline/PlaySEPlayableBehaviour.cs new file mode 100644 index 00000000..34e9137e --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Timeline/PlaySEPlayableBehaviour.cs @@ -0,0 +1,32 @@ +using UnityEngine; +using UnityEngine.Playables; + +public class PlaySEPlayableBehaviour : PlayableBehaviour { + + private string playSEFilename; + public string PlaySEFilename { + set{ playSEFilename = value; } + } + public override void OnGraphStart(Playable playable){ + } + + public override void OnGraphStop(Playable playable){ + } + + public override void OnBehaviourPlay(Playable playable, FrameData info){ + +#if UNITY_EDITOR + if(SoundManager.ExistsInstance){ + SoundManager.Instance.PlaySE(string.Format("Sounds/SE/{0}", playSEFilename)); + } +#else + SoundManager.Instance.PlaySE(string.Format("Sounds/SE/{0}", playSEFilename)); +#endif + } + + public override void OnBehaviourPause(Playable playable, FrameData info){ + } + + public override void PrepareFrame(Playable playable, FrameData info){ + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/Timeline/PlaySEPlayableBehaviour.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/Timeline/PlaySEPlayableBehaviour.cs.meta new file mode 100644 index 00000000..94233ac6 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/Timeline/PlaySEPlayableBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 553d3b9c948294c5bbb17e1e8241fbd5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/UI.meta b/popcorn/Assets/USAYAUnityLib/Scripts/UI.meta new file mode 100644 index 00000000..027489eb --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/UI.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1124f8bcdffcb4c84bd0d9423b2a00ac +folderAsset: yes +timeCreated: 1463637353 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/UI/AutoScrollText.cs b/popcorn/Assets/USAYAUnityLib/Scripts/UI/AutoScrollText.cs new file mode 100644 index 00000000..7c9cc241 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/UI/AutoScrollText.cs @@ -0,0 +1,40 @@ +using UnityEngine; +using System.Collections; + +public class AutoScrollText : MonoBehaviour { + + private RectTransform rectTransform; + private float parentSizeX; + + public float speed = 100.0f; + + void Awake(){ + rectTransform = GetComponent(); + parentSizeX = transform.parent.GetComponent().rect.width; + } + void OnEnable(){ + StartCoroutine(Scroll()); + } + IEnumerator Scroll(){ + Vector2 p; + while(true){ + p = rectTransform.anchoredPosition; + p.x = parentSizeX; + rectTransform.anchoredPosition = p; + while(rectTransform.anchoredPosition.x > 0){ + yield return null; + rectTransform.AddLocalPositionX(-speed * 3 * Time.deltaTime); + } + p = rectTransform.anchoredPosition; + p.x = 0; + rectTransform.anchoredPosition = p; + yield return new WaitForSeconds(2.0f); + + while(rectTransform.anchoredPosition.x > -rectTransform.rect.width){ + yield return null; + rectTransform.AddLocalPositionX(-speed * Time.deltaTime); + } + yield return new WaitForSeconds(0.5f); + } + } +} diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/UI/AutoScrollText.cs.meta b/popcorn/Assets/USAYAUnityLib/Scripts/UI/AutoScrollText.cs.meta new file mode 100644 index 00000000..8e0fb8cb --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/UI/AutoScrollText.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5991761277d134ce0b241d992d0eae96 +timeCreated: 1458724437 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/USAYAUnityLib/Scripts/UI/ButtonEventReceiver.cs b/popcorn/Assets/USAYAUnityLib/Scripts/UI/ButtonEventReceiver.cs new file mode 100644 index 00000000..d7f85d17 --- /dev/null +++ b/popcorn/Assets/USAYAUnityLib/Scripts/UI/ButtonEventReceiver.cs @@ -0,0 +1,29 @@ +using UnityEngine; +using UnityEngine.UI; + +[RequireComponent(typeof(Button))] +public class ButtonEventReceiver : MonoBehaviour { + // HACK 次のアプリでは削除する + public string onClickPlaySEFilename; + [SerializeField] + private string[] randomPlaySEFilenames = default; + [SerializeField] + private string[] randomPlayVoiceFilenames = default; + [SerializeField] + private VibrationType vibrationType = default; + + void Awake(){ + GetComponent