Khoatv: xoa GuiFX

parent b21dd01f
fileFormatVersion: 2
guid: d5ed746199d6808468f5c099038d9b12
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: d3bb3b2f89b21ba47807137b85f21859
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
namespace Coffee.UIExtensions
{
[System.Serializable]
public class AnimatableProperty : ISerializationCallbackReceiver
{
public enum ShaderPropertyType
{
Color,
Vector,
Float,
Range,
Texture,
}
[SerializeField] string m_Name = "";
[SerializeField] ShaderPropertyType m_Type = ShaderPropertyType.Vector;
public int id { get; private set; }
public ShaderPropertyType type
{
get { return m_Type; }
}
public void UpdateMaterialProperties(Material material, MaterialPropertyBlock mpb)
{
if (!material.HasProperty(id)) return;
switch (type)
{
case ShaderPropertyType.Color:
var color = mpb.GetColor(id);
if (color != default(Color))
material.SetColor(id, color);
break;
case ShaderPropertyType.Vector:
var vector = mpb.GetVector(id);
if (vector != default(Vector4))
material.SetVector(id, vector);
break;
case ShaderPropertyType.Float:
case ShaderPropertyType.Range:
var value = mpb.GetFloat(id);
if (value != default(float))
material.SetFloat(id, value);
break;
case ShaderPropertyType.Texture:
var tex = mpb.GetTexture(id);
if (tex != default(Texture))
material.SetTexture(id, tex);
break;
}
}
public void OnBeforeSerialize()
{
}
public void OnAfterDeserialize()
{
id = Shader.PropertyToID(m_Name);
}
}
}
fileFormatVersion: 2
guid: 9d017c10f452f104fadd0cbeb529c366
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
namespace Coffee.UIParticleExtensions
{
[AddComponentMenu("")]
internal class BakingCamera : MonoBehaviour
{
static BakingCamera s_Instance;
private static readonly Vector3 s_OrthoPosition = new Vector3(0, 0, -1000);
private static readonly Quaternion s_OrthoRotation = Quaternion.identity;
#if UNITY_2018_3_OR_NEWER && UNITY_EDITOR
static BakingCamera s_InstanceForPrefab;
private static BakingCamera InstanceForPrefab
{
get
{
// If current scene is prefab mode, create OverlayCamera for editor.
var prefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
if (prefabStage == null || !prefabStage.scene.isLoaded) return null;
if (s_InstanceForPrefab) return s_InstanceForPrefab;
s_InstanceForPrefab = Create();
s_InstanceForPrefab.name += " (For Prefab Stage)";
UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(s_InstanceForPrefab.gameObject, prefabStage.scene);
return s_InstanceForPrefab;
}
}
#endif
private static BakingCamera Instance
{
get
{
#if UNITY_2018_3_OR_NEWER && UNITY_EDITOR
var inst = InstanceForPrefab;
if (inst) return inst;
#endif
// Find instance in scene, or create new one.
return s_Instance
? s_Instance
: (s_Instance = Create());
}
}
private Camera _camera;
private static BakingCamera Create()
{
var gameObject = new GameObject(typeof(BakingCamera).Name);
// This camera object is just for internal use
gameObject.hideFlags = HideFlags.HideAndDontSave;
var inst = gameObject.AddComponent<BakingCamera>();
inst._camera = gameObject.AddComponent<Camera>();
inst._camera.enabled = false;
inst._camera.orthographic = true;
// Turn camera off because particle mesh baker will use only camera matrix
gameObject.SetActive(false);
return inst;
}
private void Awake()
{
if (this == s_Instance)
DontDestroyOnLoad(gameObject);
}
public static Camera GetCamera(Canvas canvas)
{
if (!canvas) return Camera.main;
canvas = canvas.rootCanvas;
// Adjust camera orthographic size to canvas size
// for canvas-based coordinates of particles' size and speed.
var size = ((RectTransform) canvas.transform).rect.size;
Instance._camera.orthographicSize = Mathf.Max(size.x, size.y) * canvas.scaleFactor;
var camera = canvas.worldCamera;
var transform = Instance.transform;
var rotation = canvas.renderMode != RenderMode.ScreenSpaceOverlay && camera
? camera.transform.rotation
: s_OrthoRotation;
transform.SetPositionAndRotation(s_OrthoPosition, rotation);
Instance._camera.orthographic = true;
Instance._camera.farClipPlane = 2000f;
return Instance._camera;
}
}
}
fileFormatVersion: 2
guid: efb2d11d64545fd4288c08cdcc439082
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
{
"name": "Coffee.UIParticle",
"references": [],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false
}
\ No newline at end of file
fileFormatVersion: 2
guid: bb66ba55c0b383f4da5cea3a1f1bbe56
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections.Generic;
using UnityEngine;
namespace Coffee.UIParticleExtensions
{
internal class CombineInstanceEx
{
private int count;
public long hash = -1;
public int index = -1;
private readonly List<CombineInstance> combineInstances = new List<CombineInstance>(32);
public Mesh mesh;
public Matrix4x4 transform;
public void Combine()
{
switch (count)
{
case 0:
return;
case 1:
mesh = combineInstances[0].mesh;
transform = combineInstances[0].transform;
return;
default:
{
var cis = CombineInstanceArrayPool.Get(combineInstances);
mesh = MeshPool.Rent();
mesh.CombineMeshes(cis, true, true);
transform = Matrix4x4.identity;
cis.Clear();
return;
}
}
}
public void Clear()
{
for (var i = 0; i < combineInstances.Count; i++)
{
var inst = combineInstances[i];
MeshPool.Return(inst.mesh);
inst.mesh = null;
combineInstances[i] = inst;
}
combineInstances.Clear();
MeshPool.Return(mesh);
mesh = null;
count = 0;
hash = -1;
index = -1;
}
public void Push(Mesh mesh, Matrix4x4 transform)
{
combineInstances.Add(new CombineInstance {mesh = mesh, transform = transform});
count++;
}
}
}
fileFormatVersion: 2
guid: 9db2761424470db47b402a0ef355fcee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b0b71ffe101d12847b4a78168beeefcc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using ShaderPropertyType = Coffee.UIExtensions.AnimatableProperty.ShaderPropertyType;
namespace Coffee.UIExtensions
{
internal class AnimatedPropertiesEditor
{
private static readonly List<string> s_ActiveNames = new List<string>();
private static readonly System.Text.StringBuilder s_Sb = new System.Text.StringBuilder();
private static readonly HashSet<string> s_Names = new HashSet<string>();
private string _name;
private ShaderPropertyType _type;
static string CollectActiveNames(SerializedProperty sp, List<string> result)
{
result.Clear();
for (var i = 0; i < sp.arraySize; i++)
{
var spName = sp.GetArrayElementAtIndex(i).FindPropertyRelative("m_Name");
if (spName == null) continue;
result.Add(spName.stringValue);
}
s_Sb.Length = 0;
if (result.Count == 0)
{
s_Sb.Append("Nothing");
}
else
{
result.Aggregate(s_Sb, (a, b) => s_Sb.AppendFormat("{0}, ", b));
s_Sb.Length -= 2;
}
return s_Sb.ToString();
}
public static void DrawAnimatableProperties(SerializedProperty sp, Material[] mats)
{
bool isClicked;
using (new EditorGUILayout.HorizontalScope(GUILayout.ExpandWidth(false)))
{
var r = EditorGUI.PrefixLabel(EditorGUILayout.GetControlRect(true), new GUIContent(sp.displayName, sp.tooltip));
var text = sp.hasMultipleDifferentValues ? "-" : CollectActiveNames(sp, s_ActiveNames);
isClicked = GUI.Button(r, text, EditorStyles.popup);
}
if (!isClicked) return;
var gm = new GenericMenu();
gm.AddItem(new GUIContent("Nothing"), s_ActiveNames.Count == 0, () =>
{
sp.ClearArray();
sp.serializedObject.ApplyModifiedProperties();
});
if (!sp.hasMultipleDifferentValues)
{
for (var i = 0; i < sp.arraySize; i++)
{
var p = sp.GetArrayElementAtIndex(i);
var name = p.FindPropertyRelative("m_Name").stringValue;
var type = (ShaderPropertyType) p.FindPropertyRelative("m_Type").intValue;
AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = name, _type = type}, false);
}
}
s_Names.Clear();
foreach (var mat in mats)
{
if (!mat || !mat.shader) continue;
for (var i = 0; i < ShaderUtil.GetPropertyCount(mat.shader); i++)
{
var pName = ShaderUtil.GetPropertyName(mat.shader, i);
var type = (ShaderPropertyType) ShaderUtil.GetPropertyType(mat.shader, i);
var name = string.Format("{0} ({1})", pName, type);
if (s_Names.Contains(name)) continue;
s_Names.Add(name);
AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName, _type = type}, true);
if (type != ShaderPropertyType.Texture) continue;
AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName + "_ST", _type = ShaderPropertyType.Vector}, true);
AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName + "_HDR", _type = ShaderPropertyType.Vector}, true);
AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName + "_TexelSize", _type = ShaderPropertyType.Vector}, true);
}
}
gm.ShowAsContext();
}
private static void AddMenu(GenericMenu menu, SerializedProperty sp, AnimatedPropertiesEditor property, bool add)
{
if (add && s_ActiveNames.Contains(property._name)) return;
menu.AddItem(new GUIContent(string.Format("{0} ({1})", property._name, property._type)), s_ActiveNames.Contains(property._name), () =>
{
var index = s_ActiveNames.IndexOf(property._name);
if (0 <= index)
{
sp.DeleteArrayElementAtIndex(index);
}
else
{
sp.InsertArrayElementAtIndex(sp.arraySize);
var p = sp.GetArrayElementAtIndex(sp.arraySize - 1);
p.FindPropertyRelative("m_Name").stringValue = property._name;
p.FindPropertyRelative("m_Type").intValue = (int) property._type;
}
sp.serializedObject.ApplyModifiedProperties();
});
}
}
}
fileFormatVersion: 2
guid: 84d3b36abdafe404588035dd54784f55
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
{
"name": "Coffee.UIParticle.Editor",
"references": [
"Coffee.UIParticle"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [],
"autoReferenced": false,
"defineConstraints": []
}
\ No newline at end of file
fileFormatVersion: 2
guid: 5d8b63e9af0cd714ba7c69ce01c71ce3
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
#if !UNITY_2019_1_OR_NEWER
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEditor;
namespace Coffee.UIExtensions
{
internal static class ImportSampleMenu_UIParticle
{
private const string k_DisplayName = "UI Particle";
private const string k_JsonGuid = "823dc693d087a4b559c7e1547274cc7d";
[MenuItem("Assets/Samples/" + k_DisplayName + "/Demo")]
private static void ImportSample()
{
ImportSample(k_JsonGuid, "Demo");
}
[MenuItem("Assets/Samples/" + k_DisplayName + "/Cartoon FX & War FX Demo")]
private static void ImportSample_CFX()
{
ImportSample(k_JsonGuid, "Cartoon FX & War FX Demo");
}
private static void ImportSample(string jsonGuid, string sampleName)
{
var jsonPath = AssetDatabase.GUIDToAssetPath(jsonGuid);
var packageRoot = Path.GetDirectoryName(jsonPath).Replace('\\', '/');
var json = File.ReadAllText(jsonPath);
var version = Regex.Match(json, "\"version\"\\s*:\\s*\"([^\"]+)\"").Groups[1].Value;
var src = string.Format("{0}/Samples~/{1}", packageRoot, sampleName);
var dst = string.Format("Assets/Samples/{0}/{1}/{2}", k_DisplayName, version, sampleName);
var previousPath = GetPreviousSamplePath(k_DisplayName, sampleName);
// Remove the previous sample directory.
if (!string.IsNullOrEmpty(previousPath))
{
var msg = "A different version of the sample is already imported at\n\n"
+ previousPath
+ "\n\nIt will be deleted when you update. Are you sure you want to continue?";
if (!EditorUtility.DisplayDialog("Sample Importer", msg, "OK", "Cancel"))
return;
FileUtil.DeleteFileOrDirectory(previousPath);
var metaFile = previousPath + ".meta";
if (File.Exists(metaFile))
FileUtil.DeleteFileOrDirectory(metaFile);
}
if (!Directory.Exists(dst))
FileUtil.DeleteFileOrDirectory(dst);
var dstDir = Path.GetDirectoryName(dst);
if (!Directory.Exists(dstDir))
Directory.CreateDirectory(dstDir);
if (Directory.Exists(src))
FileUtil.CopyFileOrDirectory(src, dst);
else
throw new DirectoryNotFoundException(src);
AssetDatabase.Refresh(ImportAssetOptions.ImportRecursive);
}
private static string GetPreviousSamplePath(string displayName, string sampleName)
{
var sampleRoot = string.Format("Assets/Samples/{0}", displayName);
var sampleRootInfo = new DirectoryInfo(sampleRoot);
if (!sampleRootInfo.Exists) return null;
return sampleRootInfo.GetDirectories()
.Select(versionDir => Path.Combine(versionDir.ToString(), sampleName))
.FirstOrDefault(Directory.Exists);
}
}
}
#endif
fileFormatVersion: 2
guid: 6931172d39be3334bbf5b738ed79cd2c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 698bf3aeef88d524caf6f1798d56c52d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
namespace Coffee.UIExtensions
{
internal class UIParticleMenu
{
[MenuItem("GameObject/UI/Particle System (Empty)", false, 2018)]
private static void AddParticleEmpty(MenuCommand menuCommand)
{
// Create empty UI element.
EditorApplication.ExecuteMenuItem("GameObject/UI/Image");
var ui = Selection.activeGameObject;
Object.DestroyImmediate(ui.GetComponent<Image>());
// Add UIParticle.
var uiParticle = ui.AddComponent<UIParticle>();
uiParticle.name = "UIParticle";
uiParticle.scale = 10;
uiParticle.rectTransform.sizeDelta = Vector2.zero;
}
[MenuItem("GameObject/UI/Particle System", false, 2019)]
private static void AddParticle(MenuCommand menuCommand)
{
// Create empty UIEffect.
AddParticleEmpty(menuCommand);
var uiParticle = Selection.activeGameObject.GetComponent<UIParticle>();
// Create ParticleSystem.
EditorApplication.ExecuteMenuItem("GameObject/Effects/Particle System");
var ps = Selection.activeGameObject;
ps.transform.SetParent(uiParticle.transform, false);
ps.transform.localPosition = Vector3.zero;
// Assign default material.
var renderer = ps.GetComponent<ParticleSystemRenderer>();
var defaultMat = AssetDatabase.GetBuiltinExtraResource<Material>("Default-Particle.mat");
renderer.material = defaultMat ? defaultMat : renderer.material;
// Refresh particles.
uiParticle.RefreshParticles();
}
}
}
fileFormatVersion: 2
guid: 8010af99ccf412145a417ba374e31f4f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Profiling;
namespace Coffee.UIParticleExtensions
{
internal static class MeshHelper
{
public static List<bool> activeMeshIndices { get; private set; }
private static readonly List<CombineInstanceEx> s_CachedInstance;
private static int count;
public static void Init()
{
activeMeshIndices = new List<bool>();
}
static MeshHelper()
{
s_CachedInstance = new List<CombineInstanceEx>(8);
for (var i = 0; i < 8; i++)
{
s_CachedInstance.Add(new CombineInstanceEx());
}
}
private static CombineInstanceEx Get(int index, long hash)
{
if (0 < count && s_CachedInstance[count - 1].hash == hash)
return s_CachedInstance[count - 1];
if (s_CachedInstance.Count <= count)
{
var newInst = new CombineInstanceEx();
s_CachedInstance.Add(newInst);
}
var inst = s_CachedInstance[count];
inst.hash = hash;
if (inst.index != -1) return inst;
inst.index = index;
count++;
return inst;
}
public static Mesh GetTemporaryMesh()
{
return MeshPool.Rent();
}
public static void Push(int index, long hash, Mesh mesh, Matrix4x4 transform)
{
if (mesh.vertexCount <= 0)
{
DiscardTemporaryMesh(mesh);
return;
}
Profiler.BeginSample("[UIParticle] MeshHelper > Get CombineInstanceEx");
var inst = Get(index, hash);
Profiler.EndSample();
Profiler.BeginSample("[UIParticle] MeshHelper > Push To Mesh Helper");
inst.Push(mesh, transform);
Profiler.EndSample();
activeMeshIndices[inst.index] = true;
}
public static void Clear()
{
count = 0;
activeMeshIndices.Clear();
foreach (var inst in s_CachedInstance)
{
inst.Clear();
}
}
public static void CombineMesh(Mesh result)
{
if (count == 0) return;
for (var i = 0; i < count; i++)
{
Profiler.BeginSample("[UIParticle] MeshHelper > Combine Mesh Internal");
s_CachedInstance[i].Combine();
Profiler.EndSample();
}
Profiler.BeginSample("[UIParticle] MeshHelper > Combine Mesh");
var cis = CombineInstanceArrayPool.Get(s_CachedInstance, count);
result.CombineMeshes(cis, false, true);
cis.Clear();
Profiler.EndSample();
result.RecalculateBounds();
}
public static void DiscardTemporaryMesh(Mesh mesh)
{
MeshPool.Return(mesh);
}
}
}
fileFormatVersion: 2
guid: aa45559f8dc317f4780d87e69c9a71d4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections.Generic;
using UnityEngine;
namespace Coffee.UIParticleExtensions
{
internal class ModifiedMaterial
{
private static readonly List<MatEntry> s_Entries = new List<MatEntry>();
public static Material Add(Material baseMat, Texture texture, int id)
{
MatEntry e;
for (var i = 0; i < s_Entries.Count; ++i)
{
e = s_Entries[i];
if (e.baseMat != baseMat || e.texture != texture || e.id != id) continue;
++e.count;
return e.customMat;
}
e = new MatEntry();
e.count = 1;
e.baseMat = baseMat;
e.texture = texture;
e.id = id;
e.customMat = new Material(baseMat);
e.customMat.hideFlags = HideFlags.HideAndDontSave;
if (texture)
e.customMat.mainTexture = texture;
s_Entries.Add(e);
// Debug.LogFormat(">>>> ModifiedMaterial.Add -> count = {0} {1} {2} {3}", s_Entries.Count, baseMat, texture, id);
return e.customMat;
}
public static void Remove(Material customMat)
{
if (!customMat) return;
for (var i = 0; i < s_Entries.Count; ++i)
{
var e = s_Entries[i];
if (e.customMat != customMat) continue;
if (--e.count == 0)
{
// Debug.LogFormat(">>>> ModifiedMaterial.Add -> count = {0} {1} {2} {3}", s_Entries.Count - 1, e.customMat, e.texture, e.id);
DestroyImmediate(e.customMat);
e.baseMat = null;
e.texture = null;
s_Entries.RemoveAt(i);
}
break;
}
}
private static void DestroyImmediate(Object obj)
{
if (!obj) return;
if (Application.isEditor)
Object.DestroyImmediate(obj);
else
Object.Destroy(obj);
}
private class MatEntry
{
public Material baseMat;
public Material customMat;
public int count;
public Texture texture;
public int id;
}
}
}
fileFormatVersion: 2
guid: eda92d0d666e48b48ae74cafc020395f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
fileFormatVersion: 2
guid: 18fe414fec9caac42aa01a056ad915f5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: -100
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: f93769045fa549a4d8b53cb2c01e35da
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: -100
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
using Object = UnityEngine.Object;
namespace Coffee.UIParticleExtensions
{
internal static class SpriteExtensions
{
#if UNITY_EDITOR
private static Type tSpriteEditorExtension =
Type.GetType("UnityEditor.Experimental.U2D.SpriteEditorExtension, UnityEditor")
?? Type.GetType("UnityEditor.U2D.SpriteEditorExtension, UnityEditor");
private static MethodInfo miGetActiveAtlasTexture = tSpriteEditorExtension
.GetMethod("GetActiveAtlasTexture", BindingFlags.Static | BindingFlags.NonPublic);
public static Texture2D GetActualTexture(this Sprite self)
{
if (!self) return null;
if (Application.isPlaying) return self.texture;
var ret = miGetActiveAtlasTexture.Invoke(null, new[] {self}) as Texture2D;
return ret ? ret : self.texture;
}
#else
internal static Texture2D GetActualTexture(this Sprite self)
{
return self ? self.texture : null;
}
#endif
}
internal static class ListExtensions
{
public static bool SequenceEqualFast(this List<bool> self, List<bool> value)
{
if (self.Count != value.Count) return false;
for (var i = 0; i < self.Count; ++i)
{
if (self[i] != value[i]) return false;
}
return true;
}
public static int CountFast(this List<bool> self)
{
var count = 0;
for (var i = 0; i < self.Count; ++i)
{
if (self[i]) count++;
}
return count;
}
public static bool AnyFast<T>(this List<T> self) where T : Object
{
for (var i = 0; i < self.Count; ++i)
{
if (self[i]) return true;
}
return false;
}
public static bool AnyFast<T>(this List<T> self, Predicate<T> predicate) where T : Object
{
for (var i = 0; i < self.Count; ++i)
{
if (self[i] && predicate(self[i])) return true;
}
return false;
}
}
internal static class MeshExtensions
{
// static readonly List<Color32> s_Colors = new List<Color32>();
// public static void ModifyColorSpaceToLinear(this Mesh self)
// {
// self.GetColors(s_Colors);
//
// for (var i = 0; i < s_Colors.Count; i++)
// s_Colors[i] = ((Color) s_Colors[i]).gamma;
//
// self.SetColors(s_Colors);
// s_Colors.Clear();
// }
public static void Clear(this CombineInstance[] self)
{
for (var i = 0; i < self.Length; i++)
{
MeshPool.Return(self[i].mesh);
self[i].mesh = null;
}
}
}
internal static class MeshPool
{
private static readonly Stack<Mesh> s_Pool = new Stack<Mesh>(32);
private static readonly HashSet<int> s_HashPool = new HashSet<int>();
public static void Init()
{
}
static MeshPool()
{
for (var i = 0; i < 32; i++)
{
var m = new Mesh();
m.MarkDynamic();
s_Pool.Push(m);
s_HashPool.Add(m.GetInstanceID());
}
}
public static Mesh Rent()
{
Mesh m;
while (0 < s_Pool.Count)
{
m = s_Pool.Pop();
if (m)
{
s_HashPool.Remove(m.GetInstanceID());
return m;
}
}
m = new Mesh();
m.MarkDynamic();
return m;
}
public static void Return(Mesh mesh)
{
if (!mesh) return;
var id = mesh.GetInstanceID();
if (s_HashPool.Contains(id)) return;
mesh.Clear(false);
s_Pool.Push(mesh);
s_HashPool.Add(id);
}
}
internal static class CombineInstanceArrayPool
{
private static readonly Dictionary<int, CombineInstance[]> s_Pool;
public static void Init()
{
s_Pool.Clear();
}
static CombineInstanceArrayPool()
{
s_Pool = new Dictionary<int, CombineInstance[]>();
}
public static CombineInstance[] Get(List<CombineInstance> src)
{
CombineInstance[] dst;
var count = src.Count;
if (!s_Pool.TryGetValue(count, out dst))
{
dst = new CombineInstance[count];
s_Pool.Add(count, dst);
}
for (var i = 0; i < src.Count; i++)
{
dst[i].mesh = src[i].mesh;
dst[i].transform = src[i].transform;
}
return dst;
}
public static CombineInstance[] Get(List<CombineInstanceEx> src, int count)
{
CombineInstance[] dst;
if (!s_Pool.TryGetValue(count, out dst))
{
dst = new CombineInstance[count];
s_Pool.Add(count, dst);
}
for (var i = 0; i < count; i++)
{
dst[i].mesh = src[i].mesh;
dst[i].transform = src[i].transform;
}
return dst;
}
}
internal static class ParticleSystemExtensions
{
public static void SortForRendering(this List<ParticleSystem> self, Transform transform, bool sortByMaterial)
{
self.Sort((a, b) =>
{
var tr = transform;
var aRenderer = a.GetComponent<ParticleSystemRenderer>();
var bRenderer = b.GetComponent<ParticleSystemRenderer>();
// Render queue: ascending
var aMat = aRenderer.sharedMaterial ?? aRenderer.trailMaterial;
var bMat = bRenderer.sharedMaterial ?? bRenderer.trailMaterial;
if (!aMat && !bMat) return 0;
if (!aMat) return -1;
if (!bMat) return 1;
if (sortByMaterial)
return aMat.GetInstanceID() - bMat.GetInstanceID();
if (aMat.renderQueue != bMat.renderQueue)
return aMat.renderQueue - bMat.renderQueue;
// Sorting layer: ascending
if (aRenderer.sortingLayerID != bRenderer.sortingLayerID)
return aRenderer.sortingLayerID - bRenderer.sortingLayerID;
// Sorting order: ascending
if (aRenderer.sortingOrder != bRenderer.sortingOrder)
return aRenderer.sortingOrder - bRenderer.sortingOrder;
// Z position & sortingFudge: descending
var aTransform = a.transform;
var bTransform = b.transform;
var aPos = tr.InverseTransformPoint(aTransform.position).z + aRenderer.sortingFudge;
var bPos = tr.InverseTransformPoint(bTransform.position).z + bRenderer.sortingFudge;
if (!Mathf.Approximately(aPos, bPos))
return (int) Mathf.Sign(bPos - aPos);
return (int) Mathf.Sign(GetIndex(self, a) - GetIndex(self, b));
});
}
private static int GetIndex(IList<ParticleSystem> list, Object ps)
{
for (var i = 0; i < list.Count; i++)
{
if (list[i].GetInstanceID() == ps.GetInstanceID()) return i;
}
return 0;
}
public static long GetMaterialHash(this ParticleSystem self, bool trail)
{
if (!self) return 0;
var r = self.GetComponent<ParticleSystemRenderer>();
var mat = trail ? r.trailMaterial : r.sharedMaterial;
if (!mat) return 0;
var tex = trail ? null : self.GetTextureForSprite();
return ((long) mat.GetHashCode() << 32) + (tex ? tex.GetHashCode() : 0);
}
public static Texture2D GetTextureForSprite(this ParticleSystem self)
{
if (!self) return null;
// Get sprite's texture.
var tsaModule = self.textureSheetAnimation;
if (!tsaModule.enabled || tsaModule.mode != ParticleSystemAnimationMode.Sprites) return null;
for (var i = 0; i < tsaModule.spriteCount; i++)
{
var sprite = tsaModule.GetSprite(i);
if (!sprite) continue;
return sprite.GetActualTexture();
}
return null;
}
public static void Exec(this List<ParticleSystem> self, Action<ParticleSystem> action)
{
self.RemoveAll(p => !p);
self.ForEach(action);
}
}
}
fileFormatVersion: 2
guid: 54d22dda826793f40922af81f2aa4661
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -36,7 +36,7 @@ Material: ...@@ -36,7 +36,7 @@ Material:
- Vector1_037422ac7c3343b3b7493dead063f9bb: 0.006 - Vector1_037422ac7c3343b3b7493dead063f9bb: 0.006
- Vector1_7fc372182bde42b39d4fce1ca0ef8b6e: 6.8 - Vector1_7fc372182bde42b39d4fce1ca0ef8b6e: 6.8
- Vector1_dcb7b53c006f40ef9ae4c2c1d71198be: 0.5 - Vector1_dcb7b53c006f40ef9ae4c2c1d71198be: 0.5
- _Alpha: 0.0015600007 - _Alpha: 0.00576
m_Colors: m_Colors:
- Color_7b883b4cd7c248a580d2475d1da9ed40: {r: 0, g: 65110.777, b: 259086.64, a: 0} - Color_7b883b4cd7c248a580d2475d1da9ed40: {r: 0, g: 65110.777, b: 259086.64, a: 0}
- _AtmosphereColor: {r: 0, g: 30840.47, b: 262144, a: 1} - _AtmosphereColor: {r: 0, g: 30840.47, b: 262144, a: 1}
......
...@@ -122,6 +122,6 @@ Material: ...@@ -122,6 +122,6 @@ Material:
m_Colors: m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1} - _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1} - _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 2.9876184, g: 2.6923993, b: 1.53514, a: 3.011236} - _EmissionColor: {r: 1.0303168, g: 0.9285069, b: 0.52941185, a: 1.0384617}
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} - _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
m_BuildTextureStacks: [] m_BuildTextureStacks: []
{ {
"dependencies": { "dependencies": {
"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git",
"com.unity.2d.sprite": "1.0.0", "com.unity.2d.sprite": "1.0.0",
"com.unity.cinemachine": "2.6.11", "com.unity.cinemachine": "2.6.11",
"com.unity.collab-proxy": "1.5.7", "com.unity.collab-proxy": "1.5.7",
......
{ {
"dependencies": { "dependencies": {
"com.coffee.ui-particle": {
"version": "https://github.com/mob-sakai/ParticleEffectForUGUI.git",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "2e4d80bc1cbbfe5400fb052778c65bcccc505abd"
},
"com.unity.2d.sprite": { "com.unity.2d.sprite": {
"version": "1.0.0", "version": "1.0.0",
"depth": 0, "depth": 0,
......
...@@ -420,6 +420,9 @@ PlayerSettings: ...@@ -420,6 +420,9 @@ PlayerSettings:
- m_BuildTarget: iOSSupport - m_BuildTarget: iOSSupport
m_APIs: 10000000 m_APIs: 10000000
m_Automatic: 1 m_Automatic: 1
- m_BuildTarget: AndroidPlayer
m_APIs: 0b00000015000000
m_Automatic: 1
m_BuildTargetVRSettings: [] m_BuildTargetVRSettings: []
openGLRequireES31: 0 openGLRequireES31: 0
openGLRequireES31AEP: 0 openGLRequireES31AEP: 0
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"m_SelectedPackage": { "m_SelectedPackage": {
"deviceId": "emulator-5554", "deviceId": "emulator-5554",
"name": "negaxy.galaxypuzzle.galazysmash", "name": "negaxy.galaxypuzzle.galazysmash",
"processId": 6747, "processId": 2843,
"exited": false "exited": false
}, },
"m_SelectedPriority": 0, "m_SelectedPriority": 0,
...@@ -54,6 +54,18 @@ ...@@ -54,6 +54,18 @@
"deviceId": "emulator-5554", "deviceId": "emulator-5554",
"name": "negaxy.galaxypuzzle.galazysmash", "name": "negaxy.galaxypuzzle.galazysmash",
"processId": 6747, "processId": 6747,
"exited": true
},
{
"deviceId": "emulator-5554",
"name": "negaxy.galaxypuzzle.galazysmash",
"processId": 10467,
"exited": true
},
{
"deviceId": "emulator-5554",
"name": "negaxy.galaxypuzzle.galazysmash",
"processId": 2843,
"exited": false "exited": false
} }
], ],
......
...@@ -27,10 +27,10 @@ EditorUserSettings: ...@@ -27,10 +27,10 @@ EditorUserSettings:
value: 22424703114646743e294c0b1e25561e1f03016a1f3933313f2c5d00f2e1373dadd435ece93f2c733403e6324a2b0f36e613 value: 22424703114646743e294c0b1e25561e1f03016a1f3933313f2c5d00f2e1373dadd435ece93f2c733403e6324a2b0f36e613
flags: 0 flags: 0
RecentlyUsedScenePath-7: RecentlyUsedScenePath-7:
value: 22424703114646743e294c0b1e25561e1f03016a1f3933313f2c5d00f2e1373dadd435ece93f2c73310de2394a2b0f36e613 value: 22424703114646743e294c0b1e25561e1f03016a1f3933313f2c5d00f2e1373dadd435ece93f2c730d07fc28440d0a36fe06471ef8021e12
flags: 0 flags: 0
RecentlyUsedScenePath-8: RecentlyUsedScenePath-8:
value: 22424703114646743e294c0b1e25561e1f03016a1f3933313f2c5d00f2e1373dadd435ece93f2c730d07fc28440d0a36fe06471ef8021e12 value: 22424703114646743e294c0b1e25561e1f03016a1f3933313f2c5d00f2e1373dadd435ece93f2c73310de2394a2b0f36e613
flags: 0 flags: 0
RecentlyUsedScenePath-9: RecentlyUsedScenePath-9:
value: 22424703114646743e294c0b1e25561e1f03016a1f3933313f2c5d00f2e1373dadd435ece93f2c733f0bfd2f10320e3ef603070cb81e04020517 value: 22424703114646743e294c0b1e25561e1f03016a1f3933313f2c5d00f2e1373dadd435ece93f2c733f0bfd2f10320e3ef603070cb81e04020517
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment