예제 #1
0
        public void ComplicateCollectionをモデルに書きこむことができる()
        {
            var model = new ComplicateCollectionProperty(typeof(Hoge[]), new PropertyFactory());
            var value = new Hoge[]
            {
                new Hoge {
                    X = 91
                },
                new Hoge {
                    X = 82
                },
                new Hoge {
                    X = 73
                },
            };

            Load(model, value);

            var hoge0 = model.Collection[0].Value.Value.IsInstanceOf <Hoge>();

            hoge0.X.Is(91);
            var hoge1 = model.Collection[1].Value.Value.IsInstanceOf <Hoge>();

            hoge1.X.Is(82);
            var hoge2 = model.Collection[2].Value.Value.IsInstanceOf <Hoge>();

            hoge2.X.Is(73);
        }
예제 #2
0
    public override void OnInspectorGUI()
    {
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        foldPiyo = CustomUI.Foldout("Piyo", foldPiyo);
        if (foldPiyo)
        {
            Hoge hoge = (Hoge)target;

            hoge.piyo = EditorGUILayout.Toggle("piyo", hoge.piyo);
            hoge.qiyo = EditorGUILayout.IntField("qiyo", hoge.qiyo);
            hoge.riyo = EditorGUILayout.TextField("riyo", hoge.riyo);
        }

        EditorGUILayout.Space();

        foldFuga = CustomUI.Foldout("Fuga", foldFuga);
        if (foldFuga)
        {
            Hoge hoge = (Hoge)target;

            hoge.fuga = EditorGUILayout.Toggle("fuga", hoge.fuga);
            hoge.guga = EditorGUILayout.IntField("guga", hoge.guga);
            hoge.huga = EditorGUILayout.TextField("huga", hoge.huga);
        }

        EditorGUILayout.Space();
    }
예제 #3
0
    private void Export()
    {
        Hoge a_hoge = AssetDatabase.LoadAssetAtPath <Hoge>(ASSET_PATH);

        if (a_hoge == null)
        {
            a_hoge = ScriptableObject.CreateInstance <Hoge>();
        }

        if (!AssetDatabase.Contains(a_hoge as UnityEngine.Object))
        {
            string directory = Path.GetDirectoryName(ASSET_PATH);

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            AssetDatabase.CreateAsset(a_hoge, ASSET_PATH);
        }

        EditorUtility.CopySerialized(m_hoge, a_hoge);

        a_hoge.hideFlags = HideFlags.NotEditable;

        EditorUtility.SetDirty(a_hoge);

        AssetDatabase.SaveAssets();

        AssetDatabase.Refresh();
    }
예제 #4
0
        public void SerializeTest()
        {
            // []
            {
                var dictionary = new SampleDictionary();
                dictionary["key"] = new Hoge(1, "user1");
                Assert.AreEqual("{\"keys\":[\"key\"],\"values\":[{\"Id\":1,\"Name\":\"user1\"}]}", JsonUtility.ToJson(dictionary));
            }

            // Add
            {
                var dictionary = new SampleDictionary();
                dictionary.Add("key", new Hoge(1, "user1"));
                Assert.AreEqual("{\"keys\":[\"key\"],\"values\":[{\"Id\":1,\"Name\":\"user1\"}]}", JsonUtility.ToJson(dictionary));
            }

            // Add
            {
                var dictionary = new SampleDictionary();
                dictionary.Add(new KeyValuePair <string, Hoge>("key", new Hoge(1, "user1")));
                Assert.AreEqual("{\"keys\":[\"key\"],\"values\":[{\"Id\":1,\"Name\":\"user1\"}]}", JsonUtility.ToJson(dictionary));
            }

            // Clear
            {
                var dictionary = new SampleDictionary();
                dictionary.Add("key", new Hoge(1, "user1"));
                Assert.AreEqual("{\"keys\":[\"key\"],\"values\":[{\"Id\":1,\"Name\":\"user1\"}]}", JsonUtility.ToJson(dictionary));
            }

            // Remove
            {
                var dictionary = new SampleDictionary();
                var entity     = new Hoge(1, "user1");
                dictionary.Add("key", entity);
                dictionary.Remove(new KeyValuePair <string, Hoge>("key", entity));
                Assert.AreEqual("{\"keys\":[],\"values\":[]}", JsonUtility.ToJson(dictionary));
            }

            // new
            {
                var dictionary = new SampleDictionary(
                    new Dictionary <string, Hoge> {
                    {
                        "key1", new Hoge(1, "user1")
                    }, {
                        "key2", new Hoge(2, "user2")
                    }
                });

                Assert.AreEqual(
                    "{" +
                    "\"keys\":[\"key1\",\"key2\"]," +
                    "\"values\":[{\"Id\":1,\"Name\":\"user1\"},{\"Id\":2,\"Name\":\"user2\"}]" +
                    "}",
                    JsonUtility.ToJson(dictionary)
                    );
            }
        }
    private void Start()
    {
        m_hoge = ScriptableObject.Instantiate(Resources.Load <Hoge>("Hoge"));

#if HOGE
        Debug.Log(m_hoge.IntValue);
#endif
    }
예제 #6
0
            public override bool Equals(object value)
            {
                Hoge entity = value as Hoge;

                return((entity != null) &&
                       (this.Id == entity.Id) &&
                       (this.Name == entity.Name)
                       );
            }
예제 #7
0
 public void OnEnable()
 {
     hoge = target as Hoge;
     hashKey = new List<string>();
     hashValue = new List<string>();
     //defaultKey = new List<string>();
     //defaultValue = new List<string>();
     hoge.dict = new Dictionary<string, string>();
 }
예제 #8
0
 private void Test<T>(T t, ref T dest) where T : ScriptableObject
 {
     if (t == null) return;
     var result = UnityObjectSerializer.Serializer.Serialize(t);
     var json = Encoding.UTF8.GetString(result);
     var h = UnityObjectSerializer.Serializer.Deserialize<T>(result);
     Debug.Log(json);
     dest = h;
 }
예제 #9
0
    public IEnumerator Coroutine()
    {
        Debug.Log("Coroutine START!!");
        Hoge hoge = new Hoge();

        yield return(hoge);

        Debug.Log("Coroutine END!!");
    }
예제 #10
0
    public void Test1()
    {
        var hoge = new Hoge()
        {
            Name = "hoge",
        };

        Assert.Equal("hoge", hoge.Name);
    }
예제 #11
0
    private void Import()
    {
        if (m_hoge == null)
        {
            m_hoge = ScriptableObject.CreateInstance <Hoge>();
        }

        Hoge a_hoge = AssetDatabase.LoadAssetAtPath <Hoge>(ASSET_PATH);

        if (a_hoge == null)
        {
            return;
        }

        EditorUtility.CopySerialized(a_hoge, m_hoge);
    }
예제 #12
0
        public void Test(int index, string expected)
        {
            var hoge = new Hoge
            {
                A = "A",
                B = new Foo
                {
                    C = "B-C",
                    D = "B-D",
                }
            };

            var actual = PropertyAccessor.GetLambda <Hoge, string>().ElementAt(index);
            var func   = actual.Compile();

            Assert.AreEqual(expected, func(hoge), actual.ToString());
        }
예제 #13
0
        public BatteryPage()
        {
            InitializeComponent();
            SetDisplay(Battery.ChargeLevel,
                       Battery.State == BatteryState.Charging);
            var level  = Battery.ChargeLevel;
            var level2 = Battery.ChargeLevel * 100;

            //Create hoge object
            this.hoge = new Hoge();
            //hoge.PackageName = DependencyService.Get<IAssemblyService>().GetPackageName();
            //hoge.VersionName = DependencyService.Get<IAssemblyService>().GetVersionName();
            //hoge.VersionCode = DependencyService.Get<IAssemblyService>().GetVersionCode().ToString();
            hoge.PercenTage                  = level.ToString();
            hoge.Progress                    = level2.ToString() + "%";
            this.Label5.BindingContext       = hoge;
            this.progressRing.BindingContext = hoge;
            this.Label6.BindingContext       = hoge;
            //Label6.Text = status;
        }
예제 #14
0
        public void Classをモデルに読み込むことができる()
        {
            var classModel = new ClassProperty(typeof(Hoge), new PropertyFactory());
            var value      = new Hoge
            {
                X = 101,
                Y = 0.25f,
                Z = DayOfWeek.Saturday,
                W = -1
            };

            Load(classModel, value);

            var result = classModel.Value.Value as Hoge;

            result.X.Is(101);
            result.Y.Is(0.25f);
            result.Z.Is(DayOfWeek.Saturday);
            result.W.Is(0);
        }
예제 #15
0
        public void MAtomic_MAtomicTest()
        {
            var hoge = new Hoge();

            Task.Run(() =>
            {
                Thread.Sleep(10);
                hoge.Value = "atomic!";
            });

            Assert.AreEqual(0, hoge.Status);


            while (hoge.Status == 0)
            {
                Thread.Sleep(1);
            }

            Assert.AreEqual(1, hoge.Status);
            Assert.AreEqual("atomic!", hoge.Value);
        }
예제 #16
0
파일: Game1.cs 프로젝트: play3577/Mjai3D
        public Game1()
        {
            Hoge.Moja("huga");

            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            IsMouseVisible        = true;

            mutex = new object();

            components = new List <Component>();
            majong     = new MajongComponent();
            components.Add(majong);

            fpsCounter = new FpsCounter();

            tehaiObjects       = new List <Pai3D>();
            actionAlternatives = new List <SelectionType>();
            selectionBoxes     = new List <Rectangle>();

            graphics.PreferredBackBufferWidth  = 1024;
            graphics.PreferredBackBufferHeight = 768;
        }
예제 #17
0
 public void Init(Foo foo, Bar bar, Hoge hoge)
 {
     Debug.Log("Sample009 Init");
 }
예제 #18
0
        public static void Main(string[] args)
        {
            long N = rl;
            long S = rl;

            long[] A = rla;

            long S_MAX = 3000;

            Hoge[,] dp = new Hoge[N + 1, S_MAX + 1];
            for (int i = 0; i <= N; i++)
            {
                dp[i, 0]         = new Hoge();
                dp[i, 0].Data[0] = 1;
            }

            for (int i = 1; i <= N; i++)
            {
                for (int j = (int)S; 1 <= j; j--)
                {
                    dp[i, j]         = new Hoge();
                    dp[i, j].Left    = dp[i - 1, j];
                    dp[i, j].LeftTop = (0 <= j - A[i - 1]) ? dp[i - 1, j - A[i - 1]] : null;
                }
            }

            Action <Hoge> rec = null;

            rec = (hoge) =>
            {
                if (hoge.HasMerged)
                {
                    return;
                }

                if (hoge?.Left != null)
                {
                    rec(hoge.Left);
                    // why?
                    // hoge.Data = hoge.Left.Data;
                    //hoge.Left.Data.CopyTo(hoge.Data,0);
                }

                if (hoge?.LeftTop != null)
                {
                    rec(hoge.LeftTop);
                    for (int i = hoge.LeftTop.Data.Length - 1; 0 < i; i--)
                    {
                        hoge.Data[i] += hoge.LeftTop.Data[i - 1];
                    }
                }

                hoge.HasMerged = true;
            };

            Mint ans = 0;

            if (dp[N, S] != null)
            {
                rec(dp[N, S]);
                for (int i = 1; i < dp[N, S].Data.Length; i++)
                {
                    if (dp[N, S].Data[i] == 0)
                    {
                        continue;
                    }
                    ans += Mint.Pow(2, N - i) * dp[N, S].Data[i];
                }
            }

            Console.WriteLine(ans);
        }
예제 #19
0
    // Use this for initialization
    void Start()
    {
        // そもそも使える型は?
        {
            Debug.Log("### 基本データ型");

            byte   by  = 0;
            sbyte  sby = 0;
            int    i   = 0;
            uint   ui  = 255;
            short  s   = 0;
            ushort us  = 0;
            long   l   = 0;
            ulong  ul  = 0;
            float  f   = 0.0f;
            double d   = 0.0;
            char   c   = 'a';
            bool   b   = true;
            //object
            string str = "aaa";

            Debug.Log("  byte:" + by);
            Debug.Log("  sbyte:" + sby);
            Debug.Log("  int:" + i);
            Debug.Log("  uint:" + ui);
            Debug.Log("  short:" + s);
            Debug.Log("  ushort:" + us);
            Debug.Log("  long:" + l);
            Debug.Log("  ulong:" + ul);
            Debug.Log("  float:" + f);
            Debug.Log("  double:" + d);
            Debug.Log("  char:" + c);
            Debug.Log("  bool:" + b);
            Debug.Log("  string:" + str);

            // 書式指定での出力.
            Debug.Log("### format output.");

            Debug.Log(string.Format("  uint:{0}", ui));
            Debug.Log(string.Format("  uint:0x{0:x}", ui));                 // 16進表示.
            Debug.Log(string.Format("  uint:0x{0:X}", ui));                 // 16進表示(大文字).

            Debug.LogFormat("  uint:0x{0:x}", ui);
            Debug.LogFormat("  int:[{0}] uint:[{1}]", i, ui);
            Debug.LogFormat("  uint:[{1}] int:[{0}]", i, ui);

            // ConsoleでASSERTの表示にはなるが実行自体は止まらない.
            Debug.LogAssertion("### assert!!.");

            // Errorも一緒で止まらない.
            Debug.LogError("### error!!.");

            Debug.Log("### check:0");

#if _ENABLE_HOGE
            Debug.Log("### #if _ENABLE_HOGE");
#endif

//#if defined(_ENABLE_HOGE)
            //Debug.Log("### #if defined(_ENABLE_HOGE)");
//#endif
        }

        // 配列.
        {
            // ↓NG
            // C,C++の様な書き方はダメ.
            //int array[10];

            int[] array = new int[10];

            array[0] = 1;

            Debug.Log("### Array.");

            for (int i = 0; i < array.Length; i++)
            {
                Debug.LogFormat("  [{0}]:{1}", i, array[i]);
            }
        }

        {
            int[] array = new int[10] {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };

            // foreachの書き方.
            foreach (int v in array)
            {
                Debug.LogFormat("  {0}", v);
            }
        }

        {
            int[] array = new int[] { 10, 20, 30, 40, 50 };

            // auto変数みたいにvarだと型を明示的に指定する必要が無い?.
            foreach (var v in array)
            {
                Debug.LogFormat("  {0}", v);
            }
        }

        {
            float[] array = new float[] { 1.5f, 2.5f, 3.5f, 4.5f, 5.5f };

            foreach (var v in array)
            {
                Debug.LogFormat("  {0}", v);
            }
        }

        // 可変長配列.
        {
            Debug.Log("### List<int>");

            List <int> list = new List <int>();

            // 追加.
            list.Add(10);
            list.Add(20);
            list.Add(30);
            list.Add(40);

            Debug.LogFormat("  count:[{0}]", list.Count);

            // 配列の様にアクセスできるみたい.
            for (int i = 0; i < list.Count; i++)
            {
                Debug.LogFormat("  [{0}]:[{1}]", i, list[i]);
            }

            // 挿入.
            list.Insert(2, 100);

            Debug.LogFormat("  count:[{0}]", list.Count);

            foreach (var v in list)
            {
                Debug.LogFormat("  [{0}]", v);
            }

            // ソート.
            Debug.Log("### sort.");

            list.Sort();

            foreach (var v in list)
            {
                Debug.LogFormat("  [{0}]", v);
            }

            // 降順にソート.
            // ラムダ式.
            list.Sort((a, b) => b - a);

            foreach (var v in list)
            {
                Debug.LogFormat("  [{0}]", v);
            }
        }

        {
            Debug.Log("### List<float>");

            List <float> list = new List <float>();

            list.Add(2.5f);
            list.Add(2.6f);
            list.Add(2.7f);
            list.Add(4.5f);
            list.Add(6.5f);
            list.Add(8.5f);

            list.Insert(2, 10.5f);

            foreach (var v in list)
            {
                Debug.LogFormat("  [{0}]", v);
            }

            list.Sort();
            list.Reverse();

            Debug.Log("##");

            //list.Sort((a, b) => { return a < b ? 1 : (b > a ? -1 : 0); });
            //list.Sort((a, b) => (int)(b - a));

            foreach (var v in list)
            {
                Debug.LogFormat("  [{0}]", v);
            }
        }

        // 連想配列.
        {
            Debug.Log("### Dictionary<int, string>");

            Dictionary <int, string> dic = new Dictionary <int, string>();

            dic.Add(1, "Hoge1");
            dic.Add(2, "Hoge2");

            dic[3] = "Hoge3";

            Debug.LogFormat("  val:[{0}]", dic[1]);

            // キーの列挙.
            foreach (var key in dic.Keys)
            {
                Debug.LogFormat("  key:[{0}]", key);
            }

            // 要素の列挙.
            foreach (var val in dic.Values)
            {
                Debug.LogFormat("  val:[{0}]", val);
            }

            // キーと要素の列挙.
            foreach (KeyValuePair <int, string> pair in dic)
            {
                Debug.LogFormat("  [{0}] : [{1}]", pair.Key, pair.Value);
            }
        }

        // ジェネリック.
        {
            GenericClass <int> i = new GenericClass <int>();

            i.SetItem(5);

            Debug.LogFormat("  i:[{0}]", i.GetItem());

            GenericClass <float> f = new GenericClass <float>();

            f.SetItem(10.0f);

            Debug.LogFormat("  f:[{0}]", f.GetItem());
        }

        // enum
        {
            Debug.Log("### enum");

            Debug.LogFormat("  AttackAttr Grapple:[0x{0:x}]", AttackAttr.Grapple);
            Debug.LogFormat("  AttackAttr Shoot  :[0x{0:x}]", AttackAttr.Shoot);

            Debug.LogFormat("  ElementAttr Fire   : [0x{0:x}]", ElementAttr.Fire);
            Debug.LogFormat("  ElementAttr Warter : [0x{0:x}]", ElementAttr.Water);

            Debug.LogFormat("  PhysicsAttackAttr Slash : [{0:d}]", GameConst.PhysicsAttackAttr.Slash);
            Debug.LogFormat("  PhysicsAttackAttr Blow  : [{0:d}]", GameConst.PhysicsAttackAttr.Blow);
            Debug.LogFormat("  PhysicsAttackAttr Spear : [{0:d}]", GameConst.PhysicsAttackAttr.Spear);
        }

        // if
        {
            int i = 0;

            // ↓NG
            // 数値ではエラーになる.
            //if (i)
            //{
            //Debug.Log("### check:0");
            //}

            // ↓OK
            if (i == 0)
            {
                Debug.Log("### check:0");
            }

            // ビット演算だと判定が冗長になってしまう...
            ElementAttr attr = ElementAttr.None;

            attr = ElementAttr.Fire;

            // ↓NG
            // ビット演算ではboolにならない.
            //if(attr & ElementAttr.Fire)
            //{
            //}

            // ↓OK
            if ((attr & ElementAttr.Fire) == ElementAttr.Fire)
            {
                Debug.Log("### 火属性.");
            }

            attr = ElementAttr.Water | ElementAttr.Light;

            if ((attr & ElementAttr.Water) == ElementAttr.Water)
            {
                Debug.Log("### 水属性.");
            }

            if ((attr & (ElementAttr.Water | ElementAttr.Light)) == (ElementAttr.Water | ElementAttr.Light))
            {
                Debug.Log("### 水&光属性.");
            }

            // 良いかどうかは置いておいて次の様な書き方でも判定できる.
            if ((attr & (ElementAttr.Water | ElementAttr.Light)) != 0)
            {
                Debug.Log("### 水&光属性.");
            }
        }

        // クラス.
        {
            Hoge hoge = new Hoge();

            hoge.SetY(10);

            Debug.LogFormat("  x:[{0}]", hoge.x);
            Debug.LogFormat("  z:[{0}]", hoge.GetY());

            // プロパティ.
            hoge.X = 100;

            Debug.LogFormat("  X:[{0}]", hoge.X);

            // エラーが拾える.
            hoge.Z = 100;

            Debug.LogFormat("  Z:[{0}]", hoge.Z);

            hoge.Z = 10;

            Debug.LogFormat("  Z:[{0}]", hoge.Z);
        }

        // 構造体.
        {
            Point point = new Point(10, 20);

            Debug.LogFormat("  x:[{0}] y:[{1}]", point.x, point.y);
        }

        // キャスト.
        {
            int   i = 10;
            float f = 100.0f;

            f = i;

            // ↓コンパイルエラーになる.
            //i = f;

            // ↓明示的なキャストが必要.
            i = (int)f;
        }

        {
            D d = new D();

            B b = d;                // キャストは不要.
        }

        {
            E e = new E();

            I1 i1 = e;              // キャストは不要.
            I2 i2 = e;              // キャストは不要.
        }

        {
            B b = new D();

            D d = (D)b;                         // 明示的なキャストが必要.
        }

        {
            A a = new A();

            //B b = (B)a;
        }

        // as演算子.
        {
            A a = new A();

            B b = (object)a as B;

            if (b == null)
            {
                Debug.LogFormat("### can not change A -> B.");
            }
        }

        {
            I1 i1 = new E();
            I2 i2 = i1 as I2;
            E  e  = i2 as E;
        }

        // 拡張メソッド.
        {
            string str;

            str = "aaa";

            str.ExtMethod();
        }
    }
예제 #20
0
 static void Main(string[] args)
 {
     object x = null;
     Hoge   y = (Hoge)x;
 }
예제 #21
0
        public void TestName()
        {
            var hoge = new Hoge();

            Assert.Equal(hoge.GetName(), "hoge");
        }
예제 #22
0
        static void Main(string[] args)
        {
            var hoge = new Hoge();

            Console.WriteLine("Hello World!");
        }
예제 #23
0
 public Fuga(Hoge hoge)
 {
 }
예제 #24
0
 public Fuga(Hoge hoge)
 {
 }
 public void Start()
 {
     h = new Hoge();
     h.oh = Camera.main.gameObject;
 }
 public void Start()
 {
     h    = new Hoge();
     h.oh = Camera.main.gameObject;
 }
예제 #27
0
 static void Main()
 {
     IList <int>         x    = new List <int> ();
     Hoge <IList <int> > hoge = x;
 }
예제 #28
0
 public ActionResult <string> Post(Hoge value)
 {
     return(value.Foo);
 }