示例#1
0
    private void RefreshDeviceList()
    {
        System.Collections.Generic.List <MyDevices> adbDevices = AltUnityPortHandler.GetDevicesAndroid();
        System.Collections.Generic.List <MyDevices> androidForwardedDevices = AltUnityPortHandler.GetForwardedDevicesAndroid();
        foreach (var adbDevice in adbDevices)
        {
            var deviceForwarded = androidForwardedDevices.FirstOrDefault(device => device.DeviceId.Equals(adbDevice.DeviceId));
            if (deviceForwarded != null)
            {
                adbDevice.LocalPort  = deviceForwarded.LocalPort;
                adbDevice.RemotePort = deviceForwarded.RemotePort;
                adbDevice.Active     = deviceForwarded.Active;
            }
        }
        foreach (var device in devices)
        {
            var existingDevice = adbDevices.FirstOrDefault(d => d.DeviceId.Equals(device.DeviceId));
            if (existingDevice != null && device.Active == false && existingDevice.Active == false)
            {
                existingDevice.LocalPort  = device.LocalPort;
                existingDevice.RemotePort = device.RemotePort;
            }
        }
 #if UNITY_EDITOR_OSX
        System.Collections.Generic.List <MyDevices> iOSDEvices = AltUnityPortHandler.GetConnectediOSDevices();
        foreach (var iOSDEvice in iOSDEvices)
        {
            var iOSForwardedDevice = devices.FirstOrDefault(a => a.DeviceId.Equals(iOSDEvice.DeviceId));
            if (iOSForwardedDevice != null)
            {
                iOSDEvice.LocalPort  = iOSForwardedDevice.LocalPort;
                iOSDEvice.RemotePort = iOSForwardedDevice.RemotePort;
                iOSDEvice.Active     = iOSForwardedDevice.Active;
            }
        }
#endif


        devices = adbDevices;
#if UNITY_EDITOR_OSX
        devices.AddRange(iOSDEvices);
#endif
    }
示例#2
0
    private void GetComponentTypes()
    {
        // get types
        var assembly = System.Reflection.Assembly.GetAssembly(typeof(Component));

        _componentTypes = assembly.GetTypes().Where(t => typeof(Component).IsAssignableFrom(t) && t.IsPublic && t != typeof(Component)).ToArray();

        // get names
        _componentNames = new string[_componentTypes.Length];
        for (int i = 0; i < _componentTypes.Length; i++)
        {
            _componentNames[i] = GetComponentName(_componentTypes[i]);
        }

        // add abstract self to path
        for (int i = 0; i < _componentNames.Length; i++)
        {
            string name = _componentNames[i];

            // is this name used as a path in another name?
            bool contained = false;
            for (int j = 0; j < _componentNames.Length; j++)
            {
                if (i == j)
                {
                    continue;
                }

                if (_componentNames[j].Contains(name + "/"))
                {
                    contained = true;
                    break;
                }
            }

            string category = "";
            if (_componentTypes[i].Namespace != null && _componentTypes[i].Namespace != "UnityEngine")
            {
                category = _componentTypes[i].Namespace.Substring(0, 12) + "/";
            }
            else if (i > 1 && i <= 15)
            {
                category = "Rendering/";
            }
            else if (i > 24 && i <= 33)
            {
                category = "Physics/";
            }
            else
            {
                //string contains = _componentNames[i];
                System.Collections.Generic.List <string> subStrings = new System.Collections.Generic.List <string>
                {
                    "Audio", "2D"
                };
                switch (subStrings.FirstOrDefault(_componentNames[i].Contains))
                {
                case "Audio":
                {
                    category = "Audio/";
                    break;
                }

                case "2D":
                {
                    category = "Physics/Physics2D/";
                    break;
                }

                default:
                {
                    category = "";
                    break;
                }
                }
            }

            // add it to its own path
            if (contained)
            {
                _componentNames[i] = category + name + '/' + name.Split('/').Last();
                // TODO: category name here
            }
        }
    }
示例#3
0
 public static string TryGetValue(this List <System.EasyPair> KeyValuePairs, string Key)
 {
     return(KeyValuePairs?.FirstOrDefault(x => x.Key == Key)?.Value);
 }