Пример #1
0
    private CartoonTemplate CreateLevelObj(long level_id_)
    {
        this.ClearOldCartoon();

        int template_id = (int)(level_id_ / 1000 * 1000);

        if (null == this.m_template_path_names)
        {
            this.InitTemplate();
        }

        m_cartoon_root = GameObject.Find("UI_Cartoon");

        string     path         = this.m_template_path_names[template_id];
        GameObject gameObj      = AssetDatabase.LoadAssetAtPath <GameObject>(path);
        GameObject obj_in_scene = PrefabUtility.InstantiatePrefab(gameObj) as GameObject;

        obj_in_scene.transform.SetParent(m_cartoon_root.transform);
        RectTransform rect = obj_in_scene.GetComponent <RectTransform>();

        rect.anchoredPosition = Vector2.zero;
        rect.sizeDelta        = Vector2.zero;

        m_cur_editor_cartoon_template_id = template_id;
        m_cur_editor_cartoon_level_id    = level_id_;

        obj_in_scene.name = m_cur_editor_cartoon_level_id.ToString();
        CartoonTemplate ret = obj_in_scene.GetComponent <CartoonTemplate>();

        ret.m_template_id = m_cur_editor_cartoon_level_id;

        return(ret);
    }
Пример #2
0
    private void Start()
    {
        m_cartoon = this.gameObject.GetComponentInChildren <CartoonTemplate>();
        m_cartoon.Init();
        m_cartoon.m_play_rect.GetWorldCorners(m_play_rect_4_corners);

        this.InitCartoonItemAnchorPosition();
        this.InitCartoonItemPosition();
    }
Пример #3
0
    public void OnLoadLevel(long level_id_)
    {
        CartoonTemplate temp = this.CreateLevelObj(level_id_);

        CartoonItemJson json = CartoonJsonUtil.LoadLevelJsonData(level_id_);

        CartoonItemWithClips clips = this.ConvertVideoNameToClip(json);

        temp.LoadVideos(clips);

        this.ShowNotification(new GUIContent("请用鼠标选中漫画编辑器"));
    }
Пример #4
0
    private void SaveLevelJson()
    {
        if (null != m_cartoon_root)
        {
            CartoonTemplate[] cartoons = m_cartoon_root.GetComponentsInChildren <CartoonTemplate>(true);

            if (null != cartoons && 1 == cartoons.Length)
            {
                CartoonTemplate editing_item = cartoons[0];

                long key_id = editing_item.m_template_id / 1000;

                if (null == this.m_level_json_max_name_dict)
                {
                    this.CalcNewLevelName();
                }

                if (!this.m_level_json_max_name_dict.ContainsKey(key_id) || this.m_level_json_max_name_dict[key_id] < editing_item.m_template_id)
                {
                    this.m_level_json_max_name_dict[key_id] = editing_item.m_template_id;

                    CartoonJsonUtil.SaveLevelJsonData(editing_item);
                }
                else
                {
                    CartoonJsonUtil.SaveLevelJsonData(editing_item);
                }

                this.ShowNotification(new GUIContent("提示: 保存成功"));
            }
            else
            {
                EditorGUILayout.HelpBox("场景内没有,或者有多余的漫画模板", MessageType.Error);
                this.ShowNotification(new GUIContent("错误: 场景内没有,或者有多余的漫画模板"));
                return;
            }
        }
        else
        {
            EditorGUILayout.HelpBox("重新打开漫画编辑器", MessageType.Error);
            this.ShowNotification(new GUIContent("错误: 重新打开漫画编辑器"));
            return;
        }
    }
Пример #5
0
        private void OnLoad(string name_, UnityEngine.Object obj)
        {
            if (null != m_play_root)
            {
                m_play_root.Visible = false;
                m_play_root.Dispose(false);

                GameObject.DestroyImmediate(m_play_root.gameObject);
            }
            m_cam = CameraManager.Instance.UICamera;

            GameObject cartoon_item = (GameObject)obj;

            cartoon_item.name = m_level_id.ToString();
            cartoon_item.transform.SetParent(this.gameObject.transform);
            cartoon_item.transform.localPosition = Vector3.zero;
            cartoon_item.transform.localScale    = Vector3.one;
            m_play_root = this.Make <GameUIComponent>(cartoon_item);
            m_play_root.Widget.anchoredPosition = Vector2.zero;
            m_play_root.Widget.sizeDelta        = Vector2.zero;
            m_play_root.Visible = true;

            //m_play_root = cartoon_item.GetComponent<RectTransform>();
            //m_play_root.anchoredPosition = Vector2.zero;
            //m_play_root.sizeDelta = Vector2.zero;
            //m_play_root.gameObject.SetActive(true);

            m_play_rect = m_play_root.Make <GameUIComponent>("Play_Rect");
            m_play_rect.Widget.GetWorldCorners(m_play_rect_4_corners);

            //m_play_rect = m_play_root.Find("Play_Rect").GetComponent<RectTransform>();
            //m_play_rect.GetWorldCorners(m_play_rect_4_corners);

            m_cartoon = m_play_root.GetComponent <CartoonTemplate>();
            m_cartoon.m_template_id = this.m_level_id;

            this.LoadClipByVideoName(CartoonDataManager.Instance.GetData(this.m_level_id));


            EngineCoreEvents.ResourceEvent.ReleaseAssetEvent.SafeInvoke(name_, obj);
        }
Пример #6
0
    public static void SaveLevelJsonData(CartoonTemplate temp_)
    {
        CartoonItemJson item_json = new CartoonItemJson();

        item_json.Item_id    = temp_.m_template_id;
        item_json.M_cartoons = new List <CartoonVideoNamesJson>();

        temp_.Init();

        foreach (var item in temp_.m_cartoon_items)
        {
            CartoonVideoNamesJson names = new CartoonVideoNamesJson();
            names.M_names = new List <string>();

            foreach (var clip in item.m_videos)
            {
                names.M_names.Add(clip.name);
            }

            item_json.M_cartoons.Add(names);
        }

        string j_str = fastJSON.JSON.ToJSON(item_json);
        string _path = GAME_JSON_PATH;

        if (!_path.StartsWith("/"))
        {
            _path = _path.Insert(0, "/");
        }

        if (!_path.EndsWith("/"))
        {
            _path = _path + "/";
        }

        string temp_path = string.Format("{0}{1}{2}{3}", Application.dataPath, _path, item_json.Item_id, ".json");

        ExportJigsawJson.CreateJson(temp_path, j_str);
    }