コード例 #1
0
        private static object Read(BinaryReader reader, System.TypeCode typeCode)
        {
            switch (typeCode)
            {
            case System.TypeCode.Empty:
                return(null);

            case System.TypeCode.String:
                return(reader.ReadString());

            case System.TypeCode.Boolean:
                return(reader.ReadBoolean());

            case System.TypeCode.Byte:
                return(reader.ReadByte());

            case System.TypeCode.Decimal:
                return(reader.ReadDecimal());

            case System.TypeCode.Double:
                return(reader.ReadDouble());

            case System.TypeCode.Int16:
                return(reader.ReadInt16());

            case System.TypeCode.Int32:
                return(reader.ReadInt32());

            case System.TypeCode.Int64:
                return(reader.ReadInt64());

            case System.TypeCode.Single:
                return(reader.ReadSingle());

            default:
                Debug.Fail("Unexpected type code read from binary: " + typeCode.ToString());
                return(null);
            }
        }
コード例 #2
0
    private void Edit_Int_Param <T>(ref Dictionary <TRANS_PARAM_ID, T> dic, ref bool isShow, ref TRANS_PARAM_ID param_id)
    {
        System.TypeCode typecode = System.Type.GetTypeCode(typeof(T));

        EditorGUILayout.BeginHorizontal("box");

        if (GUILayout.Button(isShow ? "-":"+", GUILayout.Width(50)))
        {
            isShow = !isShow;
        }

        if (dic != null)
        {
            GUILayout.Label(typecode.ToString() + " Param (" + dic.Count + ")");
        }

        EditorGUILayout.EndHorizontal();

        if (!isShow)
        {
            return;
        }

        EditorGUILayout.BeginHorizontal();

        param_id = (TRANS_PARAM_ID)EditorGUILayout.EnumPopup(param_id, GUILayout.Width(250));
        if (GUILayout.Button("추가", GUILayout.Width(50)))
        {
            switch (typecode)
            {
            case System.TypeCode.Int32:
                curFSM.AddParamInt(param_id);
                break;

            case System.TypeCode.Single:
                curFSM.AddParamFloat(param_id);
                break;

            case System.TypeCode.Boolean:
                curFSM.AddParamBool(param_id);
                break;
            }
        }

        EditorGUILayout.EndHorizontal();

        //int 파라메터 키/초기화값
        if (dic != null)
        {
            TRANS_PARAM_ID[] keys = new TRANS_PARAM_ID[dic.Count];
            dic.Keys.CopyTo(keys, 0);

            foreach (TRANS_PARAM_ID key in keys)
            {
                EditorGUILayout.BeginHorizontal();

                GUILayout.Label(key.ToString(), GUILayout.Width(250));
                switch (typecode)
                {
                case System.TypeCode.Int32:
                    dic[key] = (T)(object)EditorGUILayout.IntField((int)(object)dic[key], GUILayout.Width(100));
                    break;

                case System.TypeCode.Single:
                    dic[key] = (T)(object)EditorGUILayout.FloatField((float)(object)dic[key], GUILayout.Width(100));
                    break;

                case System.TypeCode.Boolean:
                    dic[key] = (T)(object)EditorGUILayout.Toggle((bool)(object)dic[key], GUILayout.Width(100));
                    break;
                }

                if (GUILayout.Button("삭제", GUILayout.Width(50)))
                {
                    dic.Remove(key);
                }

                EditorGUILayout.EndHorizontal();
            }
        }
    }