Esempio n. 1
0
    private static List <Component> GetComponents(SteamRPC sync)
    {
        var comps = sync.GetComponents <Component>();

        var list = new List <Component>();

        for (int i = 0, imax = comps.Length; i < imax; ++i)
        {
            if (comps[i] != sync && comps[i].GetType() != typeof(MonoBehaviour))
            {
                list.Add(comps[i]);
            }
        }
        return(list);
    }
Esempio n. 2
0
    private static void DrawProperties(SteamRPC _rpc, SteamRPC.Entry nowEntry, int index)
    {
        if (nowEntry.target == null)
        {
            return;
        }

        var Methods = nowEntry.target.GetType().GetMethods(
            BindingFlags.Instance | BindingFlags.Public);
        Component igorne         = new MonoBehaviour();
        var       igorne_methond = igorne.GetType().GetMethods(
            BindingFlags.Public | BindingFlags.Instance);

        var oldIndex = 0;
        var names    = new List <string> {
            "<None>"
        };
        var avalible_mthods = (from t in Methods let ignore = igorne_methond.Any(t1 => t1.Name == t.Name) where !ignore select t).ToList();

        foreach (var t in avalible_mthods)
        {
            if (t.Name == nowEntry.method_name)
            {
                oldIndex = names.Count;
            }
            names.Add(t.Name);
        }

        var new_index = EditorGUILayout.Popup(oldIndex, names.ToArray());

        GUI.backgroundColor = Color.red;
        var delete = GUILayout.Button("X", GUILayout.Width(24f), GUILayout.Height(14f));

        if (delete)
        {
            _rpc.entries.RemoveAt(index);
            EditorUtility.SetDirty(_rpc);
            return;
        }
        if (new_index == oldIndex)
        {
            return;
        }
        nowEntry.method      = (new_index == 0) ? null : avalible_mthods[new_index - 1];
        nowEntry.method_name = nowEntry.method == null?"<None>": nowEntry.method.Name;
        EditorUtility.SetDirty(_rpc);
    }
Esempio n. 3
0
    private static bool DrawTarget(SteamRPC _rpc, int index, List <Component> components, string[] names)
    {
        var ent = _rpc.entries[index];

        if (ent.target == null)
        {
            ent.target = components[0];
            EditorUtility.SetDirty(_rpc);
        }

        var oldIndex = 0;
        var tname    = (ent.target != null) ? ent.target.GetType().ToString() : "<None>";

        for (var i = 1; i < names.Length; ++i)
        {
            if (names[i] != tname)
            {
                continue;
            }
            oldIndex = i;
            break;
        }


        GUI.skin.label.alignment = TextAnchor.MiddleCenter;

        // EditorGUILayout.HelpBox(index.ToString(), MessageType.None);
        EditorGUILayout.LabelField(index.ToString(), GUILayout.Width(20f), GUILayout.Height(14f));


        GUI.backgroundColor = Color.white;
        var newIndex = EditorGUILayout.Popup(oldIndex, names);



        if (newIndex != oldIndex)
        {
            ent.target = (newIndex == 0) ? null : components[newIndex - 1];
            EditorUtility.SetDirty(_rpc);
        }
        return(true);
    }