Database Support

Refactored almost everything, but most importantly we now integrate with RethinkDB for game data.
This commit is contained in:
hyperion51 2020-03-22 19:05:26 +00:00
commit 0b46d5ee39
839 changed files with 77349 additions and 112660 deletions

View file

@ -1,494 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using MessagePack;
using UniRx;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Audio;
using static Unity.Mathematics.math;
using static Unity.Mathematics.noise;
using Object = UnityEngine.Object;
public interface IItemBehavior
{
void Update(float delta);
void FixedUpdate(float delta);
Ship Ship { get; }
Gear Item { get; }
IItemBehaviorData Data { get; }
}
public interface IActivatedItemBehavior : IItemBehavior
{
void Activate();
void Deactivate();
}
[Inspectable]
[Union(0, typeof(CannonBehaviorData))]
[Union(1, typeof(MissileBehaviorData))]
[Union(2, typeof(ReactorBehaviorData))]
// [Union(3, typeof(PlusUltraBehaviorData))]
[Union(4, typeof(AfterburnerBehaviorData))]
[Union(5, typeof(SensorBehaviorData))]
public interface IItemBehaviorData
{
IItemBehavior CreateInstance(Ship ship, Gear item);
// PerformanceStat[] DynamicStats { get; }
//Type ItemType { get; }
}
[Inspectable]
[MessagePackObject]
public class SensorBehaviorData : IItemBehaviorData
{
[Inspectable] [Key("radiance")] public PerformanceStat Radiance;
[Inspectable] [Key("masking")] public PerformanceStat RadianceMasking;
[Inspectable] [Key("sensitivity")] public PerformanceStat Sensitivity;
[Inspectable] [Key("range")] public PerformanceStat Range;
public IItemBehavior CreateInstance(Ship ship, Gear item)
{
return new SensorBehavior(this, ship, item);
}
[IgnoreMember] public PerformanceStat[] DynamicStats => new[] {Radiance, Sensitivity};
}
public class SensorBehavior : IItemBehavior
{
private SensorBehaviorData _data;
public Ship Ship { get; }
public Gear Item { get; }
public IItemBehaviorData Data => _data;
public SensorBehavior(SensorBehaviorData data, Ship ship, Gear item)
{
_data = data;
Ship = ship;
Item = item;
}
public void Update(float delta)
{
// var ship = Hardpoint.Ship.Ship.transform;
// var contacts =
// Physics.OverlapSphere(ship.position, _data.Range.Evaluate(Hardpoint)).Where(c=>c.attachedRigidbody?.GetComponent<Targetable>()!=null).Select(c=>c.attachedRigidbody.GetComponent<Targetable>());
// foreach (var contact in contacts)
// {
// var diff = (contact.transform.position - ship.position).Flatland();
// var angle = acos(dot(ship.forward.Flatland().normalized,
// diff.normalized)) / (float)PI;
// var sens = _data.Sensitivity.Evaluate(Hardpoint) *
// Hardpoint.Ship.HullData.VisibilityCurve.Evaluate(saturate(angle));
// var vis = contact.Visibility / diff.sqrMagnitude;
// if(vis > 1/sens)
// Hardpoint.Ship.Contacts[contact] = Time.time;
// }
//
// Hardpoint.Ship.VisibilitySources[this] = _data.Radiance.Evaluate(Hardpoint) / _data.RadianceMasking.Evaluate(Hardpoint);
// TODO: Handle Active Detection / Visibility From Reflected Radiance
}
public void FixedUpdate(float delta)
{
}
}
[Inspectable]
[MessagePackObject]
public class AfterburnerBehaviorData : IItemBehaviorData
{
[Inspectable] [Key("thrust")] public PerformanceStat ThrustModifier;
[Inspectable] [Key("speed")] public PerformanceStat SpeedModifier;
[Inspectable] [Key("torque")] public PerformanceStat TorqueModifier;
public IItemBehavior CreateInstance(Ship ship, Gear item)
{
return new AfterburnerBehavior(this, ship, item);
}
}
public class AfterburnerBehavior : IActivatedItemBehavior
{
private List<Dictionary<IItemBehavior,float>> _modifiers = new List<Dictionary<IItemBehavior, float>>();
private AfterburnerBehaviorData _data;
public Ship Ship { get; }
public Gear Item { get; }
public IItemBehaviorData Data => _data;
public AfterburnerBehavior(AfterburnerBehaviorData data, Ship ship, Gear item)
{
_data = data;
Ship = ship;
Item = item;
}
public void Update(float delta)
{
}
public void FixedUpdate(float delta)
{
}
public void Activate()
{
var thrustMod = (Ship.GetEquipped(HardpointType.Thruster).EquippedItemData as Thruster).Thrust.GetScaleModifiers(Ship);
_modifiers.Add(thrustMod);
thrustMod.Add(this,_data.ThrustModifier.Evaluate(Item, Ship));
var speedMod = (Ship.Hull.EquippedItemData as Hull).TopSpeed.GetScaleModifiers(Ship);
_modifiers.Add(speedMod);
speedMod.Add(this,_data.SpeedModifier.Evaluate(Item, Ship));
var torqueMod = (Ship.GetEquipped(HardpointType.Thruster).EquippedItemData as Thruster).Torque.GetScaleModifiers(Ship);
_modifiers.Add(torqueMod);
torqueMod.Add(this,_data.TorqueModifier.Evaluate(Item, Ship));
Ship.ForceThrust = true;
}
public void Deactivate()
{
Ship.ForceThrust = false;
foreach (var mod in _modifiers)
{
mod.Remove(this);
}
_modifiers.Clear();
}
}
[Inspectable]
[MessagePackObject]
public class CannonBehaviorData : IItemBehaviorData
{
[MessagePackFormatter(typeof(UnityGameObjectFormatter))]
[Inspectable] [Key("bullet")] public GameObject BulletPrefab;
// [MessagePackFormatter(typeof(ClipListFormatter))]
// [Inspectable] [Key("sounds")] public List<AudioClip> Sounds;
[Inspectable] [Key("damageType")] public ProjectileType DamageType;
[Inspectable] [Key("burstCount")] public int BurstCount;
[Inspectable] [Key("burstTime")] public PerformanceStat BurstTime;
[Inspectable] [Key("bulletRange")] public PerformanceStat Range;
[Inspectable] [Key("spread")] public PerformanceStat Spread;
[Inspectable] [Key("bulletInherit")] public float Inherit;
[Inspectable] [Key("deflection")] public float Deflection;
[Inspectable] [Key("visibility")] public PerformanceStat Visibility;
[Inspectable] [Key("visibilityDecay")]public PerformanceStat VisibilityDecay;
[Inspectable] [Key("bulletVelocity")] public PerformanceStat Velocity;
[Inspectable] [Key("cooldown")] public PerformanceStat Cooldown;
[Inspectable] [Key("damage")] public PerformanceStat Damage;
[Inspectable] [Key("heat")] public PerformanceStat Heat;
public IItemBehavior CreateInstance(Ship ship, Gear item)
{
return new CannonBehavior(this, ship, item);
}
[IgnoreMember] public PerformanceStat[] DynamicStats => new[] {BurstTime, Range, Spread, Velocity, Cooldown, Damage};
}
public class CannonBehavior : IActivatedItemBehavior
{
private bool _firing;
private float _cooldown; // normalized
private CannonBehaviorData _cannon;
public Ship Ship { get; }
public Gear Item { get; }
private float _firingVisibility;
public CannonBehavior(CannonBehaviorData c, Ship ship, Gear item)
{
_cannon = c;
Ship = ship;
Item = item;
}
public void Activate()
{
// Debug.Log("Activating Cannon");
// _firing = true;
// Observable.EveryUpdate().TakeWhile(_ => _firing).Subscribe(_ =>
// {
// // Debug.Log($"Updating Observable {_cooldown}");
// if (_cooldown < 0)
// {
// _cooldown = 1;
// Fire(0);
// if(_cannon.BurstCount>1)
// Observable.Interval(TimeSpan.FromSeconds(_cannon.BurstTime.Evaluate(Hardpoint) / (_cannon.BurstCount-1))).Take(_cannon.BurstCount-1)
// .Subscribe(l => Fire(l+1));
// }
// });
}
private void Fire(long b)
{
// _firingVisibility += _cannon.Visibility.Evaluate(Hardpoint);
// Hardpoint.Temperature += _cannon.Heat.Evaluate(Hardpoint) / Hardpoint.HeatCapacity;
// var inst = GameObject.Instantiate(_cannon.BulletPrefab).transform;
// Physics.IgnoreCollision(Hardpoint.Ship.Ship.GetComponent<Collider>(), inst.GetComponent<Collider>());
// var bullet = inst.GetComponent<Bullet>();
// bullet.Target = Hardpoint.Ship.Ship.Target;
// bullet.Source = Hardpoint.Ship.Ship.Hitpoints;
// bullet.Lifetime = _cannon.Range.Evaluate(Hardpoint) / _cannon.Velocity.Evaluate(Hardpoint);
// bullet.Damage = _cannon.Damage.Evaluate(Hardpoint);
// inst.position = Hardpoint.Proxy.position;
// inst.rotation = Hardpoint.Proxy.rotation;
// inst.GetComponent<Rigidbody>().velocity = _cannon.Velocity.Evaluate(Hardpoint) * Vector3.RotateTowards(-inst.forward, Hardpoint.Ship.Ship.Direction, _cannon.Deflection * Mathf.Deg2Rad, 1);
// Hardpoint.Ship.Ship.AudioSource.PlayOneShot(_cannon.Sounds.RandomElement());
// Debug.Log($"Firing bullet {b}");
}
public void Deactivate()
{
_firing = false;
}
public void Update(float delta)
{
_cooldown -= delta / _cannon.Cooldown.Evaluate(Item, Ship);
if (_firingVisibility < 0.01f)
{
Ship.VisibilitySources.Remove(this);
}
}
public void FixedUpdate(float delta)
{
_firingVisibility *= _cannon.VisibilityDecay.Evaluate(Item, Ship);
}
public IItemBehaviorData Data => _cannon;
}
[Inspectable]
[MessagePackObject]
public class MissileBehaviorData : IItemBehaviorData
{
// [MessagePackFormatter(typeof(UnityGameObjectFormatter))]
// [Inspectable] [Key("missile")] public GameObject MissilePrefab;
// [MessagePackFormatter(typeof(ClipListFormatter))]
// [Inspectable] [Key("sounds")] public List<AudioClip> Sounds;
// [MessagePackFormatter(typeof(UnityAudioClipFormatter))]
// [Inspectable] [Key("beepSound")] public AudioClip BeepSound;
// [Inspectable] [Key("beepCount")] public int Beeps;
[Inspectable] [Key("damageType")] public ProjectileType DamageType;
[Inspectable] [Key("burstCount")] public int BurstCount;
[Inspectable] [Key("burstTime")] public PerformanceStat BurstTime;
[Inspectable] [Key("range")] public PerformanceStat Range;
[Inspectable] [Key("guidance")] public AnimationCurve GuidanceCurve;
[Inspectable] [Key("thrustCurve")] public AnimationCurve ThrustCurve;
[Inspectable] [Key("liftCurve")] public AnimationCurve LiftCurve;
[Inspectable] [Key("thrust")] public PerformanceStat Thrust;
[Inspectable] [Key("deflection")] public float Deflection;
[Inspectable] [Key("lockOnBuffer")] public float LockOnDegrees;
[Inspectable] [Key("frequency")] public float DodgeFrequency;
[Inspectable] [Key("visibility")] public PerformanceStat Visibility;
[Inspectable] [Key("launchSpeed")] public PerformanceStat LaunchSpeed;
[Inspectable] [Key("missileSpeed")] public PerformanceStat MissileSpeed;
[Inspectable] [Key("cooldown")] public PerformanceStat Cooldown;
[Inspectable] [Key("lockOnTime")] public PerformanceStat LockOnTime;
[Inspectable] [Key("damage")] public PerformanceStat Damage;
[Inspectable] [Key("heat")] public PerformanceStat Heat;
public IItemBehavior CreateInstance(Ship ship, Gear item)
{
return new MissileBehavior(this, ship, item);
}
[IgnoreMember] public PerformanceStat[] DynamicStats => new[] {BurstTime, Range, Thrust, LaunchSpeed, MissileSpeed, Cooldown, Damage};
}
public class MissileBehavior : IActivatedItemBehavior
{
private bool _locking;
private float _lockingTimer;
private float _cooldown; // normalized
private bool _locked;
private MissileBehaviorData _missile;
public Ship Ship { get; }
public Gear Item { get; }
private float _firingVisibility;
private AudioSource _audio;
public MissileBehavior(MissileBehaviorData m, Ship ship, Gear item)
{
_missile = m;
Ship = ship;
Item = item;
// _audio = hp.Proxy.GetComponent<AudioSource>();
// if(_audio==null)
// _audio = hp.Proxy.gameObject.AddComponent<AudioSource>();
// _audio.clip = _missile.BeepSound;
// _audio.loop = true;
// _audio.volume = .5f;
}
public void Activate()
{
_locking = true;
_lockingTimer = 1;
}
private void Fire(long b)
{
// _firingVisibility += _missile.Visibility.Evaluate(Hardpoint);
// Hardpoint.Temperature += _missile.Heat.Evaluate(Hardpoint) / Hardpoint.HeatCapacity;
// var inst = GameObject.Instantiate(_missile.MissilePrefab).transform;
// var missile = inst.GetComponent<Bullet>();
// missile.Target = Hardpoint.Ship.Ship.Target;
// missile.Source = Hardpoint.Ship.Ship.Hitpoints;
// missile.Lifetime = _missile.Range.Evaluate(Hardpoint) / _missile.MissileSpeed.Evaluate(Hardpoint);
// missile.Damage = _missile.Damage.Evaluate(Hardpoint);
// inst.position = Hardpoint.Proxy.position;
// inst.rotation = Hardpoint.Proxy.rotation;
// inst.GetComponent<Rigidbody>().velocity = _missile.LaunchSpeed.Evaluate(Hardpoint) * Hardpoint.Proxy.forward;
// Physics.IgnoreCollision(Hardpoint.Ship.Ship.GetComponent<Collider>(), inst.GetComponent<Collider>());
// var proj = inst.gameObject.AddComponent<GuidedProjectile>();
// proj.GuidanceCurve = _missile.GuidanceCurve;
// proj.ThrustCurve = _missile.ThrustCurve;
// proj.LiftCurve = _missile.LiftCurve;
// proj.TopSpeed = _missile.MissileSpeed.Evaluate(Hardpoint);
// proj.Frequency = _missile.DodgeFrequency;
// proj.Target = Hardpoint.Ship.Ship.Target;
// proj.Source = Hardpoint.Ship.Ship.Hitpoints;
// proj.Thrust = _missile.Thrust.Evaluate(Hardpoint);
// _audio.PlayOneShot(_missile.Sounds.RandomElement());
// Debug.Log($"Firing bullet {b}");
}
public void Deactivate()
{
// if (_lockingTimer < 0)
// {
// Fire(0);
// if(_missile.BurstCount>1)
// Observable.Interval(TimeSpan.FromSeconds(_missile.BurstTime.Evaluate(Hardpoint) / (_missile.BurstCount-1))).Take(_missile.BurstCount-1)
// .Subscribe(l => Fire(l+1));
// _lockingTimer = _cooldown = 1;
// _locking = _locked = false;
// _audio.Stop();
// }
// _locking = false;
// _lockingTimer = 1;
}
public void Update(float delta)
{
// if (Ship.Target == null)
// return;
//
// if (_locking && _cooldown < 0)
// {
// //if the crosshair stays under a certain LockOnBuffer distance for a certain amount of time (LockOnTime)
// if (acos(Vector2.Dot(Ship.Direction, (Ship.Target.transform.position-Ship.transform.position).normalized)) * Mathf.Rad2Deg < _missile.LockOnDegrees)
// {
// var d = delta / _missile.LockOnTime.Evaluate(Hardpoint);
// _lockingTimer -= d;
// if (!_locked && _lockingTimer < 0)
// {
// _locked = true;
// _audio.Play();
// } else if(Mathf.Repeat(_lockingTimer,1.0f/(_missile.Beeps+1))-d<0)
// GameManager.Instance.InterfaceAudio.PlayOneShot(_missile.BeepSound);
// }
// else
// {
// _lockingTimer = 1;
// _audio.Stop();
// }
// }
// else
// {
// _cooldown -= delta / _missile.Cooldown.Evaluate(Hardpoint);
// }
//
//
// if (_firingVisibility > 0.01f)
// {
// Hardpoint.Ship.Visibility += _firingVisibility;
// _firingVisibility = 0;
// }
}
public void FixedUpdate(float delta)
{
}
public IItemBehaviorData Data => _missile;
}
[MessagePackObject]
public class ReactorBehaviorData : IItemBehaviorData
{
[Inspectable] [Key("charge")] public PerformanceStat Charge;
[Inspectable] [Key("capacitance")] public PerformanceStat Capacitance;
[Inspectable] [Key("efficiency")] public PerformanceStat Efficiency;
[Inspectable] [Key("overload")] public PerformanceStat OverloadEfficiency;
[Inspectable] [Key("underload")] public PerformanceStat UnderloadRecovery;
public IItemBehavior CreateInstance(Ship ship, Gear item)
{
return new ReactorBehavior(this, ship, item);
}
[IgnoreMember] public PerformanceStat[] DynamicStats => new[] {Charge, Efficiency};
}
public class ReactorBehavior : IItemBehavior
{
private ReactorBehaviorData _data;
public Ship Ship { get; }
public Gear Item { get; }
public IItemBehaviorData Data => _data;
public ReactorBehavior(ReactorBehaviorData data, Ship ship, Gear item)
{
_data = data;
Ship = ship;
Item = item;
}
public void FixedUpdate(float delta)
{
var cap = _data.Capacitance.Evaluate(Item, Ship);
var charge = _data.Charge.Evaluate(Item, Ship) * delta;
var efficiency = _data.Efficiency.Evaluate(Item, Ship);
Ship.AddHeat(charge / efficiency);
Ship.Charge += charge;
if (Ship.Charge > cap)
{
Ship.AddHeat(-(Ship.Charge - cap) / efficiency * (1 - 1 / _data.UnderloadRecovery.Evaluate(Item, Ship)));
Ship.Charge = cap;
}
if (Ship.Charge < 0)
{
Ship.AddHeat( -Ship.Charge / (_data.OverloadEfficiency.Evaluate(Item, Ship)));
Ship.Charge = 0;
}
}
public void Update(float delta)
{
}
}

View file

@ -1,25 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UI.Extensions.ColorPicker;
public class ColorButton : MonoBehaviour {
public ColorChangedEvent OnColorChanged = new ColorChangedEvent();
// Use this for initialization
void Start () {
var colorPicker = transform.root.GetComponentInChildren<ColorPickerControl>(true);
var image = GetComponent<Image>();
GetComponent<Button>().onClick.AddListener(() =>
{
colorPicker.gameObject.SetActive(true);
colorPicker.CurrentColor = image.color;
colorPicker.onValueChanged.AddListener(col =>
{
image.color = col;
OnColorChanged.Invoke(col);
});
});
}
}

View file

@ -1,131 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using MessagePack;
using UniRx;
using UnityEditor;
using UnityEngine;
#if UNITY_EDITOR
[InitializeOnLoad]
#endif
public class Database
{
public static event Action OnDataUpdate;
private static Dictionary<Guid, IDatabaseEntry> Entries = new Dictionary<Guid, IDatabaseEntry>();
private static Dictionary<Type, Dictionary<Guid, IDatabaseEntry>> Types = new Dictionary<Type, Dictionary<Guid, IDatabaseEntry>>();
private static DirectoryInfo _dir;
private static IDatabaseEntry Load(string path)
{
var bytes = File.ReadAllBytes(path);
// Debug.Log("Deserializing item: \n" + MessagePackSerializer.ToJson(bytes));
try
{
var entry = MessagePackSerializer.Deserialize<IDatabaseEntry>(bytes);
if (entry != null)
{
Entries[entry.GetId()] = entry;
var type = entry.GetType();
var types = type.FindInterfaces((_, __) => true, null).Append(type);
foreach (var t in types)
{
if(!Types.ContainsKey(t))
Types[t] = new Dictionary<Guid, IDatabaseEntry>();
Types[t][entry.GetId()] = entry;
}
OnDataUpdate?.Invoke();
}
return entry;
}
catch (Exception e)
{
Debug.Log($"Encountered exception while reading item {path.Split('\\').Last()}:\n{MessagePackSerializer.SerializeToJson(bytes)}\n{e.StackTrace}");
return null;
}
}
public static IEnumerable<IDatabaseEntry> AllEntries => Entries.Values;
public static IDatabaseEntry Get(Guid guid)
{
IDatabaseEntry entry;
Entries.TryGetValue(guid, out entry);
return entry;
}
public static T Get<T>(Guid guid) where T : IDatabaseEntry
{
IDatabaseEntry entry;
Types[typeof(T)].TryGetValue(guid, out entry);
return (T) entry;
}
public static IEnumerable<T> GetAll<T>()
{
return Types[typeof(T)].Values.Cast<T>();
}
public static void Save(IDatabaseEntry entry)
{
// Debug.Log("Serializing item: \n" + item.ToJson());
var dir = new DirectoryInfo(Path.Combine(_dir.FullName, entry.GetType().Name));
if(!dir.Exists)
dir.Create();
File.WriteAllBytes(Path.Combine(dir.FullName, entry.GetId().ToString()), entry.Serialize());
}
public static void Duplicate(IDatabaseEntry entry)
{
var oldID = entry.Entry.ID;
entry.Entry.ID = Guid.NewGuid();
Save(entry);
var dir = new DirectoryInfo(Path.Combine(_dir.FullName, entry.GetType().Name));
Load(Path.Combine(dir.FullName, oldID.ToString()));
}
public static void SaveAll()
{
foreach (var entry in GetAll<IDatabaseEntry>())
{
Save(entry);
}
}
public static void Delete(IDatabaseEntry entry)
{
var dir = new DirectoryInfo(Path.Combine(_dir.FullName, entry.GetType().Name));
File.Delete(Path.Combine(dir.FullName,entry.GetId().ToString()));
}
static Database()
{
_dir = new DirectoryInfo(Application.dataPath).Parent.CreateSubdirectory("GameData");
Action<string> update = path => Load(path);
foreach (var file in Directory.GetFiles(_dir.FullName, "*.*", SearchOption.AllDirectories))
update(file);
var watcher = new FileSystemWatcher(_dir.FullName);
watcher.IncludeSubdirectories = true;
watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName;
watcher.Changed += (_, args) => MainThreadDispatcher.Post(__ => update(args.FullPath), null);
watcher.Created += (_, args) => MainThreadDispatcher.Post(__ => update(args.FullPath), null);
watcher.Deleted += (_, args) => MainThreadDispatcher.Post(__ =>
{
var entryGuid = Guid.Parse(args.Name.Split('\\').Last());
foreach (var entries in Types.Values)
entries.Remove(entryGuid);
Entries.Remove(entryGuid);
OnDataUpdate?.Invoke();
}, null);
watcher.EnableRaisingEvents = true;
}
}

View file

@ -1,596 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MessagePack;
using UnityEngine;
using Unity.Mathematics;
using UnityEngine.UI.Extensions;
// TODO: USE THIS EVERYWHERE
using static Unity.Mathematics.math;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class NameAttribute : Attribute
{
public string Name;
public NameAttribute(string name)
{
Name = name;
}
}
public class UpdateOrderAttribute : Attribute
{
public int Order;
public UpdateOrderAttribute(int order)
{
Order = order;
}
}
public class GlobalData : IDatabaseEntry
{
[Inspectable] [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry();
[Inspectable] [Key("targetPersistenceDuration")]
public float TargetPersistenceDuration;
[Inspectable] [Key("heatRadiationPower")]
public float HeatRadiationPower;
[Inspectable] [Key("heatRadiationMultiplier")]
public float HeatRadiationMultiplier;
[IgnoreMember] public static GlobalData Instance => Database.GetAll<GlobalData>().FirstOrDefault();
[IgnoreMember] public DatabaseEntry Entry => DatabaseEntry;
}
[Union(5, typeof(Hull))]
[Union(6, typeof(Shield))]
[Union(9, typeof(Thruster))]
[Union(12, typeof(EquippableItem))]
public interface IEquippable : ICraftable
{
HardpointType HardpointType { get; }
EquippableData Equippable { get; }
}
[Union(5, typeof(Hull))]
[Union(6, typeof(Shield))]
[Union(9, typeof(Thruster))]
[Union(12, typeof(CraftedItem))]
[Union(13, typeof(EquippableItem))]
public interface ICraftable : IItem
{
Dictionary<Guid, int> CraftingIngredients { get; }
}
[Union(5, typeof(Hull))]
[Union(6, typeof(Shield))]
[Union(9, typeof(Thruster))]
[Union(12, typeof(ItemData))]
[Union(13, typeof(CraftedItem))]
[Union(14, typeof(EquippableItem))]
public interface IItem : IDatabaseEntry
{
ItemData Data { get; }
}
[Union(5, typeof(Hull))]
[Union(6, typeof(Shield))]
[Union(9, typeof(Thruster))]
[Union(12, typeof(ItemData))]
[Union(13, typeof(CraftedItem))]
[Union(14, typeof(LoadoutDefinition))]
[Union(15, typeof(ZoneData))]
[Union(16, typeof(SimpleCommodity))]
[Union(17, typeof(CompoundCommodity))]
[Union(18, typeof(Gear))]
[Union(19, typeof(EquippableItem))]
//[Union(21, typeof(ContractData))]
//[Union(22, typeof(Station))]
[Union(23, typeof(Corporation))]
[Union(24, typeof(Player))]
[Union(25, typeof(GlobalData))]
public interface IDatabaseEntry
{
DatabaseEntry Entry { get; }
}
[Union(0, typeof(SimpleCommodity))]
[Union(1, typeof(CompoundCommodity))]
[Union(2, typeof(Gear))]
public interface IItemInstance : IDatabaseEntry
{
Guid ItemGuid { get; }
IItem ItemData { get; }
float Mass { get; }
}
[Union(0, typeof(Gear))]
[Union(1, typeof(CompoundCommodity))]
public interface ICraftedItemInstance : IItemInstance
{
float CraftedQuality { get; }
IEnumerable<IItemInstance> CraftedIngredients { get; }
}
[Inspectable]
[MessagePackObject]
public class DatabaseEntry
{
[Key("id")] public Guid ID = Guid.NewGuid();
[Inspectable] [Key("name")] public string Name;
[Inspectable] [Key("description")] public string Description;
}
[Inspectable]
[MessagePackObject]
[Name("Simple Commodity")]
public class ItemData : IItem
{
[Inspectable] [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry();
[Inspectable] [Key("mass")] public float Mass;
[Inspectable] [Key("size")] public float Size;
[RangedIntInspectable(0, 20)] [Key("level")] public int TechLevel;
[IgnoreMember] public ItemData Data => this;
[IgnoreMember] public DatabaseEntry Entry => DatabaseEntry;
}
[MessagePackObject]
public class EquippableItem : IEquippable
{
[Inspectable] [Key("hardpointType")] public HardpointType Hardpoint;
[Inspectable] [Key("itemData")] public ItemData ItemData = new ItemData();
[Inspectable] [Key("equippableData")] public EquippableData EquippableData = new EquippableData();
[Inspectable] [Key("ingredients")] public Dictionary<Guid, int> Ingredients = new Dictionary<Guid, int>();
[IgnoreMember] public HardpointType HardpointType => Hardpoint;
[IgnoreMember] public EquippableData Equippable => EquippableData;
[IgnoreMember] public ItemData Data => ItemData;
[IgnoreMember] public Dictionary<Guid, int> CraftingIngredients => Ingredients;
[IgnoreMember] public DatabaseEntry Entry => ItemData.Entry;
}
[Inspectable]
[MessagePackObject]
public class EquippableData
{
[Inspectable] [Key("draw")] public PerformanceStat EnergyDraw;
// [Inspectable] [Key("conductivity")] public float ThermalConductivity;
// [Inspectable] [Key("specificHeat")] public float SpecificHeat;
[Inspectable] [Key("performance")] public AnimationCurve HeatPerformanceCurve;
[TemperatureInspectable] [Key("minTemp")] public float MinimumTemperature;
[TemperatureInspectable] [Key("maxTemp")] public float MaximumTemperature;
[Inspectable] [Key("ruggedness")] public float Ruggedness;
[Inspectable] [Key("durability")] public float Durability;
[Inspectable] [Key("durabilityExponent")] public PerformanceStat DurabilityExponent;
[Inspectable] [Key("heatExponent")] public PerformanceStat HeatExponent;
[Inspectable] [Key("behaviors")] public List<IItemBehaviorData> Behaviors = new List<IItemBehaviorData>();
[IgnoreMember] private const int STEPS = 64;
[IgnoreMember] private float? _optimum;
[IgnoreMember]
public float OptimalTemperature
{
get
{
if (_optimum==null)
{
var samples = Enumerable.Range(0, STEPS).Select(i => (float) i / STEPS).ToArray();
float max = 0;
_optimum = 0;
foreach (var f in samples)
{
var p = HeatPerformanceCurve?.Evaluate(f)??0;
if (p > max)
{
max = p;
_optimum = f;
}
}
}
return (float) (MinimumTemperature + _optimum * (MaximumTemperature - MinimumTemperature));
}
}
}
[MessagePackObject]
[Name("Compound Commodity")]
public class CraftedItem : ICraftable
{
[Inspectable] [Key("itemData")] public ItemData ItemData = new ItemData();
[Inspectable] [Key("ingredients")] public Dictionary<Guid, int> Ingredients = new Dictionary<Guid, int>();
[IgnoreMember] public ItemData Data => ItemData;
[IgnoreMember] public Dictionary<Guid, int> CraftingIngredients => Ingredients;
[IgnoreMember] public DatabaseEntry Entry => ItemData.Entry;
}
[MessagePackObject]
public class Hull : IEquippable
{
[Inspectable] [Key("itemData")] public ItemData ItemData = new ItemData();
[Inspectable] [Key("equippableData")] public EquippableData EquippableData = new EquippableData();
[Inspectable] [Key("ingredients")] public Dictionary<Guid, int> Ingredients = new Dictionary<Guid, int>();
[Inspectable] [Key("hullCapacity")] public PerformanceStat Capacity;
[Inspectable] [Key("traction")] public PerformanceStat Traction;
[Inspectable] [Key("topSpeed")] public PerformanceStat TopSpeed;
[Inspectable] [Key("emissivity")] public PerformanceStat Emissivity;
[Inspectable] [Key("crossSection")] public PerformanceStat CrossSection;
[Key("schemaSprite")] [MessagePackFormatter(typeof(UnitySpriteFormatter))]
public Sprite Schematic;
[Inspectable] [Key("hardpoints")] public List<HardpointData> Hardpoints = new List<HardpointData>();
[Inspectable] [Key("visibility")] public AnimationCurve VisibilityCurve;
[MessagePackFormatter(typeof(UnityGameObjectFormatter))]
[Inspectable] [Key("prefab")] public GameObject Prefab;
[IgnoreMember] public HardpointType HardpointType => HardpointType.Hull;
[IgnoreMember] public EquippableData Equippable => EquippableData;
[IgnoreMember] public ItemData Data => ItemData;
[IgnoreMember] public Dictionary<Guid, int> CraftingIngredients => Ingredients;
[IgnoreMember] public DatabaseEntry Entry => ItemData.Entry;
}
//[MessagePackObject]
//public class Sensor : IEquippable
//{
// [Key("itemData")] public ItemData ItemData = new ItemData();
// [Key("equippableData")] public EquippableData EquippableData = new EquippableData();
// [Key("ingredients")] public Dictionary<Guid, int> Ingredients = new Dictionary<Guid, int>();
// [Key("radiance")] public PerformanceStat Radiance;
// [Key("masking")] public PerformanceStat RadianceMasking;
// [Key("sensitivity")] public PerformanceStat Sensitivity;
//
// [IgnoreMember] public HardpointType HardpointType => HardpointType.Sensors;
// [IgnoreMember] public EquippableData Equippable => EquippableData;
// [IgnoreMember] public ItemData Data => ItemData;
// [IgnoreMember] public Dictionary<Guid, int> CraftingIngredients => Ingredients;
// [IgnoreMember] public DatabaseEntry Entry => ItemData.Entry;
//}
//
[MessagePackObject]
public class Shield : IEquippable
{
[Inspectable] [Key("itemData")]
public ItemData ItemData = new ItemData();
[Inspectable] [Key("equippableData")]
public EquippableData EquippableData = new EquippableData();
[Inspectable] [Key("ingredients")]
public Dictionary<Guid, int> Ingredients = new Dictionary<Guid, int>();
[Inspectable] [Key("efficiency")]
public PerformanceStat Efficiency;
[Inspectable] [Key("shielding")]
public PerformanceStat Shielding;
[IgnoreMember] public HardpointType HardpointType => HardpointType.Shield;
[IgnoreMember] public EquippableData Equippable => EquippableData;
[IgnoreMember] public ItemData Data => ItemData;
[IgnoreMember] public Dictionary<Guid, int> CraftingIngredients => Ingredients;
[IgnoreMember] public DatabaseEntry Entry => ItemData.Entry;
}
[MessagePackObject]
public class Thruster : IEquippable
{
[Inspectable] [Key("itemData")] public ItemData ItemData = new ItemData();
[Inspectable] [Key("equippableData")] public EquippableData EquippableData = new EquippableData();
[Inspectable] [Key("ingredients")] public Dictionary<Guid, int> Ingredients = new Dictionary<Guid, int>();
[Inspectable] [Key("thrust")] public PerformanceStat Thrust;
[Inspectable] [Key("torque")] public PerformanceStat Torque;
[Inspectable] [Key("visibility")] public PerformanceStat Visibility;
[Inspectable] [Key("thrusterHeat")] public PerformanceStat Heat;
// [Inspectable] [Key("minSound")] public GranularEmitterStats MinSound;
// [Inspectable] [Key("maxSound")] public GranularEmitterStats MaxSound;
// [Inspectable] [Key("time")] public float SoundTransitionTime;
// [Inspectable] [Key("perlin")] public bool OscillatorPerlin;
// [MessagePackFormatter(typeof(UnityAudioClipFormatter))]
// [Inspectable] [Key("clip")] public AudioClip Clip;
[IgnoreMember] public HardpointType HardpointType => HardpointType.Thruster;
[IgnoreMember] public EquippableData Equippable => EquippableData;
[IgnoreMember] public ItemData Data => ItemData;
[IgnoreMember] public Dictionary<Guid, int> CraftingIngredients => Ingredients;
[IgnoreMember] public DatabaseEntry Entry => ItemData.Entry;
}
//[MessagePackObject]
//public class Launcher : IEquippable
//{
// [Key("itemData")] public ItemData ItemData = new ItemData();
// [Key("equippableData")] public EquippableData EquippableData = new EquippableData();
//// [Key("weaponData")] public WeaponData WeaponData = new WeaponData();
// [Key("ingredients")] public Dictionary<Guid, int> Ingredients = new Dictionary<Guid, int>();
// [MessagePackFormatter(typeof(UnityGameObjectFormatter))]
// [Key("projectile")] public GameObject ProjectilePrefab;
// [Key("launcherCaliber")] public LauncherCaliber Caliber;
// [Key("salvoDuration")] public PerformanceStat SalvoDuration;
// [Key("salvoSize")] public int SalvoSize;
//
// [IgnoreMember] public HardpointType HardpointType => HardpointType.Launcher;
// [IgnoreMember] public EquippableData Equippable => EquippableData;
// [IgnoreMember] public ItemData Data => ItemData;
// [IgnoreMember] public Dictionary<Guid, int> CraftingIngredients => Ingredients;
//// [IgnoreMember] public WeaponData Weapon => WeaponData;
// [IgnoreMember] public DatabaseEntry Entry => ItemData.Entry;
//}
//[MessagePackObject]
//public class Beam : IEquippable
//{
// [Key("itemData")] public ItemData ItemData = new ItemData();
// [Key("equippableData")] public EquippableData EquippableData = new EquippableData();
//// [Key("weaponData")] public WeaponData WeaponData = new WeaponData();
// [Key("ingredients")] public Dictionary<Guid, int> Ingredients = new Dictionary<Guid, int>();
// [Key("duration")] public PerformanceStat Duration;
// [Key("diameter")] public PerformanceStat Diameter;
// [Key("amplitude")] public AnimationCurve Amplitude;
// [MessagePackFormatter(typeof(UnityMaterialFormatter))]
// [Key("material")] public Material BeamMaterial;
// [Key("damageType")] public ProjectileType DamageType;
//
// [IgnoreMember] public HardpointType HardpointType => DamageType==ProjectileType.Physical?HardpointType.Ballistic:HardpointType.Energy;
// [IgnoreMember] public EquippableData Equippable => EquippableData;
// [IgnoreMember] public ItemData Data => ItemData;
// [IgnoreMember] public Dictionary<Guid, int> CraftingIngredients => Ingredients;
//// [IgnoreMember] public WeaponData Weapon => WeaponData;
// [IgnoreMember] public DatabaseEntry Entry => ItemData.Entry;
//}
[MessagePackObject]
public struct PerformanceStat
{
[Key("min")]
public float Min;
[Key("max")]
public float Max;
[Key("durabilityDependent")]
public bool DurabilityDependent;
[Key("heatDependent")]
public bool HeatDependent;
[Key("qualityExponent")]
public float QualityExponent;
[Key("ingredient")]
public Guid Ingredient;
[IgnoreMember] private Dictionary<Ship,Dictionary<IItemBehavior,float>> _scaleModifiers;
[IgnoreMember] private Dictionary<Ship,Dictionary<IItemBehavior,float>> _constantModifiers;
[IgnoreMember]
private Dictionary<Ship,Dictionary<IItemBehavior, float>> ScaleModifiers
{
get { return _scaleModifiers ?? (_scaleModifiers = new Dictionary<Ship,Dictionary<IItemBehavior, float>>()); }
}
[IgnoreMember]
private Dictionary<Ship,Dictionary<IItemBehavior, float>> ConstantModifiers
{
get { return _constantModifiers ?? (_constantModifiers = new Dictionary<Ship,Dictionary<IItemBehavior, float>>()); }
}
public Dictionary<IItemBehavior, float> GetScaleModifiers(Ship ship)
{
if(!ScaleModifiers.ContainsKey(ship))
ScaleModifiers[ship] = new Dictionary<IItemBehavior, float>();
return ScaleModifiers[ship];
}
public Dictionary<IItemBehavior, float> GetConstantModifiers(Ship ship)
{
if(!ConstantModifiers.ContainsKey(ship))
ConstantModifiers[ship] = new Dictionary<IItemBehavior, float>();
return ConstantModifiers[ship];
}
// Determine quality of either the item itself or the specific ingredient this stat depends on
public float Quality(Gear item)
{
Guid ingredientID = Ingredient;
float quality;
if (ingredientID == Guid.Empty)
quality = item.CompoundQuality();
else
{
var ingredientInstance =
item.CraftedIngredients.FirstOrDefault(i => i.ItemGuid == ingredientID) as ICraftedItemInstance;
if (ingredientInstance == null)
throw new InvalidOperationException(
$"Item {item.Entry.Name} has invalid crafting ingredient set for performance stat.");
quality = ingredientInstance.CompoundQuality();
}
return quality;
}
// Returns stat when not equipped
public float Evaluate(Gear item)
{
var quality = pow(Quality(item), QualityExponent);
var result = lerp(Min, Max, quality);
if (float.IsNaN(result))
return Min;
return result;
}
// Returns stat using ship temperature and modifiers
public float Evaluate(Gear item, Ship ship)
{
var itemData = item.EquippedItemData;
var heat = !HeatDependent ? 1 : pow(itemData.Performance(ship.Temperature), itemData.Equippable.HeatExponent.Evaluate(item));
var durability = !DurabilityDependent ? 1 : pow(item.Durability / itemData.Equippable.Durability, itemData.Equippable.DurabilityExponent.Evaluate(item));
var quality = pow(Quality(item), QualityExponent);
var scaleModifier = 1.0f;
if (_scaleModifiers != null && _scaleModifiers.ContainsKey(ship))
{
foreach (var mod in _scaleModifiers[ship].Values)
{
scaleModifier *= mod;
}
}
var constantModifier = 0.0f;
if (_constantModifiers != null && _constantModifiers.ContainsKey(ship))
{
foreach (var mod in _constantModifiers[ship].Values)
{
scaleModifier += mod;
}
}
var result = lerp(Min, Max, heat * durability * quality) * scaleModifier + constantModifier;
if (float.IsNaN(result))
return Min;
return result;
}
}
[MessagePackObject]
public class Hardpoint
{
[Key("item")] public Gear Item;
// [IgnoreMember] public Ship Ship;
[IgnoreMember] public HardpointData HardpointData;
// [IgnoreMember]
// public float HeatCapacity => Item != null
// ? Item.EquippedItemData.Data.Mass * Item.EquippedItemData.Equippable.SpecificHeat
// : Ship.Hull.EquippedItemData.Data.Mass * Ship.Hull.EquippedItemData.Equippable.SpecificHeat / Ship.HullHardpointCount;
}
[Name("Loadout")]
[MessagePackObject]
public class LoadoutDefinition : IDatabaseEntry
{
[Inspectable] [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry();
[InspectableDatabaseLink(typeof(Hull))] [Key("hull")] public Guid Hull;
[Key("items")] public List<Guid> Items = new List<Guid>();
[IgnoreMember] public DatabaseEntry Entry => DatabaseEntry;
}
[MessagePackObject]
public class Player : IDatabaseEntry
{
[Inspectable] [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry();
[Key("email")] public string Email;
[Key("password")] public string Password;
[IgnoreMember] public DatabaseEntry Entry => DatabaseEntry;
}
[MessagePackObject]
public class HardpointData
{
[Key("type")] public HardpointType Type;
}
[MessagePackObject]
public class ZoneData : IDatabaseEntry
{
[Inspectable] [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry();
[Inspectable] [Key("radius")] public float Radius = 500;
[Inspectable] [Key("radiusPower")] public float RadiusPower = 1.75f;
[Inspectable] [Key("mass")] public float Mass = 100000;
[Inspectable] [Key("massFloor")] public float MassFloor = 1;
[Inspectable] [Key("sunMass")] public float SunMass = 10000;
[Inspectable] [Key("gasGiantMass")] public float GasGiantMass = 2000;
[Inspectable] [Key("stations")] public List<Station> Stations = new List<Station>();
[InspectableDatabaseLink(typeof(ZoneData))] [Key("wormholes")]
public List<Guid> Wormholes = new List<Guid>();
[IgnoreMember] public DatabaseEntry Entry => DatabaseEntry;
}
[Inspectable]
[MessagePackObject]
public class Station
{
[Inspectable] [Key("name")] public string Name;
[InspectableDatabaseLink(typeof(Corporation))] [Key("faction")] public Guid Faction;
[Inspectable] [Key("dockingDistance")] public float DockingDistance = 10;
[Inspectable] [Key("buying")] public Dictionary<Guid, float> BuyPrices = new Dictionary<Guid, float>();
[Inspectable] [Key("selling")] public Dictionary<Guid, float> SellPrices = new Dictionary<Guid, float>();
[MessagePackFormatter(typeof(UnityGameObjectFormatter))] [Inspectable] [Key("prefab")] public GameObject Prefab;
}
[MessagePackObject]
public class Corporation : IDatabaseEntry
{
[Inspectable] [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry();
[InspectableDatabaseLink(typeof(Corporation))] [Key("parent")] public Guid ParentCorporation;
[Inspectable] [MessagePackFormatter(typeof(UnitySpriteFormatter))] [Key("logo")] public Sprite Logo;
[Inspectable] [Key("livery")] public Skin Livery = new Skin();
[IgnoreMember] public DatabaseEntry Entry => DatabaseEntry;
}
[Inspectable]
[MessagePackObject]
public class Skin
{
[Inspectable] [MessagePackFormatter(typeof(UnityMaterialFormatter))] [Key("primary")] public Material Primary;
[Inspectable] [MessagePackFormatter(typeof(UnityMaterialFormatter))] [Key("secondary")] public Material Secondary;
[Inspectable] [MessagePackFormatter(typeof(UnityMaterialFormatter))] [Key("trim")] public Material Trim;
[Inspectable] [MessagePackFormatter(typeof(UnityMaterialFormatter))] [Key("windshield")] public Material Windshield;
}
public enum ProjectileType
{
Physical,
Energy
}
public enum LauncherCaliber
{
Missile,
Torpedo,
Fighter
}
public enum HardpointType
{
Hull,
Thruster,
WarpThruster,
Reactor,
Radiator,
Shield,
Cooler,
Sensors,
Tool,
Energy,
Ballistic,
Launcher
}
public enum DamageType
{
Kinetic,
Energy,
Thermal,
Optical,
Ionizing
}

View file

@ -3,308 +3,17 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using UniRx;
using Unity.Mathematics;
using UnityEditor;
using UnityEngine;
using UnityEngine.Serialization;
// TODO: USE THIS EVERYWHERE
using static Unity.Mathematics.math;
using Object = UnityEngine.Object;
public class DatabaseListView : EditorWindow
{
// Singleton to avoid multiple instances of window.
private static DatabaseListView _instance;
public Guid SelectedItem;
public GUIStyle SelectedStyle;
private bool[] _gearFoldouts;
private bool _itemsFoldout;
private bool _compoundFoldout;
private bool _simpleFoldout;
private bool _commoditiesFoldout;
//private bool _consumablesFoldout;
private Type[] _itemTypes;
private bool _listItemStyle;
private GUIStyle _listStyleOdd;
private GUIStyle _listStyleEven;
private static DatabaseInspector _inspector;
private Type[] _entryTypes;
private bool[] _entryFoldouts;
private const float LineHeight = 20;
// Set instance on reloading the window, else it gets lost after script reload (due to PlayMode changes, ...).
public DatabaseListView()
{
_instance = this;
}
public static DatabaseListView ShowWindow()
{
if (_instance == null)
{
// "Get existing open window or if none, make a new one:" says documentation.
// But if called after script reloads a second instance will be opened! => Custom singleton required.
DatabaseListView window = EditorWindow.GetWindow<DatabaseListView>();
window.titleContent = new GUIContent("DB List");
_instance = window;
_instance.InitStyles();
window.Show();
}
else
_instance.Focus();
return _instance;
}
public GUIStyle ListItemStyle =>
(_listItemStyle = !_listItemStyle) ? _listStyleEven : _listStyleOdd;
[MenuItem("Window/Aetheria Database Tools")]
static void Init()
{
ShowWindow();
}
void OnEnable()
{
_inspector = DatabaseInspector.ShowWindow();
_itemTypes = typeof(IItem).GetAllInterfaceClasses();
_entryTypes = typeof(IDatabaseEntry).GetAllInterfaceClasses().Where(t => !t.GetInterfaces().Contains(typeof(IItem))&& !t.GetInterfaces().Contains(typeof(IItemInstance))).ToArray();
_gearFoldouts = new bool[_itemTypes.Length];
_entryFoldouts = new bool[_entryTypes.Length];
InitStyles();
Database.OnDataUpdate += Repaint;
}
private void InitStyles()
{
_listStyleOdd = new GUIStyle
{
normal = {background = XKCDColors.LightGrey.ToTexture()},
margin = new RectOffset(0, 0, 0, 0)
};
_listStyleEven = new GUIStyle
{
normal = {background = Color.Lerp(XKCDColors.LightGrey,Color.white,.5f).ToTexture()},
margin = new RectOffset(0, 0, 0, 0)
};
SelectedStyle = new GUIStyle
{
normal = {background = XKCDColors.Greyblue.ToTexture()},
margin = new RectOffset(0, 0, 0, 0)
};
}
public void OnGUI()
{
Event currentEvent = Event.current;
EventType currentEventType = currentEvent.type;
if (currentEventType == EventType.DragUpdated)
// Indicate that we don't accept drags ourselves
DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
Action<IDatabaseEntry> select = item =>
{
SelectedItem = item.GetId();
Repaint();
_inspector.entry = Database.Get(SelectedItem);
_inspector.Repaint();
};
using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
{
_itemsFoldout = EditorGUILayout.Foldout(_itemsFoldout, "Items", true);
}
if (_itemsFoldout)
{
var items = Database.AllEntries.Where(item => item is IItem).Cast<IItem>().ToArray();
for (var i = 0; i < _itemTypes.Length; i++)
{
using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
{
GUILayout.Space(10);
_gearFoldouts[i] = EditorGUILayout.Foldout(_gearFoldouts[i],
((NameAttribute) _itemTypes[i].GetCustomAttribute(typeof(NameAttribute)))?.Name ?? _itemTypes[i].Name,
true);
}
if (_gearFoldouts[i])
{
foreach (var item in items.Where(e=>e.GetType()==_itemTypes[i]))
{
var style = ListItemStyle;
var selected = SelectedItem == item.GetId();
using (var h = new EditorGUILayout.HorizontalScope(selected?SelectedStyle:style))
{
if (h.rect.Contains(currentEvent.mousePosition))
{
if (currentEventType == EventType.MouseDrag)
{
DragAndDrop.PrepareStartDrag();
DragAndDrop.SetGenericData("Item", item.GetId());
DragAndDrop.StartDrag("Database Item");
}
else if (currentEventType == EventType.MouseUp)
select(item);
}
GUILayout.Space(20);
GUILayout.Label(item.Entry.Name, selected ? EditorStyles.whiteLabel : GUI.skin.label);
}
}
using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
{
if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none))
CreateItem(_itemTypes[i]);
GUILayout.Space(20);
GUILayout.Label("New " + _itemTypes[i].Name);
var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
}
}
}
}
var entries = Database.AllEntries.Where(item => !(item is IItem)).ToArray();
for (var i = 0; i < _entryTypes.Length; i++)
{
using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
{
_entryFoldouts[i] = EditorGUILayout.Foldout(_entryFoldouts[i],
((NameAttribute) _entryTypes[i].GetCustomAttribute(typeof(NameAttribute)))?.Name ?? _entryTypes[i].Name,
true);
}
if (_entryFoldouts[i])
{
foreach (var entry in entries.Where(e=>e.GetType()==_entryTypes[i]))
{
var style = ListItemStyle;
var selected = SelectedItem == entry.GetId();
using (var h = new EditorGUILayout.HorizontalScope(selected?SelectedStyle:style))
{
if (h.rect.Contains(currentEvent.mousePosition))
{
if (currentEventType == EventType.MouseDrag)
{
DragAndDrop.PrepareStartDrag();
DragAndDrop.SetGenericData("Item", entry.GetId());
DragAndDrop.StartDrag("Database Item");
}
else if (currentEventType == EventType.MouseUp)
select(entry);
}
GUILayout.Space(10);
GUILayout.Label(entry.Entry.Name, selected ? EditorStyles.whiteLabel : GUI.skin.label);
}
}
using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
{
if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none))
CreateItem(_entryTypes[i]);
GUILayout.Space(10);
GUILayout.Label("New " + _entryTypes[i].Name);
var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
}
}
}
// EditorGUILayout.BeginHorizontal(ListItemStyle);
// _commoditiesFoldout = EditorGUILayout.Foldout(_commoditiesFoldout, "Commodities", true);
// EditorGUILayout.EndHorizontal();
// if (_commoditiesFoldout)
// {
// using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
// {
// GUILayout.Space(10);
// _simpleFoldout = EditorGUILayout.Foldout(_simpleFoldout, "Simple", true);
// }
// if (_simpleFoldout)
// {
// foreach (var item in Database.Items.Values.Where(e=>e.GetType()==typeof(ItemData)).Cast<ItemData>())
// {
// var style = ListItemStyle;
// var selected = SelectedItem == item.ID;
// using (var h = new EditorGUILayout.HorizontalScope(selected?_selectedStyle:style))
// {
// if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none))
// select(item);
// GUILayout.Space(20);
// GUILayout.Label(item.Name, selected ? EditorStyles.whiteLabel : GUI.skin.label);
// }
// }
//
// using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
// {
// if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none))
// CreateItem(typeof(ItemData));
// GUILayout.Space(20);
// var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
// GUI.DrawTexture(rect, GlobalData.Instance.plus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
// GUILayout.Label("New Simple Commodity");
// }
// }
//
// using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
// {
// GUILayout.Space(10);
// _compoundFoldout = EditorGUILayout.Foldout(_compoundFoldout, "Compound", true);
// }
// if (_compoundFoldout)
// {
// foreach (var item in Database.Items.Values.Where(e=>e.GetType()==typeof(CraftedItem)).Cast<CraftedItem>())
// {
// var style = ListItemStyle;
// var selected = SelectedItem == item.GetId();
// using (var h = new EditorGUILayout.HorizontalScope(selected?_selectedStyle:style))
// {
// if (GUI.Button(h.rect, GUIContent.none, GUIStyle.none))
// select(item);
// GUILayout.Space(20);
// GUILayout.Label(item.Item.Name, selected ? EditorStyles.whiteLabel : GUI.skin.label);
// }
// }
//
// using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
// {
// if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none))
// CreateItem(typeof(CraftedItem));
// GUILayout.Space(20);
// var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
// GUI.DrawTexture(rect, GlobalData.Instance.plus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
// GUILayout.Label("New Compound Commodity");
// }
// }
// }
// EditorGUILayout.BeginHorizontal(ListItemStyle);
// _consumablesFoldout = EditorGUILayout.Foldout(_consumablesFoldout, "Consumables", true);
// EditorGUILayout.EndHorizontal();
// if (_consumablesFoldout)
// {
//
// }
// HACK: This ensures none of the controls in this window can be focused (usually from clicking foldouts)
GUI.SetNextControlName("");
GUI.FocusControl("");
}
private void CreateItem(Type type)
{
var newEntry = (IDatabaseEntry) Activator.CreateInstance(type);
SelectedItem = newEntry.GetId();
newEntry.Entry.Name = $"New {type.Name}";
Database.Save(newEntry);
}
}
using static Unity.Mathematics.math;
public class DatabaseInspector : EditorWindow
{
public IDatabaseEntry entry;
public static DatabaseCache DatabaseCache;
public DatabaseEntry entry;
// Singleton to avoid multiple instances of window.
private static DatabaseInspector _instance;
@ -313,7 +22,7 @@ public class DatabaseInspector : EditorWindow
private GUIStyle _labelStyle;
private Vector2 _view;
private const float IconSize = 1.0f / 16;
private static HardpointData _hardpoint;
// private static HardpointData _hardpoint;
private static float2 _dragOffset;
private bool _ctrlDown;
private string[] _hardpointTypes;
@ -346,23 +55,23 @@ public class DatabaseInspector : EditorWindow
void OnEnable()
{
_list = DatabaseListView.ShowWindow();
Database.OnDataUpdate += Repaint;
DatabaseCache.OnDataUpdateLocal += _ => Repaint();
DatabaseCache.OnDataUpdateRemote += _ => EditorDispatcher.Dispatch(Repaint);
wantsMouseMove = true;
_hardpoint = null;
_hardpointTypes = Enum.GetNames(typeof(HardpointType));
}
public void Inspect(object obj, bool inspectablesOnly = false, ICraftable craftable = null)
public void Inspect(object obj, bool inspectablesOnly = false)
{
foreach (var field in obj.GetType().GetFields())
{
Inspect(obj, field, inspectablesOnly, craftable);
Inspect(obj, field, inspectablesOnly);
}
}
public void Inspect(object obj, FieldInfo field, bool inspectablesOnly = false, ICraftable craftable = null)
public void Inspect(object obj, FieldInfo field, bool inspectablesOnly = false)
{
var inspectable = field.GetCustomAttribute<InspectableAttribute>();
var inspectable = field.GetCustomAttribute<InspectableFieldAttribute>();
if (inspectable == null && inspectablesOnly) return;
var type = field.FieldType;
@ -381,6 +90,10 @@ public class DatabaseInspector : EditorWindow
else
field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (float) value));
}
else if (type == typeof(float4[]) && inspectable is InspectableAnimationCurveAttribute)
{
field.SetValue(obj, InspectAnimationCurve(field.Name.SplitCamelCase(), (float4[]) value));
}
else if (type == typeof(int))
{
if (inspectable is RangedIntInspectableAttribute)
@ -394,10 +107,16 @@ public class DatabaseInspector : EditorWindow
else if (type.IsEnum) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (int) field.GetValue(obj), Enum.GetNames(field.FieldType)));
//else if (field.FieldType == typeof(Color)) Inspect(field.Name, () => (Color) field.GetValue(obj), c => field.SetValue(obj, c));
else if (type == typeof(bool)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (bool) value));
else if (type == typeof(string)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (string) value, inspectable is InspectableTextAttribute));
else if (type == typeof(string))
{
if(inspectable is InspectablePrefabAttribute)
field.SetValue(obj, InspectGameObject(field.Name.SplitCamelCase(), (string) value));
else
field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (string) value, inspectable is InspectableTextAttribute));
}
else if (type == typeof(GameObject)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (GameObject) value));
else if (type == typeof(AnimationCurve)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (AnimationCurve) value));
else if (type == typeof(PerformanceStat)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (PerformanceStat) value, craftable));
else if (type == typeof(PerformanceStat)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (PerformanceStat) value, obj as CraftedItemData));
else if (type == typeof(PerformanceStat[]))
{
EditorGUILayout.LabelField(field.Name.SplitCamelCase(), EditorStyles.boldLabel);
@ -409,7 +128,7 @@ public class DatabaseInspector : EditorWindow
stats = new PerformanceStat[damageTypes.Length];
for (var i = 0; i < stats.Length; i++)
{
stats[i] = Inspect(damageTypes[i].SplitCamelCase(), stats[i], craftable);
stats[i] = Inspect(damageTypes[i].SplitCamelCase(), stats[i], obj as CraftedItemData);
}
field.SetValue(obj, stats);
}
@ -431,7 +150,7 @@ public class DatabaseInspector : EditorWindow
Inspect(field.Name.SplitCamelCase(), ref list, link.EntryType);
}
else if (type == typeof(Guid) && link != null) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (Guid) value, link.EntryType));
else if (type.GetCustomAttribute<InspectableAttribute>() != null)
else if (type.GetCustomAttribute<InspectableFieldAttribute>() != null)
{
EditorGUILayout.Space();
using (new EditorGUILayout.HorizontalScope())
@ -447,12 +166,12 @@ public class DatabaseInspector : EditorWindow
field.SetValue(obj, value = newSelection==0?null:Activator.CreateInstance(subTypes[newSelection-1]));
} else if(value == null) field.SetValue(obj, value = Activator.CreateInstance(type));
}
if(value != null) Inspect(field.GetValue(obj), inspectablesOnly, craftable);
if(value != null) Inspect(field.GetValue(obj), inspectablesOnly);
}
else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>))
{
var listType = field.FieldType.GenericTypeArguments[0];
if (listType.GetCustomAttribute<InspectableAttribute>() != null)
if (listType.GetCustomAttribute<InspectableFieldAttribute>() != null)
{
EditorGUILayout.Space();
using (new EditorGUILayout.VerticalScope(GUI.skin.box))
@ -484,7 +203,7 @@ public class DatabaseInspector : EditorWindow
EditorGUILayout.Space();
Inspect(o, inspectablesOnly, craftable);
Inspect(o, inspectablesOnly);
}
}
using (new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
@ -502,7 +221,7 @@ public class DatabaseInspector : EditorWindow
menu.AddItem(new GUIContent(behaviorType.Name), false, () =>
{
list.Add(Activator.CreateInstance(behaviorType));
Database.Save(entry);
DatabaseCache.Add(entry);
});
}
menu.ShowAsContext();
@ -670,6 +389,15 @@ public class DatabaseInspector : EditorWindow
}
}
public string InspectGameObject(string label, string value)
{
using (var h = new EditorGUILayout.HorizontalScope())
{
GUILayout.Label(label, GUILayout.Width(width));
return AssetDatabase.GetAssetPath(EditorGUILayout.ObjectField(AssetDatabase.LoadAssetAtPath<GameObject>(value), typeof(GameObject), false));
}
}
public GameObject Inspect(string label, GameObject value)
{
using (var h = new EditorGUILayout.HorizontalScope())
@ -679,6 +407,20 @@ public class DatabaseInspector : EditorWindow
}
}
public float4[] InspectAnimationCurve(string label, float4[] value)
{
var val = value != null && value.Length > 0
? new AnimationCurve(value.Select(v => new Keyframe(v.x, v.y, v.z, v.w)).ToArray())
: new AnimationCurve();
using (var h = new EditorGUILayout.HorizontalScope())
{
GUILayout.Label(label, GUILayout.Width(width));
val = EditorGUILayout.CurveField(val, Color.yellow, new Rect(0, 0, 1, 1));
}
return val.keys.Select(k => float4(k.time, k.value, k.inTangent, k.outTangent)).ToArray();
}
public AnimationCurve Inspect(string label, AnimationCurve value)
{
using (var h = new EditorGUILayout.HorizontalScope())
@ -695,15 +437,15 @@ public class DatabaseInspector : EditorWindow
public Guid Inspect(string label, Guid value, Type entryType)
{
EditorGUILayout.LabelField(label, EditorStyles.boldLabel);
var valueEntry = Database.Get(value);
var valueEntry = DatabaseCache.Get(value);
using (var h = new EditorGUILayout.HorizontalScope(GUI.skin.box))
{
GUILayout.Label(valueEntry?.Entry.Name ?? $"Assign a {entryType.Name} by dragging from the list panel.");
GUILayout.Label((valueEntry as INamedEntry)?.EntryName ?? valueEntry?.ID.ToString() ?? $"Assign a {entryType.Name} by dragging from the list panel.");
if (h.rect.Contains(Event.current.mousePosition) && (Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform))
{
var guid = (Guid) DragAndDrop.GetGenericData("Item");
var dragEntry = Database.Get(guid);
var dragEntry = DatabaseCache.Get(guid);
if(Event.current.type == EventType.DragUpdated)
DragAndDrop.visualMode = dragEntry != null && dragEntry.GetType()==entryType ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected;
else if(Event.current.type == EventType.DragPerform)
@ -739,7 +481,7 @@ public class DatabaseInspector : EditorWindow
{
using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
{
GUILayout.Label(Database.Get(ingredient.Key).Entry.Name);
GUILayout.Label(DatabaseCache.Get<ItemData>(ingredient.Key).Name);
value[ingredient.Key] = EditorGUILayout.DelayedIntField(value[ingredient.Key], GUILayout.Width(50));
var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
@ -785,7 +527,7 @@ public class DatabaseInspector : EditorWindow
{
using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
{
GUILayout.Label(Database.Get(ingredient.Key).Entry.Name);
GUILayout.Label(DatabaseCache.Get(ingredient.Key).ID.ToString());
value[ingredient.Key] = EditorGUILayout.DelayedFloatField(value[ingredient.Key], GUILayout.Width(50));
var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
@ -831,7 +573,7 @@ public class DatabaseInspector : EditorWindow
{
using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
{
GUILayout.Label(Database.Get(ingredient).Entry.Name);
GUILayout.Label((DatabaseCache.Get(ingredient) as INamedEntry)?.EntryName ?? DatabaseCache.Get(ingredient).ID.ToString());
var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
@ -843,7 +585,7 @@ public class DatabaseInspector : EditorWindow
if (v.rect.Contains(Event.current.mousePosition))
{
var guid = DragAndDrop.GetGenericData("Item");
var dragObj = DragAndDrop.GetGenericData("Item") is Guid ? ((Guid) guid).Get() : null;
var dragObj = DragAndDrop.GetGenericData("Item") is Guid ? DatabaseCache.Get((Guid) guid) : null;
if(Event.current.type == EventType.DragUpdated)
DragAndDrop.visualMode = entryType.IsInstanceOfType(dragObj) ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected;
else if(Event.current.type == EventType.DragPerform)
@ -859,7 +601,7 @@ public class DatabaseInspector : EditorWindow
}
}
public PerformanceStat Inspect(string label, PerformanceStat value, ICraftable craftable)
public PerformanceStat Inspect(string label, PerformanceStat value, CraftedItemData crafted)
{
using (new EditorGUILayout.VerticalScope())
{
@ -887,14 +629,14 @@ public class DatabaseInspector : EditorWindow
{
GUILayout.Label("", GUILayout.Width(width));
GUILayout.Label("Ingredient", GUILayout.ExpandWidth(false));
var ingredients = craftable.CraftingIngredients.Keys.Select(Database.Get).Where(i => i is CraftedItem).Cast<CraftedItem>().ToList();
var ingredient = Database.Get(value.Ingredient) as CraftedItem;
var names = ingredients.Select(i => i.Entry.Name).Append("None").ToArray();
var selected = value.Ingredient == Guid.Empty || !craftable.CraftingIngredients.ContainsKey(value.Ingredient)
var ingredients = crafted.Ingredients.Keys.Select(DatabaseCache.Get).Where(i => i is CraftedItemData).Cast<CraftedItemData>().ToList();
var ingredient = value.Ingredient != null ? DatabaseCache.Get(value.Ingredient.Value) as CraftedItemData : null;
var names = ingredients.Select(i => i.Name).Append("None").ToArray();
var selected = value.Ingredient == null || !crafted.Ingredients.ContainsKey(value.Ingredient.Value)
? names.Length - 1
: ingredients.IndexOf(ingredient);
var selection = EditorGUILayout.Popup(selected, names);
value.Ingredient = selection == names.Length - 1 ? Guid.Empty : ingredients[selection].GetId();
value.Ingredient = selection == names.Length - 1 ? (Guid?) null : ingredients[selection].ID;
}
EditorGUILayout.Space();
@ -932,22 +674,22 @@ public class DatabaseInspector : EditorWindow
EditorGUI.BeginChangeCheck();
var dataEntry = entry.Entry;
var dataEntry = entry;
using (new EditorGUILayout.HorizontalScope())
{
if(GUILayout.Button("Print JSON"))
Debug.Log(entry.ToJson());
if (GUILayout.Button("Duplicate"))
{
Database.Duplicate(entry);
}
if (GUILayout.Button("Delete Entry"))
{
Database.Delete(entry);
entry = null;
return;
}
// if (GUILayout.Button("Duplicate"))
// {
// DatabaseCache.Duplicate(entry);
// }
// if (GUILayout.Button("Delete Entry"))
// {
// DatabaseCache.Delete(entry);
// entry = null;
// return;
// }
}
using (var h = new EditorGUILayout.HorizontalScope())
@ -956,10 +698,10 @@ public class DatabaseInspector : EditorWindow
EditorGUILayout.LabelField(dataEntry.ID.ToString());
}
Inspect(entry, true, entry as ICraftable);
Inspect(entry, true);
#region Hull
var hull = entry as Hull;
var hull = entry as HullData;
if (hull != null)
{
EditorGUILayout.Space();
@ -969,121 +711,121 @@ public class DatabaseInspector : EditorWindow
}
#endregion
#region Loadout
var loadout = entry as LoadoutDefinition;
if (loadout != null)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("Loadout Hull", EditorStyles.boldLabel);
var loadoutHull = Database.Get(loadout.Hull) as Hull;
if (loadoutHull != null)
{
// Reserve slots in the loadout for all equippable (non-hull) hardpoints
var hardpoints = loadoutHull.Hardpoints.Where(h => h.Type != HardpointType.Hull).ToArray();
if (loadout.Items.Count < hardpoints.Length)
loadout.Items.AddRange(Enumerable.Repeat(Guid.Empty, hardpoints.Length - loadout.Items.Count));
EditorGUILayout.Space();
using (var h = new EditorGUILayout.HorizontalScope())
{
GUILayout.Label($"Equipped Items: {loadout.Items.Sum(i=>((IItem) Database.Get(i))?.Data.Size ?? 0)}/{loadoutHull.Capacity.Min}", EditorStyles.boldLabel);
GUILayout.Label($"Mass: {loadout.Items.Sum(i=>((IItem) Database.Get(i))?.Data.Mass ?? 0)}", EditorStyles.boldLabel, GUILayout.ExpandWidth(false));
}
int itemIndex = 0;
using (var v = new EditorGUILayout.VerticalScope(GUI.skin.box))
{
for (; itemIndex < hardpoints.Length; itemIndex++)
{
var hp = hardpoints[itemIndex];
var loadoutItem = Database.Get(loadout.Items[itemIndex]) as IEquippable;
if (loadoutItem != null && loadoutItem.HardpointType != hp.Type)
{
loadout.Items[itemIndex] = Guid.Empty;
Debug.Log($"Invalid Item \"{loadoutItem.Entry.Name}\" in {Enum.GetName(typeof(HardpointType),hp.Type)} hardpoint for loadout \"{loadout.Entry.Name}\"");
Database.Save(entry);
}
using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
{
if (h.rect.Contains(current.mousePosition) &&
(currentEventType == EventType.DragUpdated || currentEventType == EventType.DragPerform))
{
var guid = (Guid) DragAndDrop.GetGenericData("Item");
var draggedEquippable = Database.Get(guid) as IEquippable;
var good = draggedEquippable != null && draggedEquippable.HardpointType == hp.Type;
if (currentEventType == EventType.DragUpdated)
DragAndDrop.visualMode = good ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected;
else if (currentEventType == EventType.DragPerform && good)
{
DragAndDrop.AcceptDrag();
loadout.Items[itemIndex] = guid;
Database.Save(entry);
}
}
GUILayout.Label(Enum.GetName(typeof(HardpointType), hp.Type));
if (loadoutItem == null || loadoutItem.HardpointType != hp.Type)
GUILayout.Label("Empty Hardpoint", GUILayout.ExpandWidth(false));
else
{
GUILayout.Label(loadoutItem.Entry.Name, GUILayout.ExpandWidth(false));
var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
loadout.Items[itemIndex] = Guid.Empty;
}
}
}
}
EditorGUILayout.Space();
EditorGUILayout.LabelField("Cargo", EditorStyles.boldLabel);
using (var v = new EditorGUILayout.VerticalScope(GUI.skin.box))
{
if (v.rect.Contains(current.mousePosition) &&
(currentEventType == EventType.DragUpdated || currentEventType == EventType.DragPerform))
{
var guid = (Guid) DragAndDrop.GetGenericData("Item");
var dragItem = Database.Get(guid) as IItem;
if (currentEventType == EventType.DragUpdated)
DragAndDrop.visualMode = dragItem != null ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected;
else if (currentEventType == EventType.DragPerform && dragItem != null)
{
DragAndDrop.AcceptDrag();
loadout.Items.Add(guid);
Database.Save(entry);
}
}
if(itemIndex == loadout.Items.Count)
GUILayout.Label("Nothing Here!");
for (; itemIndex < loadout.Items.Count; itemIndex++)
{
var loadoutItem = Database.Get(loadout.Items[itemIndex]) as IItem;
using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
{
GUILayout.Label(loadoutItem?.Entry.Name ?? "Invalid Item");
var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
loadout.Items.RemoveAt(itemIndex--);
}
}
}
}
}
#endregion
// #region Loadout
// var loadout = entry as LoadoutData;
// if (loadout != null)
// {
// EditorGUILayout.Space();
// EditorGUILayout.LabelField("Loadout Hull", EditorStyles.boldLabel);
//
// var loadoutHull = Database.Get(loadout.Hull) as HullData;
//
// if (loadoutHull != null)
// {
// // Reserve slots in the loadout for all equippable (non-hull) hardpoints
// var hardpoints = loadoutHull.Hardpoints.Where(h => h.Type != HardpointType.Hull).ToArray();
// if (loadout.Items.Count < hardpoints.Length)
// loadout.Items.AddRange(Enumerable.Repeat(Guid.Empty, hardpoints.Length - loadout.Items.Count));
//
// // EditorGUILayout.Space();
// // using (var h = new EditorGUILayout.HorizontalScope())
// // {
// // GUILayout.Label($"Equipped Items: {loadout.Items.Sum(i=>((ItemData) Database.Get(i))?.Data.Size ?? 0)}/{loadoutHull.Capacity.Min}", EditorStyles.boldLabel);
// // GUILayout.Label($"Mass: {loadout.Items.Sum(i=>((ItemData) Database.Get(i))?.Data.Mass ?? 0)}", EditorStyles.boldLabel, GUILayout.ExpandWidth(false));
// // }
//
// int itemIndex = 0;
// using (var v = new EditorGUILayout.VerticalScope(GUI.skin.box))
// {
// for (; itemIndex < hardpoints.Length; itemIndex++)
// {
// var hp = hardpoints[itemIndex];
//
// var loadoutItem = Database.Get(loadout.Items[itemIndex]) as EquippableItemData;
//
// if (loadoutItem != null && loadoutItem.HardpointType != hp.Type)
// {
// loadout.Items[itemIndex] = Guid.Empty;
// Debug.Log($"Invalid Item \"{loadoutItem.Name}\" in {Enum.GetName(typeof(HardpointType),hp.Type)} hardpoint for loadout \"{loadout.Name}\"");
// Database.Save(entry);
// }
//
// using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
// {
// if (h.rect.Contains(current.mousePosition) &&
// (currentEventType == EventType.DragUpdated || currentEventType == EventType.DragPerform))
// {
// var guid = (Guid) DragAndDrop.GetGenericData("Item");
// var draggedEquippable = Database.Get(guid) as EquippableItemData;
// var good = draggedEquippable != null && draggedEquippable.HardpointType == hp.Type;
// if (currentEventType == EventType.DragUpdated)
// DragAndDrop.visualMode = good ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected;
// else if (currentEventType == EventType.DragPerform && good)
// {
// DragAndDrop.AcceptDrag();
// loadout.Items[itemIndex] = guid;
//
// Database.Save(entry);
// }
// }
//
// GUILayout.Label(Enum.GetName(typeof(HardpointType), hp.Type));
// if (loadoutItem == null || loadoutItem.HardpointType != hp.Type)
// GUILayout.Label("Empty Hardpoint", GUILayout.ExpandWidth(false));
// else
// {
// GUILayout.Label(loadoutItem.Name, GUILayout.ExpandWidth(false));
// var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
// GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
// if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
// loadout.Items[itemIndex] = Guid.Empty;
// }
// }
// }
// }
//
// EditorGUILayout.Space();
// EditorGUILayout.LabelField("Cargo", EditorStyles.boldLabel);
//
// using (var v = new EditorGUILayout.VerticalScope(GUI.skin.box))
// {
// if (v.rect.Contains(current.mousePosition) &&
// (currentEventType == EventType.DragUpdated || currentEventType == EventType.DragPerform))
// {
// var guid = (Guid) DragAndDrop.GetGenericData("Item");
// var dragItem = Database.Get(guid) as ItemData;
// if (currentEventType == EventType.DragUpdated)
// DragAndDrop.visualMode = dragItem != null ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected;
// else if (currentEventType == EventType.DragPerform && dragItem != null)
// {
// DragAndDrop.AcceptDrag();
//
// loadout.Items.Add(guid);
// Database.Save(entry);
// }
// }
// if(itemIndex == loadout.Items.Count)
// GUILayout.Label("Nothing Here!");
// for (; itemIndex < loadout.Items.Count; itemIndex++)
// {
// var loadoutItem = Database.Get(loadout.Items[itemIndex]) as ItemData;
// using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
// {
// GUILayout.Label(loadoutItem?.Name ?? "Invalid Item");
// var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
// GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
// if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
// loadout.Items.RemoveAt(itemIndex--);
// }
// }
// }
// }
// }
// #endregion
if (EditorGUI.EndChangeCheck())
{
Database.Save(entry);
DatabaseCache.Add(entry);
}
EditorGUILayout.EndScrollView();

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 017a6733a6cd4ee4b99d7c53f15d21da
guid: 30b612dc279f724418b8a7a5426287c2
MonoImporter:
externalObjects: {}
serializedVersion: 2

View file

@ -0,0 +1,378 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using RethinkDb.Driver;
using RethinkDb.Driver.Net;
using UniRx;
using Unity.Mathematics;
using UnityEditor;
using UnityEngine;
using UnityEngine.Serialization;
// TODO: USE THIS EVERYWHERE
using static Unity.Mathematics.math;
using Object = UnityEngine.Object;
public class DatabaseListView : EditorWindow
{
// Singleton to avoid multiple instances of window.
private static DatabaseListView _instance;
public Guid SelectedItem;
public GUIStyle SelectedStyle;
public static RethinkDB R = RethinkDB.R;
private Connection _connection;
private DatabaseCache _databaseCache;
private bool[] _gearFoldouts;
private bool _itemsFoldout;
private bool _compoundFoldout;
private bool _simpleFoldout;
private bool _commoditiesFoldout;
//private bool _consumablesFoldout;
private Type[] _itemTypes;
private bool _listItemStyle;
private GUIStyle _listStyleOdd;
private GUIStyle _listStyleEven;
private static DatabaseInspector _inspector;
private Type[] _entryTypes;
private bool[] _entryFoldouts;
private string _connectionString;
private const float LineHeight = 20;
// Set instance on reloading the window, else it gets lost after script reload (due to PlayMode changes, ...).
public DatabaseListView()
{
_instance = this;
}
public static DatabaseListView ShowWindow()
{
if (_instance == null)
{
// "Get existing open window or if none, make a new one:" says documentation.
// But if called after script reloads a second instance will be opened! => Custom singleton required.
DatabaseListView window = EditorWindow.GetWindow<DatabaseListView>();
window.titleContent = new GUIContent("DB List");
_instance = window;
_instance.InitStyles();
window.Show();
}
else
_instance.Focus();
return _instance;
}
public GUIStyle ListItemStyle =>
(_listItemStyle = !_listItemStyle) ? _listStyleEven : _listStyleOdd;
[MenuItem("Window/Aetheria Database Tools")]
static void Init()
{
ShowWindow();
}
void OnEnable()
{
// Create database cache
_databaseCache = new DatabaseCache();
_databaseCache.OnDataUpdateLocal += _ => Repaint();
_databaseCache.OnDataUpdateRemote += _ => EditorDispatcher.Dispatch(Repaint);
DatabaseInspector.DatabaseCache = _databaseCache;
_inspector = DatabaseInspector.ShowWindow();
_itemTypes = typeof(ItemData).GetAllChildClasses()
.Where(t => t.GetCustomAttribute<InspectableAttribute>() != null).ToArray();
_entryTypes = typeof(DatabaseEntry).GetAllChildClasses()
.Where(t => t.GetCustomAttribute<InspectableAttribute>() != null && !typeof(ItemData).IsAssignableFrom(t)).ToArray();
_gearFoldouts = new bool[_itemTypes.Length];
_entryFoldouts = new bool[_entryTypes.Length];
if (EditorPrefs.HasKey("RethinkDB.URL"))
_connectionString = EditorPrefs.GetString("RethinkDB.URL");
else
_connectionString = "Enter DB URL";
InitStyles();
}
private void InitStyles()
{
var isDark = EditorGUIUtility.isProSkin;
_listStyleOdd = new GUIStyle
{
normal = {background = isDark ? XKCDColors.DarkGrey.ToTexture() : XKCDColors.LightGrey.ToTexture()},
margin = new RectOffset(0, 0, 0, 0)
};
_listStyleEven = new GUIStyle
{
normal = {background = isDark ? Color.Lerp(XKCDColors.DarkGrey,Color.black,.5f).ToTexture() : Color.Lerp(XKCDColors.LightGrey,Color.white,.5f).ToTexture()},
margin = new RectOffset(0, 0, 0, 0)
};
SelectedStyle = new GUIStyle
{
normal = {background = isDark ? XKCDColors.DarkGreyBlue.ToTexture() : XKCDColors.Greyblue.ToTexture()},
margin = new RectOffset(0, 0, 0, 0)
};
}
public void OnGUI()
{
Event currentEvent = Event.current;
EventType currentEventType = currentEvent.type;
if (currentEventType == EventType.DragUpdated)
// Indicate that we don't accept drags ourselves
DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
using (var h = new EditorGUILayout.HorizontalScope())
{
_connectionString = EditorGUILayout.TextField(_connectionString);
if (GUILayout.Button("Connect"))
{
EditorPrefs.SetString("RethinkDB.URL", _connectionString);
_connection = R.Connection().Hostname(_connectionString).Port(RethinkDBConstants.DefaultPort).Timeout(60).Connect();
Debug.Log("Connected to RethinkDB");
// When entries are changed locally, push the changes to RethinkDB
_databaseCache.OnDataUpdateLocal +=
entry =>
{
Debug.Log($"Uploading entry to RethinkDB: {entry.ID}");
R.Db("Aetheria").Table("Items").Replace(entry).RunAsync(_connection);
};
// Get all item data from RethinkDB
Task.Run(async () =>
{
var result = await R.Db("Aetheria").Table("Items").RunCursorAsync<DatabaseEntry>(_connection);
while (await result.MoveNextAsync())
{
var entry = result.Current;
Debug.Log($"Received entry from RethinkDB: {entry.ID}");
_databaseCache.Add(entry, true);
}
}).WrapErrors();
// Subscribe to changes from RethinkDB
Task.Run(async () =>
{
var result = await R.Db("Aetheria").Table("Items").Changes()
.RunChangesAsync<DatabaseEntry>(_connection);
while (await result.MoveNextAsync())
{
var change = result.Current;
var entry = change.NewValue;
Debug.Log($"Received change to entry from RethinkDB: {entry.ID}");
_databaseCache.Add(entry, true);
}
}).WrapErrors();
}
}
GUILayout.Space(5);
Action<DatabaseEntry> select = item =>
{
SelectedItem = item.ID;
Repaint();
_inspector.entry = _databaseCache.Get(SelectedItem);
_inspector.Repaint();
};
using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
{
_itemsFoldout = EditorGUILayout.Foldout(_itemsFoldout, "Items", true);
}
if (_itemsFoldout)
{
var items = _databaseCache.AllEntries.Where(item => item is ItemData).Cast<ItemData>().ToArray();
for (var i = 0; i < _itemTypes.Length; i++)
{
using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
{
GUILayout.Space(10);
_gearFoldouts[i] = EditorGUILayout.Foldout(_gearFoldouts[i],
((NameAttribute) _itemTypes[i].GetCustomAttribute(typeof(NameAttribute)))?.Name ?? _itemTypes[i].Name,
true);
}
if (_gearFoldouts[i])
{
foreach (var item in items.Where(e=>e.GetType()==_itemTypes[i]))
{
var style = ListItemStyle;
var selected = SelectedItem == item.ID;
using (var h = new EditorGUILayout.HorizontalScope(selected?SelectedStyle:style))
{
if (h.rect.Contains(currentEvent.mousePosition))
{
if (currentEventType == EventType.MouseDrag)
{
DragAndDrop.PrepareStartDrag();
DragAndDrop.SetGenericData("Item", item.ID);
DragAndDrop.StartDrag("Database Item");
}
else if (currentEventType == EventType.MouseUp)
select(item);
}
GUILayout.Space(20);
GUILayout.Label(item.Name, selected ? EditorStyles.whiteLabel : GUI.skin.label);
}
}
using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
{
if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none))
CreateItem(_itemTypes[i]);
GUILayout.Space(20);
GUILayout.Label("New " + _itemTypes[i].Name);
var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
}
}
}
}
var entries = _databaseCache.AllEntries.Where(item => !(item is ItemData)).ToArray();
for (var i = 0; i < _entryTypes.Length; i++)
{
using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
{
_entryFoldouts[i] = EditorGUILayout.Foldout(_entryFoldouts[i],
((NameAttribute) _entryTypes[i].GetCustomAttribute(typeof(NameAttribute)))?.Name ?? _entryTypes[i].Name,
true);
}
if (_entryFoldouts[i])
{
int index = 0;
foreach (var entry in entries.Where(e=>e.GetType()==_entryTypes[i]))
{
index++;
var style = ListItemStyle;
var selected = SelectedItem == entry.ID;
using (var h = new EditorGUILayout.HorizontalScope(selected?SelectedStyle:style))
{
if (h.rect.Contains(currentEvent.mousePosition))
{
if (currentEventType == EventType.MouseDrag)
{
DragAndDrop.PrepareStartDrag();
DragAndDrop.SetGenericData("Item", entry.ID);
DragAndDrop.StartDrag("Database Item");
}
else if (currentEventType == EventType.MouseUp)
select(entry);
}
GUILayout.Space(10);
GUILayout.Label((entry as INamedEntry)?.EntryName ?? index.ToString(), selected ? EditorStyles.whiteLabel : GUI.skin.label);
}
}
using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
{
if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none))
CreateItem(_entryTypes[i]);
GUILayout.Space(10);
GUILayout.Label("New " + _entryTypes[i].Name);
var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
}
}
}
// EditorGUILayout.BeginHorizontal(ListItemStyle);
// _commoditiesFoldout = EditorGUILayout.Foldout(_commoditiesFoldout, "Commodities", true);
// EditorGUILayout.EndHorizontal();
// if (_commoditiesFoldout)
// {
// using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
// {
// GUILayout.Space(10);
// _simpleFoldout = EditorGUILayout.Foldout(_simpleFoldout, "Simple", true);
// }
// if (_simpleFoldout)
// {
// foreach (var item in Database.Items.Values.Where(e=>e.GetType()==typeof(ItemData)).Cast<ItemData>())
// {
// var style = ListItemStyle;
// var selected = SelectedItem == item.ID;
// using (var h = new EditorGUILayout.HorizontalScope(selected?_selectedStyle:style))
// {
// if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none))
// select(item);
// GUILayout.Space(20);
// GUILayout.Label(item.Name, selected ? EditorStyles.whiteLabel : GUI.skin.label);
// }
// }
//
// using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
// {
// if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none))
// CreateItem(typeof(ItemData));
// GUILayout.Space(20);
// var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
// GUI.DrawTexture(rect, GlobalData.Instance.plus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
// GUILayout.Label("New Simple Commodity");
// }
// }
//
// using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
// {
// GUILayout.Space(10);
// _compoundFoldout = EditorGUILayout.Foldout(_compoundFoldout, "Compound", true);
// }
// if (_compoundFoldout)
// {
// foreach (var item in Database.Items.Values.Where(e=>e.GetType()==typeof(CraftedItem)).Cast<CraftedItem>())
// {
// var style = ListItemStyle;
// var selected = SelectedItem == item.GetId();
// using (var h = new EditorGUILayout.HorizontalScope(selected?_selectedStyle:style))
// {
// if (GUI.Button(h.rect, GUIContent.none, GUIStyle.none))
// select(item);
// GUILayout.Space(20);
// GUILayout.Label(item.Item.Name, selected ? EditorStyles.whiteLabel : GUI.skin.label);
// }
// }
//
// using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
// {
// if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none))
// CreateItem(typeof(CraftedItem));
// GUILayout.Space(20);
// var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
// GUI.DrawTexture(rect, GlobalData.Instance.plus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
// GUILayout.Label("New Compound Commodity");
// }
// }
// }
// EditorGUILayout.BeginHorizontal(ListItemStyle);
// _consumablesFoldout = EditorGUILayout.Foldout(_consumablesFoldout, "Consumables", true);
// EditorGUILayout.EndHorizontal();
// if (_consumablesFoldout)
// {
//
// }
// HACK: This ensures none of the controls in this window can be focused (usually from clicking foldouts)
//GUI.SetNextControlName("");
//GUI.FocusControl("");
}
private void CreateItem(Type type)
{
var newEntry = (DatabaseEntry) Activator.CreateInstance(type);
SelectedItem = newEntry.ID;
if(newEntry is INamedEntry entry)
entry.EntryName = $"New {type.Name}";
_databaseCache.Add(newEntry);
}
}

View file

@ -0,0 +1,81 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEditor;
using UnityEngine;
public static class EditorDispatcher
{
private static readonly Queue<Action> dispatchQueue = new Queue<Action>();
private static double timeSliceLimit = 10.0; // in miliseconds
private static Stopwatch timer;
static EditorDispatcher()
{
EditorApplication.update += Update;
timer = new Stopwatch();
}
private static void Update ()
{
lock (dispatchQueue)
{
int dispatchCount = 0;
timer.Reset();
timer.Start();
while (dispatchQueue.Count > 0 && (timer.Elapsed.TotalMilliseconds <= timeSliceLimit))
{
dispatchQueue.Dequeue().Invoke();
dispatchCount++;
}
timer.Stop();
if (dispatchCount > 0)
UnityEngine.Debug.Log(string.Format("[EditorDispatcher] Dispatched {0} calls in {1}ms", dispatchCount, timer.Elapsed.TotalMilliseconds));
// todo some logic for disconnecting update when the queue is empty
}
}
/// <summary>
/// Send an Action Delegate to be run on the main thread. See EditorDispatchActions for some common usecases.
/// </summary>
/// <param name="task">An action delegate to run on the main thread</param>
/// <returns>An AsyncDispatch that can be used to track if the dispatch has completed.</returns>
public static AsyncDispatch Dispatch(Action task)
{
lock (dispatchQueue)
{
AsyncDispatch dispatch = new AsyncDispatch();
// enqueue a new task that runs the supplied task and completes the dispatcher
dispatchQueue.Enqueue(() => { task(); dispatch.FinishedDispatch(); });
return dispatch;
}
}
}
/// <summary>
/// Represents the progress of the dispatched action. Can be yielded to in a coroutine.
/// If not using coroutines, look at the IsDone property to find out when its okay to proceed.
/// </summary>
public class AsyncDispatch : CustomYieldInstruction
{
public bool IsDone { get; private set; }
public override bool keepWaiting { get { return !IsDone; } }
/// <summary>
/// Flags this dispatch as completed.
/// </summary>
internal void FinishedDispatch()
{
IsDone = true;
}
}

View file

@ -1,8 +1,7 @@
fileFormatVersion: 2
guid: b7b84624f1ba7bd49b6cfc63b25f4b7c
timeCreated: 1485671367
licenseType: Pro
guid: b7269ba738c469a4ea5b50811ef07f11
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0

View file

@ -0,0 +1,79 @@
using System;
using MessagePack;
using MessagePack.Formatters;
using Newtonsoft.Json;
using RethinkDb.Driver;
using RethinkDb.Driver.Net;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
public class SerializerTestWindow : EditorWindow
{
// Singleton to avoid multiple instances of window.
private static SerializerTestWindow _instance;
private static readonly RethinkDB R = RethinkDB.R;
private Connection _connection;
private Object _object;
private void OnEnable()
{
_connection = R.Connection().Hostname("asgard.gamecult.games").Port(RethinkDBConstants.DefaultPort).Timeout(60).Connect();
}
public void OnGUI()
{
var obj = new ShieldData() {ID = Guid.NewGuid(), Name = "Foo"} as DatabaseEntry;
// This button serializes the texture reference and print the JSON representation
if (GUILayout.Button("Print MsgPack JSON"))
Debug.Log(MessagePackSerializer.SerializeToJson(obj));
if (GUILayout.Button("Print Newtonsoft JSON"))
Debug.Log(JsonConvert.SerializeObject(obj));
if (GUILayout.Button("Create Database"))
R.DbCreate("Aetheria").Run(_connection);
if (GUILayout.Button("Create Table"))
R.Db("Aetheria").TableCreate("Items").Run(_connection);
if (GUILayout.Button("Send to RethinkDB"))
R.Db("Aetheria").Table("Items").Insert(obj).Run(_connection);
}
#region EditorWindow Boilerplate
public SerializerTestWindow()
{
_instance = this;
}
static SerializerTestWindow ShowWindow()
{
if (_instance == null)
{
SerializerTestWindow window = EditorWindow.GetWindow<SerializerTestWindow>();
window.titleContent = new GUIContent("Serializer Test");
_instance = window;
window.Show();
}
else
_instance.Focus();
return _instance;
}
[MenuItem("Window/Serializer Test Tool")]
static void Init()
{
ShowWindow();
}
#endregion
}

View file

@ -1,8 +1,7 @@
fileFormatVersion: 2
guid: 8445204f2ee16e0408274b8400deef53
timeCreated: 1485929052
licenseType: Pro
guid: c18f225a1e4e8bc42bce3782701c9a6b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0

View file

@ -1,134 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using MessagePack;
using Unity.Mathematics;
using UnityEngine;
using Random = UnityEngine.Random;
using static Unity.Mathematics.math;
public static class Extensions
{
public static void BroadcastMessageExt<T>(this GameObject go, string methodName, object value = null, SendMessageOptions options = SendMessageOptions.RequireReceiver)
{
var monoList = new List<T>();
go.GetComponentsInChildren(true, monoList);
foreach (var component in monoList)
{
try
{
Type type = component.GetType();
MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance |
BindingFlags.NonPublic |
BindingFlags.Public |
BindingFlags.Static);
method.Invoke(component, new[] { value });
}
catch (Exception e)
{
//Re-create the Error thrown by the original SendMessage function
if (options == SendMessageOptions.RequireReceiver)
Debug.LogError("SendMessage " + methodName + " has no receiver!");
//Debug.LogError(e.Message);
}
}
}
private static Dictionary<Type,Type[]> InterfaceClasses = new Dictionary<Type, Type[]>();
public static Type[] GetAllInterfaceClasses(this Type type)
{
if (InterfaceClasses.ContainsKey(type))
return InterfaceClasses[type];
return InterfaceClasses[type] = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(ass => ass.GetTypes()).Where(t => t.IsClass && t.GetInterfaces().Contains(type)).ToArray();
}
public static bool IsDefault<T>(this T value) where T : struct
{
bool isDefault = value.Equals(default(T));
return isDefault;
}
public static Texture2D ToTexture(this Color c)
{
Texture2D result = new Texture2D(1, 1);
result.SetPixels(new[]{c});
result.Apply();
return result;
}
public static string SplitCamelCase( this string str )
{
return Regex.Replace(
Regex.Replace(
str,
@"(\P{Ll})(\P{Ll}\p{Ll})",
"$1 $2"
),
@"(\p{Ll})(\P{Ll})",
"$1 $2"
);
}
public static T RandomElement<T>(this IEnumerable<T> enumerable) => enumerable.ElementAt(Random.Range(0, enumerable.Count()));
public static float2 ToFloat2(this Vector2 v) => new float2(v.x, v.y);
public static float3 ToFloat3(this Vector3 v) => new float3(v.x, v.y, v.z);
public static Vector2 ToVector2(this float2 v) => new Vector2(v.x, v.y);
public static Vector3 ToVector3(this float3 v) => new Vector3(v.x, v.y, v.z);
public static IDatabaseEntry Get(this Guid entry) => Database.Get(entry);
public static T Get<T>(this Guid entry) where T : class, IDatabaseEntry => Database.Get(entry) as T;
public static Guid GetId(this IDatabaseEntry entry) => entry.Entry.ID;
public static string ToJson(this IDatabaseEntry entry) => MessagePackSerializer.SerializeToJson(entry);
public static byte[] Serialize(this IDatabaseEntry entry) => MessagePackSerializer.Serialize(entry);
public static bool IsImplementationOf(this Type baseType, Type interfaceType)
{
return baseType.GetInterfaces().Any(interfaceType.Equals);
}
private static readonly Dictionary<ICraftedItemInstance, float> Quality = new Dictionary<ICraftedItemInstance, float>();
public static float CompoundQuality(this ICraftedItemInstance item)
{
if (Quality.ContainsKey(item)) return Quality[item];
var quality = item.CraftedQuality;
var craftedIngredients = item.CraftedIngredients.Where(i => i is ICraftedItemInstance).ToArray();
if (craftedIngredients.Length > 0)
{
quality *= craftedIngredients.Cast<ICraftedItemInstance>().Average(CompoundQuality);
}
Quality[item] = quality;
return Quality[item];
}
private static readonly Dictionary<ICraftable, int> Tier = new Dictionary<ICraftable, int>();
public static int ItemTier(this ICraftable item)
{
if (Tier.ContainsKey(item)) return Tier[item];
Tier[item] = item.CraftingIngredients.Keys.Max(ci => (Database.Get<IItem>(ci) as ICraftable)?.ItemTier() ?? 0);
return Tier[item];
}
public static float Performance(this IEquippable item, float temperature)
{
return saturate(item.Equippable.HeatPerformanceCurve.Evaluate(saturate(
(temperature - item.Equippable.MinimumTemperature) /
(item.Equippable.MaximumTemperature - item.Equippable.MinimumTemperature))));
}
}

View file

@ -1,336 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Remoting.Messaging;
using JM.LinqFaster;
using MessagePack;
using MessagePack.Formatters;
using MIConvexHull;
using UniRx;
using UnityEngine;
using Unity.Mathematics;
using UnityEngine.UI.Extensions;
using Object = UnityEngine.Object;
// TODO: USE THIS EVERYWHERE
using static Unity.Mathematics.math;
using Random = UnityEngine.Random;
#if UNITY_EDITOR
using UnityEditor;
#endif
[MessagePackObject]
public class Ship
{
[Key("hull")]
public Gear Hull;
[Key("hardpoints")]
public List<Hardpoint> Hardpoints = new List<Hardpoint>();
[Key("cargo")]
public List<IItemInstance> Cargo = new List<IItemInstance>();
// [Key("bindings")] public Dictionary<KeyCode,Guid> Bindings = new Dictionary<KeyCode,Guid>();
//[IgnoreMember] public int HullHardpointCount;
[IgnoreMember] public Dictionary<Guid, IActivatedItemBehavior[]> ItemBindings;
[IgnoreMember] public IItemBehavior[] ItemBehaviors;
[IgnoreMember] public bool ForceThrust;
//[IgnoreMember] public Ship Ship;
[IgnoreMember] public Dictionary<Targetable, float> Contacts = new Dictionary<Targetable, float>();
[IgnoreMember] public float Temperature;
[IgnoreMember] public float Charge;
[IgnoreMember] public Targetable Target;
[IgnoreMember] public Vector2 Direction;
[IgnoreMember] public Dictionary<object, float> VisibilitySources = new Dictionary<object, float>();
//[IgnoreMember] public float Visibility;
private Hull _hullData;
private bool _hydrated = false;
[IgnoreMember] public Hull HullData => _hullData ?? (_hullData = Hull.EquippedItemData as Hull);
[IgnoreMember] public float Mass { get; private set; }
//[IgnoreMember] public float Visibility => VisibilitySources.Values.Sum();
public Gear GetEquipped(HardpointType type)
{
return Hardpoints.FirstOrDefault(hp => hp.HardpointData.Type == type)?.Item;
}
public T GetEquipped<T>() where T : class, IEquippable
{
return Hardpoints.FirstOrDefault(hp => hp.Item?.EquippedItemData is T)?.Item.EquippedItemData as T;
}
public void AddHeat(float heat)
{
Temperature += heat / Mass;
}
public void Hydrate()
{
GenerateBehaviors();
Mass = Hull.Mass + Hardpoints.Sum(hp => hp.Item?.Mass ?? 0) + Cargo.Sum(ii => ii.Mass);
//HullHardpointCount = Hardpoints.Count(hp => hp.HardpointData.Type == HardpointType.Hull);
_hydrated = true;
}
private void GenerateBehaviors()
{
ItemBehaviors = Hardpoints.Where(hp=>hp.Item!=null)
.Where(hp=>hp.Item.EquippedItemData.Equippable.Behaviors?.Any()??false)
.SelectMany(hp => hp.Item.EquippedItemData.Equippable.Behaviors
.Select(bd => bd.CreateInstance(this, hp.Item)))
.OrderBy(b => b.GetType().GetCustomAttribute<UpdateOrderAttribute>()?.Order ?? 0).ToArray();
ItemBindings = ItemBehaviors
.Where(b => b is IActivatedItemBehavior)
.GroupBy(b => b.Item.GetId(), (guid, behaviors) => new {guid, behaviors})
.ToDictionary(g => g.guid, g => g.behaviors.Cast<IActivatedItemBehavior>().ToArray());
}
// public void GenerateBindings()
// {
// Bindings = new Dictionary<KeyCode, Guid>();
//
// var bindables =
// ItemBindings.Select(id => new {id=id.Key, eq = id.Value.First().Hardpoint.Item.EquippedItemData}).ToList();
//
// var weapons = bindables.Where(i => i.eq.HardpointType.IsWeapon()).ToArray();
//
// var mouseButtons = Enumerable.Range((int) KeyCode.Mouse0, 3).Cast<KeyCode>();
// foreach (var x in weapons.Zip(mouseButtons, (binding, key) => new {binding,key}))
// {
// Bindings.Add(x.key, x.binding.id);
// bindables.Remove(x.binding);
// }
//
// var thruster = bindables.FirstOrDefault(x => x.eq.HardpointType == HardpointType.Thruster);
// if (thruster != null)
// {
// Bindings.Add(KeyCode.LeftShift, thruster.id);
// bindables.Remove(thruster);
// }
//
// var utility = bindables.FirstOrDefault(x => !x.eq.HardpointType.IsWeapon());
// if (utility != null)
// {
// Bindings.Add(KeyCode.Space, utility.id);
// bindables.Remove(utility);
// }
//
// var numKeys = Enumerable.Range((int) KeyCode.Alpha1, 9).Cast<KeyCode>();
// foreach (var x in bindables.Zip(numKeys, (binding, key) => new {binding,key}))
// {
// Bindings.Add(x.key, x.binding.id);
// }
//
// }
// public void Activate(KeyCode binding)
// {
// if (Bindings.ContainsKey(binding))
// foreach (var behavior in ItemBindings[Bindings[binding]])
// {
// behavior.Activate();
// if(behavior.Hardpoint.ActionBarButton!=null)
// behavior.Hardpoint.ActionBarButton.Background.color = Color.yellow;
// }
// }
//
// public void Deactivate(KeyCode binding)
// {
// if(Bindings.ContainsKey(binding))
// foreach (var behavior in ItemBindings[Bindings[binding]])
// {
// behavior.Deactivate();
// if(behavior.Hardpoint.ActionBarButton!=null)
// behavior.Hardpoint.ActionBarButton.Background.color = GlobalData.Instance.UnselectedElementColor;
// }
// }
public void FixedUpdate(float delta)
{
foreach (var kvp in Contacts.ToArray())
if (kvp.Key == null || Time.time - kvp.Value > GlobalData.Instance.TargetPersistenceDuration)
{
Contacts.Remove(kvp.Key);
if (kvp.Key == Target)
Target = null;
}
if (_hydrated)
{
var hull = Database.Get<Hull>(Hull.Data);
var rad = pow(Temperature, GlobalData.Instance.HeatRadiationPower) * GlobalData.Instance.HeatRadiationMultiplier;
Temperature -= rad * delta;
VisibilitySources[this] = rad;
foreach(var behavior in ItemBehaviors)
behavior.FixedUpdate(delta);
foreach (var hardpoint in Hardpoints)
{
if (hardpoint.Item.EquippedItemData.Performance(Temperature) < .01f)
hardpoint.Item.Durability -= delta;
}
}
}
public void Update(float delta)
{
foreach(var behavior in ItemBehaviors)
behavior.Update(delta);
}
// public void UpdateInput(float delta)
// {
// foreach (var key in Bindings.Keys)
// {
// if(Input.GetKeyDown(key))
// Activate(key);
// if(Input.GetKeyUp(key))
// Deactivate(key);
// }
//
// }
}
[MessagePackObject]
public class SimpleCommodity : IItemInstance
{
[Key("data")] public Guid Data;
[Key("quantity")] public int Quantity;
[Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry();
[IgnoreMember] private ItemData _item;
[IgnoreMember] public Guid ItemGuid => Data;
[IgnoreMember] public IItem ItemData => _item ?? (_item = Database.Get<ItemData>(Data));
[IgnoreMember] public DatabaseEntry Entry => DatabaseEntry;
[IgnoreMember] public float Mass => ItemData.Data.Mass * Quantity;
public static SimpleCommodity CreateInstance(Guid data, int count)
{
var item = Database.Get<ItemData>(data);
if (item != null)
return new SimpleCommodity
{
Data = data,
Quantity = count,
DatabaseEntry = new DatabaseEntry
{
ID = Guid.NewGuid(),
Name = item.Entry.Name
}
};
Debug.LogError("Attempted to create Simple Commodity instance using missing or incorrect item id");
return null;
}
}
[MessagePackObject]
public class Gear : ICraftedItemInstance
{
[Key("data")] public Guid Data;
[Key("durability")] public float Durability;
[Key("quality")] public float Quality;
[Key("ingredients")] public List<IItemInstance> Ingredients = new List<IItemInstance>();
[Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry();
[IgnoreMember] private IEquippable _equippedItem;
[IgnoreMember] public Guid ItemGuid => Data;
[IgnoreMember] public IItem ItemData => EquippedItemData;
[IgnoreMember] public DatabaseEntry Entry => DatabaseEntry;
[IgnoreMember] public float CraftedQuality => Quality;
[IgnoreMember] public IEnumerable<IItemInstance> CraftedIngredients => Ingredients;
[IgnoreMember] public IEquippable EquippedItemData => _equippedItem ?? (_equippedItem = Database.Get<IEquippable>(Data));
[IgnoreMember] public float Mass => ItemData.Data.Mass;
public static Gear CreateInstance(Guid data)
{
var item = Database.Get<IEquippable>(data);
if (item == null)
{
Debug.LogError("Attempted to create Gear instance using missing or incorrect item id");
return null;
}
var equippable = item.Equippable;
return new Gear
{
Data = data,
Durability = equippable.Durability,
Quality = Random.Range(.5f, 1),
Ingredients = item.CraftingIngredients.SelectMany(ci =>
{
var ingredient = Database.Get(ci.Key);
return ingredient is ItemData
? (IEnumerable<IItemInstance>) new[] {SimpleCommodity.CreateInstance(ci.Key, ci.Value)}
: Enumerable.Range(0, ci.Value).Select(i => CompoundCommodity.CreateInstance(ci.Key));
})
.ToList(),
DatabaseEntry = new DatabaseEntry
{
ID = Guid.NewGuid(),
Name = item.Entry.Name
}
};
}
}
[MessagePackObject]
public class CompoundCommodity : ICraftedItemInstance
{
[Key("data")] public Guid Data;
[Key("quality")] public float Quality;
[Key("ingredients")] public List<IItemInstance> Ingredients = new List<IItemInstance>();
[Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry();
[IgnoreMember] private ICraftable _item;
[IgnoreMember] public Guid ItemGuid => Data;
[IgnoreMember] public IItem ItemData => _item ?? (_item = Database.Get<ICraftable>(Data));
[IgnoreMember] public DatabaseEntry Entry => DatabaseEntry;
[IgnoreMember] public float CraftedQuality => Quality;
[IgnoreMember] public IEnumerable<IItemInstance> CraftedIngredients => Ingredients;
[IgnoreMember] public float Mass => ItemData.Data.Mass;
public static CompoundCommodity CreateInstance(Guid data)
{
var item = Database.Get<CraftedItem>(data);
if (item != null)
return new CompoundCommodity
{
Data = data,
Quality = Random.Range(.5f, 1),
Ingredients = item.CraftingIngredients.SelectMany(ci =>
{
var ingredient = Database.Get(ci.Key);
return ingredient is ItemData
? (IEnumerable<IItemInstance>) new[] {SimpleCommodity.CreateInstance(ci.Key, ci.Value)}
: Enumerable.Range(0, ci.Value).Select(i => CreateInstance(ci.Key));
})
.ToList(),
DatabaseEntry = new DatabaseEntry
{
ID = Guid.NewGuid(),
Name = item.Entry.Name
}
};
Debug.LogError("Attempted to create Compound Commodity instance using missing or incorrect item id");
return null;
}
}

View file

@ -1,82 +0,0 @@
#if !(UNITY_METRO || UNITY_WP8)
using UnityEngine;
namespace UniRx.Examples
{
// sample script, attach your object.
public class Sample01_ObservableWWW : MonoBehaviour
{
void Start()
{
// Basic: Download from google.
{
ObservableWWW.Get("http://google.co.jp/")
.Subscribe(
x => Debug.Log(x.Substring(0, 100)), // onSuccess
ex => Debug.LogException(ex)); // onError
}
// Linear Pattern with LINQ Query Expressions
// download after google, start bing download
{
var query = from google in ObservableWWW.Get("http://google.com/")
from bing in ObservableWWW.Get("http://bing.com/")
select new { google, bing };
var cancel = query.Subscribe(x => Debug.Log(x.google.Substring(0, 100) + ":" + x.bing.Substring(0, 100)));
// Call Dispose is cancel downloading.
cancel.Dispose();
}
// Observable.WhenAll is for parallel asynchronous operation
// (It's like Observable.Zip but specialized for single async operations like Task.WhenAll of .NET 4)
{
var parallel = Observable.WhenAll(
ObservableWWW.Get("http://google.com/"),
ObservableWWW.Get("http://bing.com/"),
ObservableWWW.Get("http://unity3d.com/"));
parallel.Subscribe(xs =>
{
Debug.Log(xs[0].Substring(0, 100)); // google
Debug.Log(xs[1].Substring(0, 100)); // bing
Debug.Log(xs[2].Substring(0, 100)); // unity
});
}
// with Progress
{
// notifier for progress
var progressNotifier = new ScheduledNotifier<float>();
progressNotifier.Subscribe(x => Debug.Log(x)); // write www.progress
// pass notifier to WWW.Get/Post
ObservableWWW.Get("http://google.com/", progress: progressNotifier).Subscribe();
}
// with Error
{
// If WWW has .error, ObservableWWW throws WWWErrorException to onError pipeline.
// WWWErrorException has RawErrorMessage, HasResponse, StatusCode, ResponseHeaders
ObservableWWW.Get("http://www.google.com/404")
.CatchIgnore((WWWErrorException ex) =>
{
Debug.Log(ex.RawErrorMessage);
if (ex.HasResponse)
{
Debug.Log(ex.StatusCode);
}
foreach (var item in ex.ResponseHeaders)
{
Debug.Log(item.Key + ":" + item.Value);
}
})
.Subscribe();
}
}
}
}
#endif

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: bf3770fc51ac89f45987dbde37ae81bd
timeCreated: 1455373901
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,39 +0,0 @@
using System;
using System.Collections;
using System.Threading;
using UnityEngine;
namespace UniRx.Examples
{
public class Sample05_ConvertFromCoroutine
{
// public method
public static IObservable<string> GetWWW(string url)
{
// convert coroutine to IObservable
return Observable.FromCoroutine<string>((observer, cancellationToken) => GetWWWCore(url, observer, cancellationToken));
}
// IEnumerator with callback
static IEnumerator GetWWWCore(string url, IObserver<string> observer, CancellationToken cancellationToken)
{
var www = new UnityEngine.WWW(url);
while (!www.isDone && !cancellationToken.IsCancellationRequested)
{
yield return null;
}
if (cancellationToken.IsCancellationRequested) yield break;
if (www.error != null)
{
observer.OnError(new Exception(www.error));
}
else
{
observer.OnNext(www.text);
observer.OnCompleted();
}
}
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 41f3df73f7da66b4980f6d9a86927796
timeCreated: 1455373898
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,57 +0,0 @@
using System;
using System.Collections;
using UnityEngine;
namespace UniRx.Examples
{
public class Sample06_ConvertToCoroutine : MonoBehaviour
{
// convert IObservable to Coroutine
void Start()
{
StartCoroutine(ComplexCoroutineTest());
}
IEnumerator ComplexCoroutineTest()
{
yield return new WaitForSeconds(1);
var v = default(int);
yield return Observable.Range(1, 10).StartAsCoroutine(x => v = x);
Debug.Log(v); // 10(callback is last value)
yield return new WaitForSeconds(3);
yield return Observable.Return(100).StartAsCoroutine(x => v = x);
Debug.Log(v); // 100
}
// Note:ToAwaitableEnumerator/StartAsCoroutine/LazyTask are obsolete way on Unity 5.3
// You can use ToYieldInstruction.
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2)
IEnumerator TestNewCustomYieldInstruction()
{
// wait Rx Observable.
yield return Observable.Timer(TimeSpan.FromSeconds(1)).ToYieldInstruction();
// you can change the scheduler(this is ignore Time.scale)
yield return Observable.Timer(TimeSpan.FromSeconds(1), Scheduler.MainThreadIgnoreTimeScale).ToYieldInstruction();
// get return value from ObservableYieldInstruction
var o = ObservableWWW.Get("http://unity3d.com/").ToYieldInstruction(throwOnError: false);
yield return o;
if (o.HasError) { Debug.Log(o.Error.ToString()); }
if (o.HasResult) { Debug.Log(o.Result); }
// other sample(wait until transform.position.y >= 100)
yield return this.ObserveEveryValueChanged(x => x.transform).FirstOrDefault(x => x.position.y >= 100).ToYieldInstruction();
}
#endif
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 5da8247fbc4a4c84e96a727b44903214
timeCreated: 1455373899
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -117,13 +117,7 @@ namespace UniRx
}
var type = current.GetType();
if (type == typeof(WWW))
{
var www = (WWW)current;
editorQueueWorker.Enqueue(_ => ConsumeEnumerator(UnwrapWaitWWW(www, routine)), null);
return;
}
else if (type == typeof(AsyncOperation))
if (type == typeof(AsyncOperation))
{
var asyncOperation = (AsyncOperation)current;
editorQueueWorker.Enqueue(_ => ConsumeEnumerator(UnwrapWaitAsyncOperation(asyncOperation, routine)), null);
@ -156,15 +150,6 @@ namespace UniRx
}
}
IEnumerator UnwrapWaitWWW(WWW www, IEnumerator continuation)
{
while (!www.isDone)
{
yield return null;
}
ConsumeEnumerator(continuation);
}
IEnumerator UnwrapWaitAsyncOperation(AsyncOperation asyncOperation, IEnumerator continuation)
{
while (!asyncOperation.isDone)
@ -431,7 +416,11 @@ namespace UniRx
{
#if UNITY_EDITOR
// Don't try to add a GameObject when the scene is not playing. Only valid in the Editor, EditorView.
if (!ScenePlaybackDetector.IsPlaying) return;
if (!ScenePlaybackDetector.IsPlaying)
{
//var _ = EditorThreadDispatcher.Instance;
return;
}
#endif
MainThreadDispatcher dispatcher = null;

View file

@ -233,7 +233,6 @@ namespace UniRx
{
readonly static HashSet<Type> YieldInstructionTypes = new HashSet<Type>
{
typeof(WWW),
typeof(WaitForEndOfFrame),
typeof(WaitForFixedUpdate),
typeof(WaitForSeconds),

View file

@ -1,431 +0,0 @@
using System;
using System.Collections;
using UnityEngine;
#if !UniRxLibrary
using ObservableUnity = UniRx.Observable;
#endif
namespace UniRx
{
using System.Threading;
#if !(UNITY_METRO || UNITY_WP8) && (UNITY_4_4 || UNITY_4_3 || UNITY_4_2 || UNITY_4_1 || UNITY_4_0_1 || UNITY_4_0 || UNITY_3_5 || UNITY_3_4 || UNITY_3_3 || UNITY_3_2 || UNITY_3_1 || UNITY_3_0_0 || UNITY_3_0 || UNITY_2_6_1 || UNITY_2_6)
// Fallback for Unity versions below 4.5
using Hash = System.Collections.Hashtable;
using HashEntry = System.Collections.DictionaryEntry;
#else
// Unity 4.5 release notes:
// WWW: deprecated 'WWW(string url, byte[] postData, Hashtable headers)',
// use 'public WWW(string url, byte[] postData, Dictionary<string, string> headers)' instead.
using Hash = System.Collections.Generic.Dictionary<string, string>;
using HashEntry = System.Collections.Generic.KeyValuePair<string, string>;
#endif
public static partial class ObservableWWW
{
public static IObservable<string> Get(string url, Hash headers = null, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<string>((observer, cancellation) => FetchText(new WWW(url, null, (headers ?? new Hash())), observer, progress, cancellation));
}
public static IObservable<byte[]> GetAndGetBytes(string url, Hash headers = null, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<byte[]>((observer, cancellation) => FetchBytes(new WWW(url, null, (headers ?? new Hash())), observer, progress, cancellation));
}
public static IObservable<WWW> GetWWW(string url, Hash headers = null, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<WWW>((observer, cancellation) => Fetch(new WWW(url, null, (headers ?? new Hash())), observer, progress, cancellation));
}
public static IObservable<string> Post(string url, byte[] postData, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<string>((observer, cancellation) => FetchText(new WWW(url, postData), observer, progress, cancellation));
}
public static IObservable<string> Post(string url, byte[] postData, Hash headers, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<string>((observer, cancellation) => FetchText(new WWW(url, postData, headers), observer, progress, cancellation));
}
public static IObservable<string> Post(string url, WWWForm content, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<string>((observer, cancellation) => FetchText(new WWW(url, content), observer, progress, cancellation));
}
public static IObservable<string> Post(string url, WWWForm content, Hash headers, IProgress<float> progress = null)
{
var contentHeaders = content.headers;
return ObservableUnity.FromCoroutine<string>((observer, cancellation) => FetchText(new WWW(url, content.data, MergeHash(contentHeaders, headers)), observer, progress, cancellation));
}
public static IObservable<byte[]> PostAndGetBytes(string url, byte[] postData, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<byte[]>((observer, cancellation) => FetchBytes(new WWW(url, postData), observer, progress, cancellation));
}
public static IObservable<byte[]> PostAndGetBytes(string url, byte[] postData, Hash headers, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<byte[]>((observer, cancellation) => FetchBytes(new WWW(url, postData, headers), observer, progress, cancellation));
}
public static IObservable<byte[]> PostAndGetBytes(string url, WWWForm content, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<byte[]>((observer, cancellation) => FetchBytes(new WWW(url, content), observer, progress, cancellation));
}
public static IObservable<byte[]> PostAndGetBytes(string url, WWWForm content, Hash headers, IProgress<float> progress = null)
{
var contentHeaders = content.headers;
return ObservableUnity.FromCoroutine<byte[]>((observer, cancellation) => FetchBytes(new WWW(url, content.data, MergeHash(contentHeaders, headers)), observer, progress, cancellation));
}
public static IObservable<WWW> PostWWW(string url, byte[] postData, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<WWW>((observer, cancellation) => Fetch(new WWW(url, postData), observer, progress, cancellation));
}
public static IObservable<WWW> PostWWW(string url, byte[] postData, Hash headers, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<WWW>((observer, cancellation) => Fetch(new WWW(url, postData, headers), observer, progress, cancellation));
}
public static IObservable<WWW> PostWWW(string url, WWWForm content, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<WWW>((observer, cancellation) => Fetch(new WWW(url, content), observer, progress, cancellation));
}
public static IObservable<WWW> PostWWW(string url, WWWForm content, Hash headers, IProgress<float> progress = null)
{
var contentHeaders = content.headers;
return ObservableUnity.FromCoroutine<WWW>((observer, cancellation) => Fetch(new WWW(url, content.data, MergeHash(contentHeaders, headers)), observer, progress, cancellation));
}
public static IObservable<AssetBundle> LoadFromCacheOrDownload(string url, int version, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<AssetBundle>((observer, cancellation) => FetchAssetBundle(WWW.LoadFromCacheOrDownload(url, version), observer, progress, cancellation));
}
public static IObservable<AssetBundle> LoadFromCacheOrDownload(string url, int version, uint crc, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<AssetBundle>((observer, cancellation) => FetchAssetBundle(WWW.LoadFromCacheOrDownload(url, version, crc), observer, progress, cancellation));
}
// over Unity5 supports Hash128
#if !(UNITY_4_7 || UNITY_4_6 || UNITY_4_5 || UNITY_4_4 || UNITY_4_3 || UNITY_4_2 || UNITY_4_1 || UNITY_4_0_1 || UNITY_4_0 || UNITY_3_5 || UNITY_3_4 || UNITY_3_3 || UNITY_3_2 || UNITY_3_1 || UNITY_3_0_0 || UNITY_3_0 || UNITY_2_6_1 || UNITY_2_6)
public static IObservable<AssetBundle> LoadFromCacheOrDownload(string url, Hash128 hash128, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<AssetBundle>((observer, cancellation) => FetchAssetBundle(WWW.LoadFromCacheOrDownload(url, hash128), observer, progress, cancellation));
}
public static IObservable<AssetBundle> LoadFromCacheOrDownload(string url, Hash128 hash128, uint crc, IProgress<float> progress = null)
{
return ObservableUnity.FromCoroutine<AssetBundle>((observer, cancellation) => FetchAssetBundle(WWW.LoadFromCacheOrDownload(url, hash128, crc), observer, progress, cancellation));
}
#endif
// over 4.5, Hash define is Dictionary.
// below Unity 4.5, WWW only supports Hashtable.
// Unity 4.5, 4.6 WWW supports Dictionary and [Obsolete]Hashtable but WWWForm.content is Hashtable.
// Unity 5.0 WWW only supports Dictionary and WWWForm.content is also Dictionary.
#if !(UNITY_METRO || UNITY_WP8) && (UNITY_4_5 || UNITY_4_6 || UNITY_4_7)
static Hash MergeHash(Hashtable wwwFormHeaders, Hash externalHeaders)
{
var newHeaders = new Hash();
foreach (DictionaryEntry item in wwwFormHeaders)
{
newHeaders[item.Key.ToString()] = item.Value.ToString();
}
foreach (HashEntry item in externalHeaders)
{
newHeaders[item.Key] = item.Value;
}
return newHeaders;
}
#else
static Hash MergeHash(Hash wwwFormHeaders, Hash externalHeaders)
{
foreach (HashEntry item in externalHeaders)
{
wwwFormHeaders[item.Key] = item.Value;
}
return wwwFormHeaders;
}
#endif
static IEnumerator Fetch(WWW www, IObserver<WWW> observer, IProgress<float> reportProgress, CancellationToken cancel)
{
using (www)
{
if (reportProgress != null)
{
while (!www.isDone && !cancel.IsCancellationRequested)
{
try
{
reportProgress.Report(www.progress);
}
catch (Exception ex)
{
observer.OnError(ex);
yield break;
}
yield return null;
}
}
else
{
if (!www.isDone)
{
yield return www;
}
}
if (cancel.IsCancellationRequested)
{
yield break;
}
if (reportProgress != null)
{
try
{
reportProgress.Report(www.progress);
}
catch (Exception ex)
{
observer.OnError(ex);
yield break;
}
}
if (!string.IsNullOrEmpty(www.error))
{
observer.OnError(new WWWErrorException(www, www.text));
}
else
{
observer.OnNext(www);
observer.OnCompleted();
}
}
}
static IEnumerator FetchText(WWW www, IObserver<string> observer, IProgress<float> reportProgress, CancellationToken cancel)
{
using (www)
{
if (reportProgress != null)
{
while (!www.isDone && !cancel.IsCancellationRequested)
{
try
{
reportProgress.Report(www.progress);
}
catch (Exception ex)
{
observer.OnError(ex);
yield break;
}
yield return null;
}
}
else
{
if (!www.isDone)
{
yield return www;
}
}
if (cancel.IsCancellationRequested)
{
yield break;
}
if (reportProgress != null)
{
try
{
reportProgress.Report(www.progress);
}
catch (Exception ex)
{
observer.OnError(ex);
yield break;
}
}
if (!string.IsNullOrEmpty(www.error))
{
observer.OnError(new WWWErrorException(www, www.text));
}
else
{
observer.OnNext(www.text);
observer.OnCompleted();
}
}
}
static IEnumerator FetchBytes(WWW www, IObserver<byte[]> observer, IProgress<float> reportProgress, CancellationToken cancel)
{
using (www)
{
if (reportProgress != null)
{
while (!www.isDone && !cancel.IsCancellationRequested)
{
try
{
reportProgress.Report(www.progress);
}
catch (Exception ex)
{
observer.OnError(ex);
yield break;
}
yield return null;
}
}
else
{
if (!www.isDone)
{
yield return www;
}
}
if (cancel.IsCancellationRequested)
{
yield break;
}
if (reportProgress != null)
{
try
{
reportProgress.Report(www.progress);
}
catch (Exception ex)
{
observer.OnError(ex);
yield break;
}
}
if (!string.IsNullOrEmpty(www.error))
{
observer.OnError(new WWWErrorException(www, www.text));
}
else
{
observer.OnNext(www.bytes);
observer.OnCompleted();
}
}
}
static IEnumerator FetchAssetBundle(WWW www, IObserver<AssetBundle> observer, IProgress<float> reportProgress, CancellationToken cancel)
{
using (www)
{
if (reportProgress != null)
{
while (!www.isDone && !cancel.IsCancellationRequested)
{
try
{
reportProgress.Report(www.progress);
}
catch (Exception ex)
{
observer.OnError(ex);
yield break;
}
yield return null;
}
}
else
{
if (!www.isDone)
{
yield return www;
}
}
if (cancel.IsCancellationRequested)
{
yield break;
}
if (reportProgress != null)
{
try
{
reportProgress.Report(www.progress);
}
catch (Exception ex)
{
observer.OnError(ex);
yield break;
}
}
if (!string.IsNullOrEmpty(www.error))
{
observer.OnError(new WWWErrorException(www, ""));
}
else
{
observer.OnNext(www.assetBundle);
observer.OnCompleted();
}
}
}
}
public class WWWErrorException : Exception
{
public string RawErrorMessage { get; private set; }
public bool HasResponse { get; private set; }
public string Text { get; private set; }
public System.Net.HttpStatusCode StatusCode { get; private set; }
public System.Collections.Generic.Dictionary<string, string> ResponseHeaders { get; private set; }
public WWW WWW { get; private set; }
// cache the text because if www was disposed, can't access it.
public WWWErrorException(WWW www, string text)
{
this.WWW = www;
this.RawErrorMessage = www.error;
this.ResponseHeaders = www.responseHeaders;
this.HasResponse = false;
this.Text = text;
var splitted = RawErrorMessage.Split(' ', ':');
if (splitted.Length != 0)
{
int statusCode;
if (int.TryParse(splitted[0], out statusCode))
{
this.HasResponse = true;
this.StatusCode = (System.Net.HttpStatusCode)statusCode;
}
}
}
public override string ToString()
{
var text = this.Text;
if (string.IsNullOrEmpty(text))
{
return RawErrorMessage;
}
else
{
return RawErrorMessage + " " + text;
}
}
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: ba71e5544e233dd4b83d4c5a6c696d05
timeCreated: 1455373900
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -52,7 +52,7 @@ namespace UniRx
// InitializeOnLoad ensures that this constructor is called when the Unity Editor is started.
static ScenePlaybackDetector()
{
EditorApplication.playmodeStateChanged += () =>
EditorApplication.playModeStateChanged += (state) =>
{
// Before scene start: isPlayingOrWillChangePlaymode = false; isPlaying = false
// Pressed Playback button: isPlayingOrWillChangePlaymode = true; isPlaying = false

View file

@ -1,24 +0,0 @@
///Credit ChoMPHi
///Sourced from - http://forum.unity3d.com/threads/accordion-type-layout.271818/
using UnityEditor;
using UnityEditor.UI;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(AccordionElement), true)]
public class AccordionElementEditor : ToggleEditor {
public override void OnInspectorGUI()
{
this.serializedObject.Update();
EditorGUILayout.PropertyField(this.serializedObject.FindProperty("m_MinHeight"));
this.serializedObject.ApplyModifiedProperties();
base.serializedObject.Update();
EditorGUILayout.PropertyField(base.serializedObject.FindProperty("m_IsOn"));
EditorGUILayout.PropertyField(base.serializedObject.FindProperty("m_Interactable"));
base.serializedObject.ApplyModifiedProperties();
}
}
}

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 8882b502b0c65b24ba4623d6a383815b
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -1,77 +0,0 @@
///Credit Jason Horsburgh
///Sourced from - https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/issues/127/uilinerenderer-mesh-not-updating-in-editor
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(UILineRenderer))]
public class BezierLineRendererEditor : Editor
{
void OnSceneGUI()
{
UILineRenderer curveRenderer = target as UILineRenderer;
if (!curveRenderer || curveRenderer.drivenExternally || curveRenderer.Points == null || curveRenderer.Points.Length < 2)
{
return;
}
var oldMatrix = Handles.matrix;
var transform = curveRenderer.GetComponent<RectTransform>();
//Pivot must be 0,0 to edit
//transform.pivot = Vector2.zero;
Handles.matrix = transform.localToWorldMatrix;
var sizeX = curveRenderer.rectTransform.rect.width;
var sizeY = curveRenderer.rectTransform.rect.height;
var offsetX = -curveRenderer.rectTransform.pivot.x * sizeX;
var offsetY = -curveRenderer.rectTransform.pivot.y * sizeY;
Vector2[] points = new Vector2[curveRenderer.Points.Length];
for (int i = 0; i < curveRenderer.Points.Length; i++)
{
points[i] = curveRenderer.Points[i];
}
//Need to transform points to worldspace! when set to Relative
if (curveRenderer.RelativeSize)
{
for (int i = 0; i < points.Length; i++)
{
points[i] = new Vector2(points[i].x * sizeX + offsetX, points[i].y * sizeY + offsetY);
}
}
for (int i = 0; i < points.Length - 1; i += 2)
{
Handles.DrawLine(points[i], points[i + 1]);
}
for (int i = 0; i < points.Length; ++i)
{
using (var check = new EditorGUI.ChangeCheckScope())
{
var p = Handles.PositionHandle(points[i], Quaternion.identity);
if (check.changed)
{
Undo.RecordObject(curveRenderer, "Changed Curve Position");
if (curveRenderer.RelativeSize)
{
curveRenderer.Points[i] = new Vector2((p.x - offsetX) / sizeX, (p.y - offsetY) / sizeY);
}
else
{
curveRenderer.Points[i] = p;
}
curveRenderer.transform.gameObject.SetActive(false);
curveRenderer.transform.gameObject.SetActive(true);
}
}
}
Handles.matrix = oldMatrix;
}
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 4ef6a0d3c3259384982ae3974fe7e618
timeCreated: 1492258093
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,67 +0,0 @@
///Credit judah4
///Sourced from - http://forum.unity3d.com/threads/color-picker.267043/
using UnityEditor;
using UnityEditor.UI;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(BoxSlider), true)]
[CanEditMultipleObjects]
public class BoxSliderEditor : SelectableEditor
{
SerializedProperty m_HandleRect;
SerializedProperty m_MinValue;
SerializedProperty m_MaxValue;
SerializedProperty m_WholeNumbers;
SerializedProperty m_ValueX;
SerializedProperty m_ValueY;
SerializedProperty m_OnValueChanged;
protected override void OnEnable()
{
base.OnEnable();
m_HandleRect = serializedObject.FindProperty("m_HandleRect");
m_MinValue = serializedObject.FindProperty("m_MinValue");
m_MaxValue = serializedObject.FindProperty("m_MaxValue");
m_WholeNumbers = serializedObject.FindProperty("m_WholeNumbers");
m_ValueX = serializedObject.FindProperty("m_ValueX");
m_ValueY = serializedObject.FindProperty("m_ValueY");
m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged");
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
EditorGUILayout.Space();
serializedObject.Update();
EditorGUILayout.PropertyField(m_HandleRect);
if (m_HandleRect.objectReferenceValue != null)
{
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_MinValue);
EditorGUILayout.PropertyField(m_MaxValue);
EditorGUILayout.PropertyField(m_WholeNumbers);
EditorGUILayout.Slider(m_ValueX, m_MinValue.floatValue, m_MaxValue.floatValue);
EditorGUILayout.Slider(m_ValueY, m_MinValue.floatValue, m_MaxValue.floatValue);
// Draw the event notification options
EditorGUILayout.Space();
EditorGUILayout.PropertyField(m_OnValueChanged);
}
else
{
EditorGUILayout.HelpBox("Specify a RectTransform for the slider fill or the slider handle or both. Each must have a parent RectTransform that it can slide within.", MessageType.Info);
}
serializedObject.ApplyModifiedProperties();
}
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 8701e045b26e51f4eb345f2ccb3c13f5
timeCreated: 1426804458
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,59 +0,0 @@
/// Credit Titinious (https://github.com/Titinious)
/// Sourced from - https://github.com/Titinious/CurlyUI
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(CUIBezierCurve))]
[CanEditMultipleObjects]
public class CUIBezierCurveEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
}
protected void OnSceneGUI()
{
CUIBezierCurve script = (CUIBezierCurve)this.target;
if (script.ControlPoints != null)
{
Vector3[] controlPoints = script.ControlPoints;
Transform handleTransform = script.transform;
Quaternion handleRotation = script.transform.rotation;
for (int p = 0; p < CUIBezierCurve.CubicBezierCurvePtNum; p++)
{
EditorGUI.BeginChangeCheck();
Vector3 newPt = Handles.DoPositionHandle(handleTransform.TransformPoint(controlPoints[p]), handleRotation);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(script, "Move Point");
EditorUtility.SetDirty(script);
controlPoints[p] = handleTransform.InverseTransformPoint(newPt);
script.Refresh();
}
}
Handles.color = Color.gray;
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[0]), handleTransform.TransformPoint(controlPoints[1]));
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[1]), handleTransform.TransformPoint(controlPoints[2]));
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[2]), handleTransform.TransformPoint(controlPoints[3]));
int sampleSize = 10;
Handles.color = Color.white;
for (int s = 0; s < sampleSize; s++)
{
Handles.DrawLine(handleTransform.TransformPoint(script.GetPoint((float)s / sampleSize)), handleTransform.TransformPoint(script.GetPoint((float)(s + 1) / sampleSize)));
}
script.EDITOR_ControlPoints = controlPoints;
}
}
}
}

View file

@ -1,187 +0,0 @@
/// Credit Titinious (https://github.com/Titinious)
/// Sourced from - https://github.com/Titinious/CurlyUI
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(CUIGraphic), true)]
public class CUIGraphicEditor : Editor {
protected static bool isCurveGpFold = false;
protected Vector3[] reuse_Vector3s = new Vector3[4];
public override void OnInspectorGUI()
{
CUIGraphic script = (CUIGraphic)this.target;
EditorGUILayout.HelpBox("CurlyUI (CUI) should work with most of the Unity UI. For Image, use CUIImage; for Text, use CUIText; and for others (e.g. RawImage), use CUIGraphic", MessageType.Info);
if (script.UIGraphic == null)
{
EditorGUILayout.HelpBox("CUI is an extension to Unity's UI. You must set Ui Graphic with a Unity Graphic component (e.g. Image, Text, RawImage)", MessageType.Error);
}
else
{
if (script.UIGraphic is Image && script.GetType() != typeof(CUIImage))
{
EditorGUILayout.HelpBox("Although CUI components are generalized. It is recommended that for Image, use CUIImage", MessageType.Warning);
}
else if (script.UIGraphic is Text && script.GetType() != typeof(CUIText))
{
EditorGUILayout.HelpBox("Although CUI components are generalized. It is recommended that for Text, use CUIText", MessageType.Warning);
}
EditorGUILayout.HelpBox("Now that CUI is ready, change the control points of the top and bottom bezier curves to curve/morph the UI. Improve resolution when the UI seems to look poorly when curved/morphed should help.", MessageType.Info);
}
DrawDefaultInspector();
// draw the editor that shows the position ratio of all control points from the two bezier curves
isCurveGpFold = EditorGUILayout.Foldout(isCurveGpFold, "Curves Position Ratios");
if (isCurveGpFold)
{
EditorGUI.indentLevel++;
EditorGUILayout.LabelField("Top Curve");
EditorGUI.indentLevel++;
Vector3[] controlPoints = script.RefCurvesControlRatioPoints[1].array;
EditorGUI.BeginChangeCheck();
for (int p = 0; p < controlPoints.Length; p++)
{
reuse_Vector3s[p] = EditorGUILayout.Vector3Field(string.Format("Control Points {0}", p + 1), controlPoints[p]);
}
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(script, "Change Ratio Points");
EditorUtility.SetDirty(script);
System.Array.Copy(reuse_Vector3s, script.RefCurvesControlRatioPoints[1].array, controlPoints.Length);
script.UpdateCurveControlPointPositions();
}
EditorGUI.indentLevel--;
EditorGUILayout.LabelField("Bottom Curve");
EditorGUI.indentLevel++;
controlPoints = script.RefCurvesControlRatioPoints[0].array;
EditorGUI.BeginChangeCheck();
for (int p = 0; p < controlPoints.Length; p++)
{
reuse_Vector3s[p] = EditorGUILayout.Vector3Field(string.Format("Control Points {0}", p + 1), controlPoints[p]);
}
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(script, "Change Ratio Points");
EditorUtility.SetDirty(script);
System.Array.Copy(reuse_Vector3s, controlPoints, controlPoints.Length);
script.UpdateCurveControlPointPositions();
}
EditorGUI.indentLevel--;
EditorGUI.indentLevel--;
}
EditorGUILayout.Space();
if (GUILayout.Button("Fit Bezier curves to rect transform"))
{
Undo.RecordObject(script, "Fit to Rect Transform");
Undo.RecordObject(script.RefCurves[0], "Fit to Rect Transform");
Undo.RecordObject(script.RefCurves[1], "Fit to Rect Transform");
EditorUtility.SetDirty(script);
script.FixTextToRectTrans();
script.Refresh();
}
EditorGUILayout.Space();
// disable group to prevent allowing the reference be used when there is no reference CUI
EditorGUI.BeginDisabledGroup(script.RefCUIGraphic == null);
if (GUILayout.Button("Reference CUI component for curves"))
{
Undo.RecordObject(script, "Reference Reference CUI");
Undo.RecordObject(script.RefCurves[0], "Reference Reference CUI");
Undo.RecordObject(script.RefCurves[1], "Reference Reference CUI");
EditorUtility.SetDirty(script);
script.ReferenceCUIForBCurves();
script.Refresh();
}
EditorGUILayout.HelpBox("Auto set the curves' control points by refencing another CUI. You need to set Ref CUI Graphic (e.g. CUIImage) first.", MessageType.Info);
EditorGUI.EndDisabledGroup();
}
protected virtual void OnSceneGUI()
{
// for CUITextEditor, allow using scene UI to change the control points of the bezier curves
CUIGraphic script = (CUIGraphic)this.target;
script.ReportSet();
for (int c = 0; c < script.RefCurves.Length; c++)
{
CUIBezierCurve curve = script.RefCurves[c];
if (curve.ControlPoints != null)
{
Vector3[] controlPoints = curve.ControlPoints;
Transform handleTransform = curve.transform;
Quaternion handleRotation = curve.transform.rotation;
for (int p = 0; p < CUIBezierCurve.CubicBezierCurvePtNum; p++)
{
EditorGUI.BeginChangeCheck();
Handles.Label(handleTransform.TransformPoint(controlPoints[p]), string.Format("Control Point {0}", p + 1));
Vector3 newPt = Handles.DoPositionHandle(handleTransform.TransformPoint(controlPoints[p]), handleRotation);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(curve, "Move Point");
Undo.RecordObject(script, "Move Point");
EditorUtility.SetDirty(curve);
controlPoints[p] = handleTransform.InverseTransformPoint(newPt);
}
}
Handles.color = Color.gray;
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[0]), handleTransform.TransformPoint(controlPoints[1]));
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[1]), handleTransform.TransformPoint(controlPoints[2]));
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[2]), handleTransform.TransformPoint(controlPoints[3]));
int sampleSize = 10;
Handles.color = Color.white;
for (int s = 0; s < sampleSize; s++)
{
Handles.DrawLine(handleTransform.TransformPoint(curve.GetPoint((float)s / sampleSize)), handleTransform.TransformPoint(curve.GetPoint((float)(s + 1) / sampleSize)));
}
curve.EDITOR_ControlPoints = controlPoints;
}
}
if (script.RefCurves != null)
{
Handles.DrawLine(script.RefCurves[0].transform.TransformPoint(script.RefCurves[0].ControlPoints[0]), script.RefCurves[1].transform.TransformPoint(script.RefCurves[1].ControlPoints[0]));
Handles.DrawLine(script.RefCurves[0].transform.TransformPoint(script.RefCurves[0].ControlPoints[3]), script.RefCurves[1].transform.TransformPoint(script.RefCurves[1].ControlPoints[3]));
}
script.Refresh();
}
}
}

View file

@ -1,88 +0,0 @@
/// Credit Titinious (https://github.com/Titinious)
/// Sourced from - https://github.com/Titinious/CurlyUI
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(CUIImage))]
public class CUIImageEditor : CUIGraphicEditor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
CUIImage script = (CUIImage)this.target;
EditorGUILayout.Space();
EditorGUI.BeginChangeCheck();
EditorGUI.BeginDisabledGroup(!(script.UIImage.type == Image.Type.Sliced || script.UIImage.type == Image.Type.Tiled));
Vector2 newCornerRatio = EditorGUILayout.Vector2Field("Corner Ratio", script.cornerPosRatio);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(script, "Change Corner Ratio");
EditorUtility.SetDirty(script);
script.cornerPosRatio = newCornerRatio;
}
if (GUILayout.Button("Use native corner ratio"))
{
Undo.RecordObject(script, "Change Corner Ratio");
EditorUtility.SetDirty(script);
script.cornerPosRatio = script.OriCornerPosRatio;
}
if (script.UIImage.type == Image.Type.Sliced || script.UIImage.type == Image.Type.Filled)
{
EditorGUILayout.HelpBox("With CUIImage, you can also adjust the size of the corners for filled or sliced Image. The grey sphere in the editor scene could also be moved to change the corner's size.", MessageType.Info);
}
else
{
EditorGUILayout.HelpBox("With CUIImage, you can also adjust the size of the corners for filled or sliced Image. You need to set Image to filled or sliced to use this feature.", MessageType.Info);
}
EditorGUI.EndDisabledGroup();
}
protected override void OnSceneGUI()
{
base.OnSceneGUI();
CUIImage script = (CUIImage)this.target;
if (script.UIImage.type == Image.Type.Sliced || script.UIImage.type == Image.Type.Tiled)
{
Vector3 cornerPos = Vector3.zero;//
if (script.IsCurved)
{
cornerPos = script.GetBCurveSandwichSpacePoint(script.cornerPosRatio.x, script.cornerPosRatio.y);
}
else
{
cornerPos.x = script.cornerPosRatio.x * script.RectTrans.rect.width - script.RectTrans.pivot.x * script.RectTrans.rect.width;
cornerPos.y = script.cornerPosRatio.y * script.RectTrans.rect.height - script.RectTrans.pivot.y * script.RectTrans.rect.height;
}
Handles.color = Color.gray;
EditorGUI.BeginChangeCheck();
Vector3 newCornerPos = Handles.FreeMoveHandle(script.transform.TransformPoint(cornerPos), script.transform.rotation, HandleUtility.GetHandleSize(script.transform.TransformPoint(cornerPos)) / 7, Vector3.one, Handles.SphereHandleCap);
Handles.Label(newCornerPos, string.Format("Corner Mover"));
newCornerPos = script.transform.InverseTransformPoint(newCornerPos);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(script, "Move Corner");
EditorUtility.SetDirty(script);
script.cornerPosRatio = new Vector2(newCornerPos.x, newCornerPos.y);
script.cornerPosRatio.x = (script.cornerPosRatio.x + script.RectTrans.pivot.x * script.RectTrans.rect.width) / script.RectTrans.rect.width;
script.cornerPosRatio.y = (script.cornerPosRatio.y + script.RectTrans.pivot.y * script.RectTrans.rect.height) / script.RectTrans.rect.height;
}
}
}
}
}

View file

@ -1,10 +0,0 @@
/// Credit Titinious (https://github.com/Titinious)
/// Sourced from - https://github.com/Titinious/CurlyUI
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(CUIText))]
public class CUITextEditor : CUIGraphicEditor { }
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 041976c43b8439747a030b45a4712b77
timeCreated: 1485929052
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,116 +0,0 @@
/// Credit dakka
/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/#post-1752415
/// Notes - Mod from Yilmaz Kiymaz's editor scripts presentation at Unite 2013
/// Updated ddreaper - removed Linq use, not required.
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
public class CanvasGroupActivator : EditorWindow
{
[MenuItem("Window/UI/Extensions/Canvas Groups Activator")]
public static void InitWindow()
{
EditorWindow.GetWindow<CanvasGroupActivator>();
}
CanvasGroup[] canvasGroups;
void OnEnable()
{
ObtainCanvasGroups();
}
void OnFocus()
{
ObtainCanvasGroups();
}
void ObtainCanvasGroups()
{
canvasGroups = GameObject.FindObjectsOfType<CanvasGroup>();
}
void OnGUI()
{
if (canvasGroups == null)
{
return;
}
GUILayout.Space(10f);
GUILayout.Label("Canvas Groups");
for (int i = 0; i < canvasGroups.Length; i++)
{
if (canvasGroups[i] == null) { continue; }
bool initialActive = false;
if (canvasGroups[i].alpha == 1.0f)
initialActive = true;
bool active = EditorGUILayout.Toggle(canvasGroups[i].name, initialActive);
if (active != initialActive)
{
//If deactivated and initially active
if (!active && initialActive)
{
//Deactivate this
canvasGroups[i].alpha = 0f;
canvasGroups[i].interactable = false;
canvasGroups[i].blocksRaycasts = false;
}
//If activated and initially deactive
else if (active && !initialActive)
{
//Deactivate all others and activate this
HideAllGroups();
canvasGroups[i].alpha = 1.0f;
canvasGroups[i].interactable = true;
canvasGroups[i].blocksRaycasts = true;
}
}
}
GUILayout.Space(5f);
if (GUILayout.Button("Show All"))
{
ShowAllGroups();
}
if (GUILayout.Button("Hide All"))
{
HideAllGroups();
}
}
void ShowAllGroups()
{
foreach (var group in canvasGroups)
{
if (group != null)
{
group.alpha = 1.0f;
group.interactable = true;
group.blocksRaycasts = true;
}
}
}
void HideAllGroups()
{
foreach (var group in canvasGroups)
{
if (group != null)
{
group.alpha = 0;
group.interactable = false;
group.blocksRaycasts = false;
}
}
}
}
}

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: f60a419e63d329f43ba1bf57e98b34bf
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -1,21 +0,0 @@
/// Credit Slipp Douglas Thompson
/// Sourced from - https://gist.github.com/capnslipp/349c18283f2fea316369
///
using UnityEditor;
using UnityEditor.UI;
namespace UnityEngine.UI.Extensions
{
[CanEditMultipleObjects, CustomEditor(typeof(NonDrawingGraphic), false)]
public class NonDrawingGraphicEditor : GraphicEditor
{
public override void OnInspectorGUI()
{
base.serializedObject.Update();
EditorGUILayout.PropertyField(base.m_Script, new GUILayoutOption[0]);
// skipping AppearanceControlsGUI
base.RaycastControlsGUI();
base.serializedObject.ApplyModifiedProperties();
}
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: ee2802949feca4c4c934331b6a0dc379
timeCreated: 1483566748
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,19 +0,0 @@
/// Credit tanoshimi
/// Sourced from - https://forum.unity3d.com/threads/read-only-fields.68976/
///
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
public class ReadOnlyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
GUI.enabled = false;
EditorGUI.PropertyField(position, property, label, true);
GUI.enabled = true;
}
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 33c90f5149877a242981372f6cde9a35
timeCreated: 1498392707
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,38 +0,0 @@
/// Credit drobina, w34edrtfg, playemgames
/// Sourced from - http://forum.unity3d.com/threads/sprite-icons-with-text-e-g-emoticons.265927/
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[CanEditMultipleObjects]
[CustomEditor(typeof(TextPic))]
public class TextPicEditor : UnityEditor.UI.TextEditor
{
private SerializedProperty ImageScalingFactorProp;
private SerializedProperty hyperlinkColorProp;
private SerializedProperty imageOffsetProp;
private SerializedProperty iconList;
protected override void OnEnable()
{
base.OnEnable();
ImageScalingFactorProp = serializedObject.FindProperty("ImageScalingFactor");
hyperlinkColorProp = serializedObject.FindProperty("hyperlinkColor");
imageOffsetProp = serializedObject.FindProperty("imageOffset");
iconList = serializedObject.FindProperty("inspectorIconList");
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
serializedObject.Update();
EditorGUILayout.PropertyField(imageOffsetProp, new GUIContent("Image Offset"));
EditorGUILayout.PropertyField(ImageScalingFactorProp, new GUIContent("Image Scaling Factor"));
EditorGUILayout.PropertyField(hyperlinkColorProp, new GUIContent("Hyperlink Color"));
EditorGUILayout.PropertyField(iconList, new GUIContent("Icon List"), true);
serializedObject.ApplyModifiedProperties();
}
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 5fe8e67609bbee14d8ad0805aac72799
timeCreated: 1468515486
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 3cac6d35505037446b512aea22d40688
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -1,115 +0,0 @@
/// Credit Senshi
/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/ (uGUITools link)
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
public static class uGUITools
{
[MenuItem("uGUI/Anchors to Corners %[")]
static void AnchorsToCorners()
{
foreach (Transform transform in Selection.transforms)
{
RectTransform t = transform as RectTransform;
RectTransform pt = Selection.activeTransform.parent as RectTransform;
if (t == null || pt == null) return;
Vector2 newAnchorsMin = new Vector2(t.anchorMin.x + t.offsetMin.x / pt.rect.width,
t.anchorMin.y + t.offsetMin.y / pt.rect.height);
Vector2 newAnchorsMax = new Vector2(t.anchorMax.x + t.offsetMax.x / pt.rect.width,
t.anchorMax.y + t.offsetMax.y / pt.rect.height);
t.anchorMin = newAnchorsMin;
t.anchorMax = newAnchorsMax;
t.offsetMin = t.offsetMax = new Vector2(0, 0);
}
}
[MenuItem("uGUI/Corners to Anchors %]")]
static void CornersToAnchors()
{
foreach (Transform transform in Selection.transforms)
{
RectTransform t = transform as RectTransform;
if (t == null) return;
t.offsetMin = t.offsetMax = new Vector2(0, 0);
}
}
[MenuItem("uGUI/Mirror Horizontally Around Anchors %;")]
static void MirrorHorizontallyAnchors()
{
MirrorHorizontally(false);
}
[MenuItem("uGUI/Mirror Horizontally Around Parent Center %:")]
static void MirrorHorizontallyParent()
{
MirrorHorizontally(true);
}
static void MirrorHorizontally(bool mirrorAnchors)
{
foreach (Transform transform in Selection.transforms)
{
RectTransform t = transform as RectTransform;
RectTransform pt = Selection.activeTransform.parent as RectTransform;
if (t == null || pt == null) return;
if (mirrorAnchors)
{
Vector2 oldAnchorMin = t.anchorMin;
t.anchorMin = new Vector2(1 - t.anchorMax.x, t.anchorMin.y);
t.anchorMax = new Vector2(1 - oldAnchorMin.x, t.anchorMax.y);
}
Vector2 oldOffsetMin = t.offsetMin;
t.offsetMin = new Vector2(-t.offsetMax.x, t.offsetMin.y);
t.offsetMax = new Vector2(-oldOffsetMin.x, t.offsetMax.y);
t.localScale = new Vector3(-t.localScale.x, t.localScale.y, t.localScale.z);
}
}
[MenuItem("uGUI/Mirror Vertically Around Anchors %'")]
static void MirrorVerticallyAnchors()
{
MirrorVertically(false);
}
[MenuItem("uGUI/Mirror Vertically Around Parent Center %\"")]
static void MirrorVerticallyParent()
{
MirrorVertically(true);
}
static void MirrorVertically(bool mirrorAnchors)
{
foreach (Transform transform in Selection.transforms)
{
RectTransform t = transform as RectTransform;
RectTransform pt = Selection.activeTransform.parent as RectTransform;
if (t == null || pt == null) return;
if (mirrorAnchors)
{
Vector2 oldAnchorMin = t.anchorMin;
t.anchorMin = new Vector2(t.anchorMin.x, 1 - t.anchorMax.y);
t.anchorMax = new Vector2(t.anchorMax.x, 1 - oldAnchorMin.y);
}
Vector2 oldOffsetMin = t.offsetMin;
t.offsetMin = new Vector2(t.offsetMin.x, -t.offsetMax.y);
t.offsetMax = new Vector2(t.offsetMax.x, -oldOffsetMin.y);
t.localScale = new Vector3(t.localScale.x, -t.localScale.y, t.localScale.z);
}
}
}
}

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: b896154a8dbdc524092e78923478d27a
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 53b194f66900add419869c57ffbe7b85
timeCreated: 1480025159
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: f0be9e32438568548bd3693bd1b330bc
folderAsset: yes
timeCreated: 1494955283
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: c2b77282ad285f34dacea481a4ec44c4
timeCreated: 1494955300
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,29 +0,0 @@
namespace UnityEngine.UI.Extensions.Examples
{
public class ComboBoxChanged : MonoBehaviour
{
public void ComboBoxChangedEvent(string text)
{
Debug.Log("ComboBox changed [" + text + "]");
}
public void AutoCompleteComboBoxChangedEvent(string text)
{
Debug.Log("AutoCompleteComboBox changed [" + text + "]");
}
public void AutoCompleteComboBoxSelectionChangedEvent(string text, bool valid)
{
Debug.Log("AutoCompleteComboBox selection changed [" + text + "] and its validity was [" + valid + "]");
}
public void DropDownChangedEvent(int newValue)
{
Debug.Log("DropDown changed [" + newValue + "]");
}
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: e4dde8b689b437f468ee7005636aa60c
timeCreated: 1494955552
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: e144d5ae849c2574ebe61b323b01d41d
folderAsset: yes
timeCreated: 1498408611
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,54 +0,0 @@
/// Credit SimonDarksideJ
/// Sourced from my head
namespace UnityEngine.UI.Extensions.Examples
{
[RequireComponent(typeof(Image))]
public class CooldownEffect_Image : MonoBehaviour
{
public CooldownButton cooldown;
public Text displayText;
private Image target;
string originalText;
// Use this for initialization
void Start()
{
if (cooldown == null)
{
Debug.LogError("Missing Cooldown Button assignment");
}
target = GetComponent<Image>();
}
// Update is called once per frame
void Update()
{
target.fillAmount = Mathf.Lerp(0, 1, cooldown.CooldownTimeRemaining / cooldown.CooldownTimeout);
if (displayText)
{
displayText.text = string.Format("{0}%", cooldown.CooldownPercentComplete);
}
}
private void OnDisable()
{
if (displayText)
{
displayText.text = originalText;
}
}
private void OnEnable()
{
if (displayText)
{
originalText = displayText.text;
}
}
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 1ca6e387bb13bff4d90528c055130c44
timeCreated: 1498409243
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,26 +0,0 @@
/// Credit SimonDarksideJ
/// Sourced from my head
namespace UnityEngine.UI.Extensions.Examples
{
[RequireComponent(typeof(SoftMaskScript))]
public class CooldownEffect_SAUIM : MonoBehaviour {
public CooldownButton cooldown;
private SoftMaskScript sauim;
// Use this for initialization
void Start() {
if (cooldown == null)
{
Debug.LogError("Missing Cooldown Button assignment");
}
sauim = GetComponent<SoftMaskScript>();
}
// Update is called once per frame
void Update() {
sauim.CutOff = Mathf.Lerp(0,1, cooldown.CooldownTimeElapsed / cooldown.CooldownTimeout);
}
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: ee97fdcaa3f5e8447a6bebb781fbe830
timeCreated: 1498393575
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 3dc06f5aa2fbb624fbec6c044cbcaa03
timeCreated: 1498408627
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -1,57 +0,0 @@
fileFormatVersion: 2
guid: 53265fa76b3529848a7fb47f0f4a594b
timeCreated: 1447969857
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 4
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 0
mipBias: -1
wrapMode: 0
nPOTScale: 1
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 5
buildTargetSettings: []
spriteSheet:
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -1,57 +0,0 @@
fileFormatVersion: 2
guid: 2b2d3cd4355b13b4699d3f1abf451cf7
timeCreated: 1447970042
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 4
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 0
mipBias: -1
wrapMode: 0
nPOTScale: 1
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 5
buildTargetSettings: []
spriteSheet:
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -1,57 +0,0 @@
fileFormatVersion: 2
guid: be862b17a8fa1544da2abdb50784ccf9
timeCreated: 1447969667
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 4
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 0
mipBias: -1
wrapMode: 0
nPOTScale: 1
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 5
buildTargetSettings: []
spriteSheet:
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -1,57 +0,0 @@
fileFormatVersion: 2
guid: 85b639891c9cfa54998a58964e8ef747
timeCreated: 1447964200
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 4
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 0
mipBias: -1
wrapMode: 0
nPOTScale: 1
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 5
buildTargetSettings: []
spriteSheet:
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: d426546e1b1bdb346a4f1b7ead452375
folderAsset: yes
timeCreated: 1501406849
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 3fcaf2574bec7db4db33947995886a8c
timeCreated: 1501406849
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: e4715bcc5adadca46ac601c64bd58681
folderAsset: yes
timeCreated: 1501610666
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 0e019a51b207adf4dbc65576e8a03ed9
folderAsset: yes
timeCreated: 1501610675
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,706 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 8
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.37311947, g: 0.38074005, b: 0.35872722, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 8
m_Resolution: 2
m_BakeResolution: 40
m_TextureWidth: 1024
m_TextureHeight: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 1
m_BakeBackend: 0
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVRFiltering: 0
m_PVRFilteringMode: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousColorSigma: 1
m_PVRFilteringAtrousNormalSigma: 1
m_PVRFilteringAtrousPositionSigma: 1
m_LightingDataAsset: {fileID: 0}
m_ShadowMaskMode: 2
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &650160435
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 650160439}
- component: {fileID: 650160438}
- component: {fileID: 650160437}
- component: {fileID: 650160436}
- component: {fileID: 650160440}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &650160436
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 650160435}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1301386320, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &650160437
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 650160435}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1980459831, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!223 &650160438
Canvas:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 650160435}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 1
m_Camera: {fileID: 777088607}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 25
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &650160439
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 650160435}
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: 1492537696}
m_Father: {fileID: 0}
m_RootOrder: 1
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!114 &650160440
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 650160435}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 69123a589054bf041ba5ead99364646f, type: 3}
m_Name:
m_EditorClassIdentifier:
scrollView: {fileID: 1492537700}
--- !u!1 &777088603
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 777088608}
- component: {fileID: 777088607}
- component: {fileID: 777088606}
- component: {fileID: 777088605}
- component: {fileID: 777088604}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &777088604
AudioListener:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 777088603}
m_Enabled: 1
--- !u!124 &777088605
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 777088603}
m_Enabled: 1
--- !u!92 &777088606
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 777088603}
m_Enabled: 1
--- !u!20 &777088607
Camera:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 777088603}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
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: 0
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: 1
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!4 &777088608
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 777088603}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, 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!1 &1012097242
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1012097243}
- component: {fileID: 1012097245}
- component: {fileID: 1012097244}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1012097243
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1012097242}
m_LocalRotation: {x: 0.5, y: 0, z: 0, w: 0.8660254}
m_LocalPosition: {x: 0, y: 0, z: 276}
m_LocalScale: {x: 0.3, y: 0.3, z: 1}
m_Children:
- {fileID: 1506879310}
m_Father: {fileID: 1590362722}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 60, y: 0, z: 0}
m_AnchorMin: {x: -0.2, y: 0.5}
m_AnchorMax: {x: -0.2, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 450}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1012097244
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1012097242}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.3019608}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &1012097245
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1012097242}
--- !u!1 &1492537695
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1492537696}
- component: {fileID: 1492537700}
- component: {fileID: 1492537699}
- component: {fileID: 1492537702}
- component: {fileID: 1492537701}
m_Layer: 5
m_Name: ScrollView
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1492537696
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1492537695}
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: 1590362722}
m_Father: {fileID: 650160439}
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!114 &1492537699
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1492537695}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cc9ad31350b1b6348b57c626195a562d, type: 3}
m_Name:
m_EditorClassIdentifier:
viewport: {fileID: 1492537696}
directionOfRecognize: 1
movementType: 1
elasticity: 0.1
scrollSensitivity: 7
inertia: 1
decelerationRate: 0.03
snap:
Enable: 1
VelocityThreshold: 0.5
Duration: 0.3
dataCount: 0
--- !u!114 &1492537700
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1492537695}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c7e0222f92bdad84c9ee57a127efe088, type: 3}
m_Name:
m_EditorClassIdentifier:
cellInterval: 0.15
cellOffset: 0.5
loop: 0
cellBase: {fileID: 1590362721}
scrollPositionController: {fileID: 1492537699}
--- !u!114 &1492537701
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1492537695}
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: 0.392}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 10907, 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
--- !u!222 &1492537702
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1492537695}
--- !u!1 &1506879309
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1506879310}
- component: {fileID: 1506879312}
- component: {fileID: 1506879311}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1506879310
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1506879309}
m_LocalRotation: {x: 0.008726558, y: 0, z: 0, w: 0.999962}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1012097243}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 1, 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: 160, y: 35}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1506879311
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1506879309}
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: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 30
m_FontStyle: 3
m_BestFit: 0
m_MinSize: 3
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text:
--- !u!222 &1506879312
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1506879309}
--- !u!1 &1590362721
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1590362722}
- component: {fileID: 1590362725}
- component: {fileID: 1590362723}
- component: {fileID: 1590362724}
- component: {fileID: 1590362726}
m_Layer: 5
m_Name: Cell
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1590362722
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1590362721}
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: 1012097243}
m_Father: {fileID: 1492537696}
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!95 &1590362723
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1590362721}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 8bbdb068c73989c438aef167096a86cb, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
--- !u!114 &1590362724
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1590362721}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b77a04c729f174c478baf21a47c16620, type: 3}
m_Name:
m_EditorClassIdentifier:
animator: {fileID: 1590362723}
message: {fileID: 1506879311}
--- !u!222 &1590362725
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1590362721}
--- !u!225 &1590362726
CanvasGroup:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1590362721}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 1
m_BlocksRaycasts: 1
m_IgnoreParentGroups: 0
--- !u!1 &1770868449
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1770868452}
- component: {fileID: 1770868451}
- component: {fileID: 1770868450}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1770868450
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1770868449}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1077351063, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &1770868451
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1770868449}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -619905303, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 5
--- !u!4 &1770868452
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1770868449}
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: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: f5666b6c719a9b544ab322e1066aef5f
timeCreated: 1487186707
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 0f8e29708d324ea48ba2af889fea2c5a
folderAsset: yes
timeCreated: 1487186581
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,600 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: 01_Basic_Animation
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: {x: 90, y: 0, z: 0}
inSlope: {x: -198.47397, y: 0, z: 0}
outSlope: {x: -198.47397, y: 0, z: 0}
tangentMode: 0
- serializedVersion: 2
time: 0.5
value: {x: 0, y: 0, z: 0}
inSlope: {x: -180, y: 0, z: 0}
outSlope: {x: -180, y: 0, z: 0}
tangentMode: 0
- serializedVersion: 2
time: 1
value: {x: -90, y: 0, z: 0}
inSlope: {x: -178.53796, y: 0, z: 0}
outSlope: {x: -178.53796, y: 0, z: 0}
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
path: Image
m_PositionCurves: []
m_ScaleCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: {x: 0.3, y: 0.3, z: 1}
inSlope: {x: 0, y: 0, z: 0}
outSlope: {x: 0, y: 0, z: 0}
tangentMode: 0
- serializedVersion: 2
time: 0.5
value: {x: 1, y: 1, z: 1}
inSlope: {x: 0, y: 0, z: 0}
outSlope: {x: 0, y: 0, z: 0}
tangentMode: 0
- serializedVersion: 2
time: 1
value: {x: 0.2, y: 0.2, z: 1}
inSlope: {x: 0, y: 0, z: 0}
outSlope: {x: 0, y: 0, z: 0}
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
path: Image
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: -0.2
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 0.5
value: 0.5
inSlope: 1.4000001
outSlope: 1.4000001
tangentMode: 136
- serializedVersion: 2
time: 1
value: 1.2
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMax.x
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 0.5
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 1
value: 0.5
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMax.y
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: -0.2
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 0.5
value: 0.5
inSlope: 1.4000001
outSlope: 1.4000001
tangentMode: 136
- serializedVersion: 2
time: 1
value: 1.2
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMin.x
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 0.5
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 1
value: 0.5
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMin.y
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 0.5
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Alpha
path:
classID: 225
script: {fileID: 0}
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- path: 83635035
attribute: 4
script: {fileID: 0}
classID: 4
customType: 14
isPPtrCurve: 0
- path: 83635035
attribute: 3
script: {fileID: 0}
classID: 4
customType: 0
isPPtrCurve: 0
- path: 83635035
attribute: 2711263438
script: {fileID: 0}
classID: 224
customType: 0
isPPtrCurve: 0
- path: 83635035
attribute: 2089119715
script: {fileID: 0}
classID: 224
customType: 0
isPPtrCurve: 0
- path: 0
attribute: 1574349066
script: {fileID: 0}
classID: 225
customType: 0
isPPtrCurve: 0
- path: 83635035
attribute: 3600656472
script: {fileID: 0}
classID: 224
customType: 0
isPPtrCurve: 0
- path: 83635035
attribute: 193093493
script: {fileID: 0}
classID: 224
customType: 0
isPPtrCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 1
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: -0.2
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 0.5
value: 0.5
inSlope: 1.4000001
outSlope: 1.4000001
tangentMode: 136
- serializedVersion: 2
time: 1
value: 1.2
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMax.x
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 0.5
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 1
value: 0.5
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMax.y
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: -0.2
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 0.5
value: 0.5
inSlope: 1.4000001
outSlope: 1.4000001
tangentMode: 136
- serializedVersion: 2
time: 1
value: 1.2
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMin.x
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 0.5
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 1
value: 0.5
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMin.y
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 0.3
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 0.5
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 1
value: 0.2
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalScale.x
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 0.3
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 0.5
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 1
value: 0.2
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalScale.y
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 0.5
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalScale.z
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 90
inSlope: -198.47397
outSlope: -198.47397
tangentMode: 0
- serializedVersion: 2
time: 0.5
value: 0
inSlope: -180
outSlope: -180
tangentMode: 136
- serializedVersion: 2
time: 1
value: -90
inSlope: -178.53796
outSlope: -178.53796
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: localEulerAnglesRaw.x
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 0.5
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: localEulerAnglesRaw.y
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 0.5
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: localEulerAnglesRaw.z
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 0.5
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Alpha
path:
classID: 225
script: {fileID: 0}
m_EulerEditorCurves:
- curve:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalEulerAngles.x
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalEulerAngles.y
path: Image
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalEulerAngles.z
path: Image
classID: 224
script: {fileID: 0}
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_GenerateMotionCurves: 0
m_IsEmpty: 0
m_Events: []

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 9e6e4c5500df9dc439749ba892b2995c
timeCreated: 1487186596
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,95 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: 01_Basic_CellScroll
serializedVersion: 5
m_AnimatorParameters:
- m_Name: scroll
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 1
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: 1107904440216339570}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1101 &1101181072344081740
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102900943980948860}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.1
m_TransitionOffset: 0
m_ExitTime: 0.9
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &1102900943980948860
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: scroll
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_Motion: {fileID: 7400000, guid: 9e6e4c5500df9dc439749ba892b2995c, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
--- !u!1107 &1107904440216339570
AnimatorStateMachine:
serializedVersion: 5
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 1102900943980948860}
m_Position: {x: 252, y: 24, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions:
- {fileID: 1101181072344081740}
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 1102900943980948860}

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 8bbdb068c73989c438aef167096a86cb
timeCreated: 1487186612
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,7 +0,0 @@
namespace UnityEngine.UI.Extensions.Examples
{
public class Example01CellDto
{
public string Message;
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: e14503efd7a60d54db0d148e00aa2169
timeCreated: 1487508481
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,19 +0,0 @@
using System.Linq;
namespace UnityEngine.UI.Extensions.Examples
{
public class Example01Scene : MonoBehaviour
{
[SerializeField]
Example01ScrollView scrollView;
void Start()
{
var cellData = Enumerable.Range(0, 20)
.Select(i => new Example01CellDto { Message = "Cell " + i })
.ToList();
scrollView.UpdateData(cellData);
}
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 69123a589054bf041ba5ead99364646f
timeCreated: 1487186233
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,23 +0,0 @@
using System.Collections.Generic;
namespace UnityEngine.UI.Extensions.Examples
{
public class Example01ScrollView : FancyScrollView<Example01CellDto>
{
[SerializeField]
ScrollPositionController scrollPositionController;
new void Awake()
{
base.Awake();
scrollPositionController.OnUpdatePosition.AddListener(UpdatePosition);
}
public void UpdateData(List<Example01CellDto> data)
{
cellData = data;
scrollPositionController.SetDataCount(cellData.Count);
UpdateContents();
}
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: c7e0222f92bdad84c9ee57a127efe088
timeCreated: 1487262733
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,40 +0,0 @@
namespace UnityEngine.UI.Extensions.Examples
{
public class Example01ScrollViewCell : FancyScrollViewCell<Example01CellDto>
{
[SerializeField]
Animator animator;
[SerializeField]
Text message;
readonly int scrollTriggerHash = Animator.StringToHash("scroll");
void Start()
{
var rectTransform = transform as RectTransform;
rectTransform.anchorMax = Vector2.one;
rectTransform.anchorMin = Vector2.zero;
rectTransform.anchoredPosition3D = Vector3.zero;
UpdatePosition(0);
}
/// <summary>
/// セルの内容を更新します
/// </summary>
/// <param name="itemData"></param>
public override void UpdateContent(Example01CellDto itemData)
{
message.text = itemData.Message;
}
/// <summary>
/// セルの位置を更新します
/// </summary>
/// <param name="position"></param>
public override void UpdatePosition(float position)
{
animator.Play(scrollTriggerHash, -1, position);
animator.speed = 0;
}
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: b77a04c729f174c478baf21a47c16620
timeCreated: 1487184978
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 577dcbd98667cbb47ba8c97b564802d2
folderAsset: yes
timeCreated: 1501610675
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,750 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 8
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.37311947, g: 0.38074005, b: 0.35872722, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 8
m_Resolution: 2
m_BakeResolution: 40
m_TextureWidth: 1024
m_TextureHeight: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 1
m_BakeBackend: 0
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVRFiltering: 0
m_PVRFilteringMode: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousColorSigma: 1
m_PVRFilteringAtrousNormalSigma: 1
m_PVRFilteringAtrousPositionSigma: 1
m_LightingDataAsset: {fileID: 0}
m_ShadowMaskMode: 2
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &650160435
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 650160439}
- component: {fileID: 650160438}
- component: {fileID: 650160437}
- component: {fileID: 650160436}
- component: {fileID: 650160440}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &650160436
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 650160435}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1301386320, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &650160437
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 650160435}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1980459831, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!223 &650160438
Canvas:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 650160435}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 1
m_Camera: {fileID: 777088607}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 25
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &650160439
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 650160435}
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: 1492537696}
m_Father: {fileID: 0}
m_RootOrder: 1
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!114 &650160440
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 650160435}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b945ba693af0d824989e76c183a47fb3, type: 3}
m_Name:
m_EditorClassIdentifier:
scrollView: {fileID: 1492537697}
--- !u!1 &777088603
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 777088608}
- component: {fileID: 777088607}
- component: {fileID: 777088606}
- component: {fileID: 777088605}
- component: {fileID: 777088604}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &777088604
AudioListener:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 777088603}
m_Enabled: 1
--- !u!124 &777088605
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 777088603}
m_Enabled: 1
--- !u!92 &777088606
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 777088603}
m_Enabled: 1
--- !u!20 &777088607
Camera:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 777088603}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
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: 0
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: 1
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!4 &777088608
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 777088603}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, 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!1 &1012097242
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1012097243}
- component: {fileID: 1012097245}
- component: {fileID: 1012097244}
- component: {fileID: 1012097246}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1012097243
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1012097242}
m_LocalRotation: {x: 0.5, y: 0, z: 0, w: 0.8660254}
m_LocalPosition: {x: 0, y: 0, z: 276}
m_LocalScale: {x: 0.3, y: 0.3, z: 1}
m_Children:
- {fileID: 1506879310}
m_Father: {fileID: 1590362722}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 60, y: 0, z: 0}
m_AnchorMin: {x: -0.2, y: 0.5}
m_AnchorMax: {x: -0.2, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 450}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1012097244
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1012097242}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, 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_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &1012097245
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1012097242}
--- !u!114 &1012097246
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1012097242}
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: 0
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: 1012097244}
m_OnClick:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!1 &1492537695
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1492537696}
- component: {fileID: 1492537699}
- component: {fileID: 1492537702}
- component: {fileID: 1492537701}
- component: {fileID: 1492537697}
m_Layer: 5
m_Name: ScrollView
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1492537696
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1492537695}
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: 1590362722}
m_Father: {fileID: 650160439}
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!114 &1492537697
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1492537695}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5b1ee62a075132e49b6fc82cd114e89d, type: 3}
m_Name:
m_EditorClassIdentifier:
cellInterval: 0.15
cellOffset: 0.5
loop: 0
cellBase: {fileID: 1590362721}
scrollPositionController: {fileID: 1492537699}
--- !u!114 &1492537699
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1492537695}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cc9ad31350b1b6348b57c626195a562d, type: 3}
m_Name:
m_EditorClassIdentifier:
viewport: {fileID: 1492537696}
directionOfRecognize: 1
movementType: 1
elasticity: 0.1
scrollSensitivity: 7
inertia: 1
decelerationRate: 0.03
snap:
Enable: 1
VelocityThreshold: 0.5
Duration: 0.3
dataCount: 0
--- !u!114 &1492537701
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1492537695}
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: 0.392}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 10907, 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
--- !u!222 &1492537702
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1492537695}
--- !u!1 &1506879309
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1506879310}
- component: {fileID: 1506879312}
- component: {fileID: 1506879311}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1506879310
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1506879309}
m_LocalRotation: {x: 0.008726558, y: 0, z: 0, w: 0.999962}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1012097243}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 1, 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: 160, y: 35}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1506879311
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1506879309}
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: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 30
m_FontStyle: 3
m_BestFit: 0
m_MinSize: 3
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text:
--- !u!222 &1506879312
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1506879309}
--- !u!1 &1590362721
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1590362722}
- component: {fileID: 1590362725}
- component: {fileID: 1590362723}
- component: {fileID: 1590362724}
- component: {fileID: 1590362726}
m_Layer: 5
m_Name: Cell
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1590362722
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1590362721}
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: 1012097243}
m_Father: {fileID: 1492537696}
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!95 &1590362723
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1590362721}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 8bbdb068c73989c438aef167096a86cb, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
--- !u!114 &1590362724
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1590362721}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9409f360a0deeb949a3635126edf8000, type: 3}
m_Name:
m_EditorClassIdentifier:
animator: {fileID: 1590362723}
message: {fileID: 1506879311}
image: {fileID: 1012097244}
button: {fileID: 1012097246}
--- !u!222 &1590362725
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1590362721}
--- !u!225 &1590362726
CanvasGroup:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1590362721}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 1
m_BlocksRaycasts: 1
m_IgnoreParentGroups: 0
--- !u!1 &1770868449
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1770868452}
- component: {fileID: 1770868451}
- component: {fileID: 1770868450}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1770868450
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1770868449}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1077351063, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &1770868451
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1770868449}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -619905303, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 5
--- !u!4 &1770868452
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1770868449}
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: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 22d1be941599faf45b04ab4c6a2def09
timeCreated: 1487505810
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,7 +0,0 @@
namespace UnityEngine.UI.Extensions.Examples
{
public class Example02CellDto
{
public string Message;
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: cf9eb20bd16f1aa448580b085861a75b
timeCreated: 1487505929
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,19 +0,0 @@
using System.Linq;
namespace UnityEngine.UI.Extensions.Examples
{
public class Example02Scene : MonoBehaviour
{
[SerializeField]
Example02ScrollView scrollView;
void Start()
{
var cellData = Enumerable.Range(0, 20)
.Select(i => new Example02CellDto { Message = "Cell " + i })
.ToList();
scrollView.UpdateData(cellData);
}
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: b945ba693af0d824989e76c183a47fb3
timeCreated: 1487506430
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,42 +0,0 @@
using System.Collections.Generic;
namespace UnityEngine.UI.Extensions.Examples
{
public class Example02ScrollView : FancyScrollView<Example02CellDto, Example02ScrollViewContext>
{
[SerializeField]
ScrollPositionController scrollPositionController;
new void Awake()
{
scrollPositionController.OnUpdatePosition.AddListener(UpdatePosition);
// Add OnItemSelected event listener
scrollPositionController.OnItemSelected.AddListener(CellSelected);
SetContext(new Example02ScrollViewContext { OnPressedCell = OnPressedCell });
base.Awake();
}
public void UpdateData(List<Example02CellDto> data)
{
cellData = data;
scrollPositionController.SetDataCount(cellData.Count);
UpdateContents();
}
void OnPressedCell(Example02ScrollViewCell cell)
{
scrollPositionController.ScrollTo(cell.DataIndex, 0.4f);
context.SelectedIndex = cell.DataIndex;
UpdateContents();
}
// An event triggered when a cell is selected.
void CellSelected(int cellIndex)
{
// Update context.SelectedIndex and call UpdateContents for updating cell's content.
context.SelectedIndex = cellIndex;
UpdateContents();
}
}
}

View file

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 5b1ee62a075132e49b6fc82cd114e89d
timeCreated: 1487505830
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show more