Esempio n. 1
0
        public void PrepareBundlePlugins(BuildTarget target, string pathToXcodeProject)
        {
            if (target == BuildTarget.StandaloneOSX)
            {
                // Loop through Xcode project to find all .bundle plugins:
                foreach (string filePath in Directory.GetDirectories(pathToXcodeProject, "*.bundle", SearchOption.AllDirectories))
                {
                    // This should be the path to the main Info.plist file of the plugin
                    string plistPath = filePath + "/Contents/Info.plist";

                    // This bundle does not have a Info.plist file, that's strange - let's stop now to make sure we don't break anything
                    if (!File.Exists(plistPath))
                    {
                        continue;
                    }

                    // Multiple Info.plist files cause problems, and the Prime31 iCloud Mac plugin has these, so let's remove them
                    string[] allInfoPlists = Directory.GetFiles(filePath, "Info.plist", SearchOption.AllDirectories);
                    if (allInfoPlists.Length > 1)
                    {
                        for (int i = 0; i < allInfoPlists.Length; i++)
                        {
                            // Delete any Info.plist file that's not the main one
                            if (allInfoPlists[i] != plistPath)
                            {
                                File.Delete(allInfoPlists[i]);
                            }
                        }
                    }

                    // Delete all metafiles inside the bundle. Not necessary after Unity 2019, but let's check to be sure
                    string[] allMetaFiles = Directory.GetFiles(filePath, "*.meta", SearchOption.AllDirectories);
                    for (int i = 0; i < allMetaFiles.Length; i++)
                    {
                        File.Delete(allInfoPlists[i]);
                    }

                    PList plist = XcodeEditor.LoadResourcePlist(plistPath);

                    // This is the filename of the plugin, minus extension:
                    string bundleName = Path.GetFileName(filePath).Replace(".bundle", "");

                    // Set the CFBundleIdentifier to be com.company.product.bundleName
                    if (!plist.Root.ContainsKey("CFBundleIdentifier"))
                    {
                        plist.Root.Add("", Application.identifier + "." + bundleName);
                    }
                    else
                    {
                        plist.Root["CFBundleIdentifier"] = new PListString(Application.identifier + "." + bundleName);
                    }

                    // Save the Plist file
                    plist.Save(plistPath, true);

                    // Let's remove any codesigning from this plugin, so only the main app code sign is being used
                    ExecuteProcessTerminal(string.Format("codesign --remove-signature {0}", filePath));
                }
            }
        }
Esempio n. 2
0
        Texture2D LoadTexture(string resourceName, int width, int height)
        {
            Texture2D asset = AssetDatabase.LoadAssetAtPath <Texture2D>(XcodeEditor.BasePath() + "/Resources/" + resourceName + ".png");

            if (asset == null)
            {
                Debug.LogError("Failed to load texture: " + XcodeEditor.BasePath() + "/Resources/" + resourceName + ".png");
                return(null);
            }
            return(asset);
        }
Esempio n. 3
0
        void LoadTexturesInResourceFile(string fileName)
        {
            using (StreamReader reader = new StreamReader(XcodeEditor.BasePath() + "/Resources/" + fileName))
            {
                while (!reader.EndOfStream)
                {
                    string entry = reader.ReadLine().Trim();

                    if (entry.StartsWith("//"))
                    {
                        continue;
                    }

                    string[] elements = entry.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);

                    if (elements.Length != 3)
                    {
                        continue;
                    }

                    int w = 0, h = 0;

                    if (!int.TryParse(elements[1], out w))
                    {
                        continue;
                    }

                    if (!int.TryParse(elements[2], out h))
                    {
                        continue;
                    }

                    var tex = LoadTexture(elements[0], w, h);

                    if (tex != null)
                    {
                        _resources.Add(elements[0], tex);
                    }
                }
            }
        }
Esempio n. 4
0
        void LoadResourceBuildSettings()
        {
            PList plist = XcodeEditor.LoadResourcePlist(BUILD_SETTINGS_FILE);

            //check is right type
            if (!ValidatePlist(plist))
            {
                return;
            }

            //load the contents from the dic
            var settings = plist.Root.ArrayValue(BUILD_SETTINGS_KEY);

            if (settings == null)
            {
                return;
            }

            //populate the settings
            for (int ii = 0; ii < settings.Count; ++ii)
            {
                var         dic = settings.DictionaryValue(ii);
                SettingType type;

                try
                {
                    type = (SettingType)System.Enum.Parse(typeof(SettingType), dic.StringValue(TYPE_KEY));
                }
                catch
                {
                    Debug.LogError("EgoXproject: Unknown setting type in build settings database.");
                    continue;
                }

                switch (type)
                {
                case SettingType.Bool:
                    AddBool(dic);
                    break;

                case SettingType.Enum:
                    AddEnum(dic);
                    break;

                case SettingType.String:
                    AddString(dic);
                    break;

                case SettingType.Array:
                    AddArray(dic);
                    break;

                case SettingType.StringList:
                    AddStringList(dic);
                    break;

                default:
                    Debug.LogError("EgoXproject: Developer has forgot to implement code for a new type in the build settings database.");
                    break;
                }
            }
        }