Skip to content

Instantly share code, notes, and snippets.

View HassakuTb's full-sized avatar
💭
🍊

Hassaku HassakuTb

💭
🍊
View GitHub Profile
@HassakuTb
HassakuTb / Screenshot.cs
Last active June 28, 2016 02:42
Screenshot extension for Unity Editor
/**
Screenshot.cs
Copyright (c) 2016 Hassaku
This software is released under the MIT License.
http://opensource.org/licenses/mit-license.php
*/
using UnityEngine;
using UnityEditor;
/**
SequenceScreenshot.cs
Copyright (c) 2016 Hassaku
This software is released under the MIT License.
http://opensource.org/licenses/mit-license.php
*/
using UnityEngine;
using UnityEditor;
using UnityEngine;
[CreateAssetMenu(menuName = "ScriptableObject/Enemy", fileName = "NewEnemy")]
public class Enemy : ScriptableObject{
public string Name;
public int Hp;
public int Power;
using UnityEngine;
[CreateAssetMenu(menuName = "ScriptableObject/SubEnemy", fileName = "NewSubEnemy")]
public class SubEnemy : Enemy{
private int damageCount = 0;
public override void Damage(int damageValue){
base.Damage(damageValue);
++ damageCount;
using UnityEngine;
[CreateAssetMenu(menuName = "ScriptableObject/Enemy", fileName = "NewEnemy")]
public class Enemy : ScriptableObject{
public string Name;
public int HpMax;
public int Power;
using UnityEngine;
public abstract class ScriptableObjectInstancePresenter<T> : MonoBehaviour where T : ScriptableObject{
public T m_model;
protected T model { get; set; }
protected void Awake() {
model = ScriptableObject.Instantiate<T>(m_model);
}
public class EnemyPresenter : ScriptableObjectInstancePresenter<Enemy> {
//...
}
[InitializeOnLoadMethod]
public static void RefreshItemAssetPath() {
EditorApplication.projectWindowChanged += () => {
foreach (string guid in AssetDatabase.FindAssets("t:Item")) {
string path = AssetDatabase.GUIDToAssetPath(guid);
Item item = AssetDatabase.LoadAssetAtPath<Item>(path);
Match match = new Regex(@"Assets\/Resources\/(?<resource_path>.*)\.asset").Match(path);
if (!match.Success) {
Debug.Log("Cannot extract resource Path. : " + path);
/**
EnumLabel.cs
Copyright (c) 2016 Hassaku
This software is released under the MIT License.
http://opensource.org/licenses/mit-license.php
*/
using UnityEngine;
using UnityEngine.Assertions;
using System;
using UnityEngine;
public class EnumLabelSample : MonoBehaviour{
[EnumLabel(typeof(Fruit))]
public string[] names = new string[Enum.GetValues(typeof(Fruit)).Length];
private enum Fruit {
Orange,