コード例 #1
0
    private void OnGUI()
    {
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
        object NullObj = null;

        DataInspectorUtility.inspect(ref NullObj, typeof(AssetBundleLoader), "Resources");
        EditorGUILayout.EndScrollView();
    }
コード例 #2
0
    private void OnGUI()
    {
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
        object obj = UF.Managers.GameSaveManager.Instance;

        DataInspectorUtility.inspect(ref obj, typeof(UF.Managers.GameSaveManager), "GameSave");
        EditorGUILayout.EndScrollView();
    }
コード例 #3
0
    private void OnGUI()
    {
        //static config inspector
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
        object obj = UF.Managers.ConfigManager.Instance;

        DataInspectorUtility.inspect(ref obj, typeof(UF.Managers.ConfigManager), "Config");
        EditorGUILayout.EndScrollView();
    }
コード例 #4
0
    public override bool inspect(ref object data, Type type, string name, string path)
    {
        bool changed    = false;
        var  fields     = TypeUtility.GetClassFieldInfo(type);
        var  properties = TypeUtility.GetClassPropertyInfo(type);

        if (fields.Count == 0 && properties.Count == 0)
        {
            return(changed);
        }
        //inspect the fields
        SortedDictionary <string, FieldInfo> fieldDict = new SortedDictionary <string, FieldInfo>();

        foreach (var fieldinfo in fields)
        {
            string fieldname = fieldinfo.Name;
            fieldDict.Add(fieldname, fieldinfo);
        }
        foreach (var keyvalue in fieldDict)
        {
            object value = keyvalue.Value.GetValue(data);
            if (value == null)
            {
                continue;
            }
            Type valueType = value.GetType();
            if (DataInspectorUtility.inspect(ref value, valueType, keyvalue.Key, path))
            {
                keyvalue.Value.SetValue(data, value);
                changed = true;
            }
        }
        foreach (var propertyInfo in properties)
        {
            object value = propertyInfo.GetValue(data, null);
            if (value == null)
            {
                continue;
            }
            Type valueType = value.GetType();
            if (DataInspectorUtility.inspect(ref value, valueType, propertyInfo.Name, path))
            {
                propertyInfo.SetValue(data, value, null);
                changed = true;
            }
        }
        return(changed);
    }
コード例 #5
0
    public override bool inspect(ref object data, Type type, string name, string path)
    {
        var fields = ClassFieldFilter.GetClassFieldInfo(type);
        //inspect the fields
        bool changed = false;

        foreach (var fieldinfo in fields)
        {
            object value     = fieldinfo.GetValue(data);
            Type   valueType = value != null?value.GetType() : fieldinfo.FieldType;

            if (DataInspectorUtility.inspect(ref value, valueType, fieldinfo.Name, path))
            {
                fieldinfo.SetValue(data, value);
                changed = true;
            }
        }
        return(changed);
    }
コード例 #6
0
    public override bool inspect(ref object data, Type type, string name, string path)
    {
        if (data == null)
        {
            return(false);
        }
        var array = data as Array;

        var  valueType = type.GetElementType();
        bool changed   = false;

        for (int i = 0; i < array.Length; ++i)
        {
            object value = array.GetValue(i);
            if (DataInspectorUtility.inspect(ref value, valueType, "[" + i + "]", path))
            {
                changed = true;
                array.SetValue(value, i);
            }
        }
        return(changed);
    }
コード例 #7
0
    public override bool inspect(ref object data, Type type, string name, string path)
    {
        var list = data as IList;

        if (list == null)
        {
            return(false);
        }

        var  valueType = type.GetGenericArguments()[0];
        bool changed   = false;

        for (int i = 0; i < list.Count; ++i)
        {
            var value = list[i];
            if (DataInspectorUtility.inspect(ref value, valueType, "[" + i + "]", path))
            {
                changed = true;
                list[i] = value;
            }
        }

        return(changed);
    }
コード例 #8
0
    public override bool inspect(ref object data, Type type, string name, string path)
    {
        if (data == null)
        {
            return(false);
        }
        var dict = data as IDictionary;

        var args      = type.GetGenericArguments();
        var keyType   = args[0];
        var valueType = args[1];

        bool            changed      = false;
        object          keyToDelete  = null;
        DictionaryEntry pairToAdd    = new DictionaryEntry();
        DictionaryEntry pairToChange = new DictionaryEntry();

        foreach (DictionaryEntry pair in dict)
        {
            var key   = pair.Key;
            var value = pair.Value;

            EditorGUILayout.BeginHorizontal();
            if (DataInspectorUtility.inspect(ref key, keyType, "Key", path + key.ToString()))
            {
                if (dict.Contains(key))
                {
                    continue;
                }
                keyToDelete = pair.Key;
                pairToAdd   = new DictionaryEntry(key, value);
            }

            if (GUILayout.Button("-", btnStype, GUILayout.Width(20f)))
            {
                keyToDelete = key;
                continue;
            }

            EditorGUILayout.EndHorizontal();
            if (DataInspectorUtility.inspect(ref value, valueType, "Value", path + key.ToString()))
            {
                pairToChange = new DictionaryEntry(key, value);
            }
        }
        if (keyToDelete != null)
        {
            DataInspectorUtility.removeChangedPath(path + keyToDelete.ToString() + ".Key");
            dict.Remove(keyToDelete);
            changed = true;
        }
        if (pairToAdd.Key != null && pairToAdd.Value != null)
        {
            DataInspectorUtility.addChangedPath(path + pairToAdd.Key.ToString() + ".Key");
            dict.Add(pairToAdd.Key, pairToAdd.Value);
            changed = true;
        }
        if (pairToChange.Key != null && pairToChange.Value != null)
        {
            dict[pairToChange.Key] = pairToChange.Value;
            changed = true;
        }
        return(changed);
    }