コード例 #1
0
        private static void JSEditorNewClone(string _activity, string _params)
        {
            if (isLoading)
            {
                return;
            }

            try
            {
                JSONNode root    = JSON.Parse(_params);
                string   package = root["package"].Value;
                string   file    = root["file"].Value;
                string   uuid    = root["uuid"].Value;


                ResourceMgr.PreloadAsset(package, file
                                         , () =>
                {
                    startLoading();
                }
                                         , (_obj) =>
                {
                    GameObject go = ResourceMgr.CloneGameObject(package, file, uuid);
                    go.SetActive(false);
                    //open collider, support mouse pick
                    Collider collider = go.GetComponent <Collider>();
                    if (null != collider)
                    {
                        collider.enabled = true;
                    }
                    Battlehub.RTEditor.ExposeToEditor script = go.GetComponent <Battlehub.RTEditor.ExposeToEditor>();
                    if (null == script)
                    {
                        script = go.AddComponent <Battlehub.RTEditor.ExposeToEditor>();
                        //Debug.Log(script);
                    }
                    EditorMgr.AppendGameObject(uuid);
                    go.SetActive(true);
                    finishLoading();
                }
                                         , (_err) =>
                {
                    onNotify(_err);
                }
                                         );
            }
            catch (System.Exception e)
            {
                onNotify("Parse json has error: " + e.Message);
            }
        }