Пример #1
0
    //==============================================================================

    /**
     *	@brief	Load state from mcs file.
     */
    //==============================================================================
    private void LoadConfig()
    {
        var fbhelper = target as FirebaseHelper;
        var defines  = fbhelper.defines;

        McsManager.LoadMcs();
        if (McsManager.keyValues.ContainsKey("-define"))
        {
            int count = McsManager.keyValues["-define"].Count;
            for (int i = 0; i < count; ++i)
            {
                string fileDefines = McsManager.keyValues["-define"][i].value;
                if (fileDefines.IsReadable() == false)
                {
                    continue;
                }

                for (int d = 0; d < defines.Length; ++d)
                {
                    if (fileDefines == defines[d].defineName)
                    {
                        defines[d].enable = config[d].enable = true;
                        break;
                    }
                }
            }
        }

        bool useSdk = false;

        for (int i = 0; i < FirebaseHelper.Index.Length; ++i)
        {
            if (i == FirebaseHelper.Index.SdkBase)
            {
                continue;
            }

            config[i] = fbhelper.defines[i];
            useSdk   |= config[i].enable;
        }
        config[FirebaseHelper.Index.SdkBase].enable = useSdk;
    }
// U N I T Y   E V E N T S
//##########################################################################

    //==============================================================================

    /**
     *	@brief	OnEnable inspector event.
     */
    //==============================================================================
    public void OnEnable()
    {
        McsManager.keyValues.Clear();
        McsManager.LoadMcs();
    }
Пример #3
0
    //==============================================================================

    /**
     *	@brief	Update mcs file.
     */
    //==============================================================================
    private void UpdateMsc()
    {
        var fbhelper = target as FirebaseHelper;

        try
        {
            string text = "";

            // Trim FirebaseUtility's defines.
            if (File.Exists(McsManager.MCS_PATH))
            {
                text = File.ReadAllText(McsManager.MCS_PATH).Trim();
                IEnumerable <string> lines = text.Split('\n').Where(line => line.Length > 0);
                text = string.Join("\n", lines.Where(line => fbhelper.defines.All(define => (line.Contains(define.defineName) == false))).ToArray());
                if (text.Length > 0)
                {
                    text += "\n";
                }
            }

            string dir_libpath = nRedPath;
            if (dir_libpath.IsReadable())
            {
                dir_libpath += "/Firebase/";

                List <string> recompileList = new List <string>(8);

                // Add FirebaseUtility's defines.
                for (int i = 0; i < fbhelper.defines.Length; i++)
                {
                    string define = fbhelper.defines[i].defineName;
                    string script = fbhelper.defines[i].scriptName;
                    if (define.IsReadable() && config[i].enable)
                    {
                        text += "-define:" + define + "\n";
                        if (script.IsReadable())
                        {
                            recompileList.Add(script);
                        }
                    }
                }

                File.WriteAllText(McsManager.MCS_PATH, text);

                AssetDatabase.ImportAsset(McsManager.MCS_PATH);
                foreach (string scriptPath in recompileList)
                {
                    AssetDatabase.ImportAsset(dir_libpath + scriptPath);
                }

                if (recompileList.Count > 0)
                {
                    AssetDatabase.ImportAsset(nRedPath + "/FirebaseHelper.cs");
                }
                McsManager.LoadMcs();
            }
        }
        catch (System.Exception e)
        {
            nRed.DebugUtil.D.Log("[nRed][FirebaseUtility][Inspector] Could not update mcs: \n-----------------------\n" + e.ToString());
        }
    }