CreateContent() public method

public CreateContent ( ) : CLS_Content
return CLS_Content
Esempio n. 1
0
 public void SetValue(string name, object v)
 {
     if (env == null)
     {
         Init();
     }
     if (content == null)
     {
         content = env.CreateContent();
     }
     content.DefineAndSet(name, v.GetType(), v);
 }
Esempio n. 2
0
    // 从资源包初始化脚本环境
    public void InitializeFromAssetBundle(AssetBundle scriptsAssetBundle)
    {
        m_clsAssetBundle = scriptsAssetBundle;

        #if UNITY_EDITOR
        float timeStart = Time.realtimeSinceStartup;
        uint monoStart = Profiler.GetMonoUsedSize();
        #endif

        // 获取默认的脚本实例
        m_clsEnv = ToCSLight.CreateEnvironment();
        m_clsContent = m_clsEnv.CreateContent();

        // 预注册脚本类
        #if UNITY_EDITOR && !EDITOR_FORCE_ASSET_BUNDLE
        string rootPath = Application.dataPath + "/CSLight/Editor/CSLogic";
        string[] files = System.IO.Directory.GetFiles(rootPath, "*.cs", System.IO.SearchOption.AllDirectories);
        foreach (var file in files)
        {
            string className = System.IO.Path.GetFileNameWithoutExtension(file);
            m_clsEnv.RegType(new CLS_Type_Class(className, file.Replace('\\', '/')));
        }
        #else
        StringHolder classHolder = m_clsAssetBundle.LoadAsset("class", typeof(StringHolder)) as StringHolder;
        foreach (string className in classHolder.content)
        {
            m_clsEnv.RegType(new CLS_Type_Class(className, className));
        }
        #endif

        #if UNITY_EDITOR
        Debug.Log("script init cost time: " + (Time.realtimeSinceStartup - timeStart));
        Debug.Log(string.Format("script init cost memory: {0:0.00}MB", (Profiler.GetMonoUsedSize() - monoStart) / (1024f * 1024f)));
        timeStart = Time.realtimeSinceStartup;
        #endif
    }