コード例 #1
0
    void ClearPreview()
    {
        MainViewCtrl spriteView = _GetControl <MainViewCtrl>(m_SpriteViewName);

        if (null == spriteView)
        {
            return;
        }

        MainViewCtrl atlasView = _GetControl <MainViewCtrl>(m_AtlasViewName);

        if (null == atlasView)
        {
            return;
        }

        LabelCtrl spriteInfo = _GetControl <LabelCtrl>(m_SpriteInfoLabel);

        if (null == spriteInfo)
        {
            return;
        }

        LabelCtrl atlasInfo = _GetControl <LabelCtrl>(m_AtlasInfoLabel);

        if (null == atlasInfo)
        {
            return;
        }

        UniversalEditorUtility.DestoryChildren(spriteView.GetBindingTarget());
        UniversalEditorUtility.DestoryChildren(atlasView.GetBindingTarget());

        spriteInfo.Caption = "";
        atlasInfo.Caption  = "";
    }
コード例 #2
0
ファイル: Launcher.cs プロジェクト: jpsiyu/MotionBlur
 private void BoostFinish()
 {
     GameObject.Destroy(this);
     MainViewCtrl.Open();
 }
コード例 #3
0
ファイル: UIAtlasEditor.cs プロジェクト: Hengle/UnityEditor
    public static void InitControls(EditorRoot editorRoot)
    {//初始化窗口
        if (editorRoot == null)
        {
            //提示程序错误Message
            EditorUtility.DisplayDialog("运行错误",
                                        "窗口初始化失败",
                                        "确认");
            return;
        }

        s_root = editorRoot;
        //s_root.position = new Rect(100f, 100f, 1280, 768f);

        {
            s_root.onEnable  = OnEnable;
            s_root.onDisable = OnDisable;
        }

        #region 创建布置窗口元素

        #region 第一级分割
        Rect btnRect   = new Rect(0, 0, 80, 20);
        Rect labelRect = new Rect(0, 0, 80, 5);
        Rect hboxRect  = new Rect(0, 0, 300, 5);

        HSpliterCtrl hs1 = new HSpliterCtrl();
        hs1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30f);
        HSpliterCtrl hs2 = new HSpliterCtrl();
        hs2.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30f, true);

        HBoxCtrl hb1 = new HBoxCtrl();      //布置上方菜单条
        HBoxCtrl hb2 = new HBoxCtrl();      //布置主窗口
        HBoxCtrl hb3 = new HBoxCtrl();      //布置下方状态栏
        #endregion

        #region 第二级分割
        VSpliterCtrl vs2_1 = new VSpliterCtrl();
        vs2_1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(300f);
        vs2_1.Dragable         = true;
        VSpliterCtrl vs2_2 = new VSpliterCtrl();
        vs2_2.layoutConstraint = LayoutConstraint.GetSpliterConstraint(300f, true);
        vs2_2.Dragable         = true;

        VBoxCtrl vb2_1 = new VBoxCtrl();               //布置工程目录/小图列表
        VBoxCtrl vb2_2 = new VBoxCtrl();               //布置预览窗口
        VBoxCtrl vb2_3 = new VBoxCtrl();               //布置Inspector窗口
        #endregion

        #region 第三级分割
        HSpliterCtrl hs2_1_1 = new HSpliterCtrl();
        hs2_1_1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(260f, true);

        VBoxCtrl vb2_1_1 = new VBoxCtrl();                    //布置小图列表
        VBoxCtrl vb2_1_2 = new VBoxCtrl();                    //布置工程目录
        #endregion

        #region  第四级分割
        HSpliterCtrl hs2_1_2_1 = new HSpliterCtrl();
        hs2_1_2_1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(240, true);

        VBoxCtrl vb2_1_2_1 = new VBoxCtrl();                    //布置小图列表
        VBoxCtrl vb2_1_2_2 = new VBoxCtrl();                    //布置工程目录
        #endregion
        #endregion

        #region 布置窗口(由高至低布置)

        #region 第四级分割

        #region Project View
        HBoxCtrl projectBtnBox = new HBoxCtrl();
        projectBtnBox.Size = hboxRect;

        LabelCtrl procLabel = new LabelCtrl();
        procLabel.Size    = labelRect;
        procLabel.Caption = "Project View";

        ButtonCtrl newProjBtn = new ButtonCtrl();
        newProjBtn.Caption = "新建工程";
        newProjBtn.Name    = "_NewProjBtn";
        newProjBtn.Size    = btnRect;
        newProjBtn.onClick = OnNewProjBtn;

        ButtonCtrl openProjBtn = new ButtonCtrl();
        openProjBtn.Caption = "打开工程";
        openProjBtn.Name    = "_OpenProjBtn";
        openProjBtn.Size    = btnRect;
        openProjBtn.onClick = OnOpenProjBtn;

        ButtonCtrl saveProjBtn = new ButtonCtrl();
        saveProjBtn.Caption = "保存工程";
        saveProjBtn.Name    = "_SaveProjBtn";
        saveProjBtn.Size    = btnRect;
        saveProjBtn.onClick = OnSaveProjBtn;
        projectBtnBox.Add(newProjBtn);
        projectBtnBox.Add(saveProjBtn);
        projectBtnBox.Add(openProjBtn);

        // vb2_1_2_1.Add(procLabel);
        vb2_1_2_1.Add(projectBtnBox);
        #endregion

        m_projTreeView                = new ListViewCtrl(); //工程目录
        m_projTreeView.Caption        = "Project";
        m_projTreeView.Name           = "Project";
        m_projTreeView.onItemSelected = OnSelectProjectListItem;
        m_projTreeView.IsTextureView  = false;


        vb2_1_2_2.Add(m_projTreeView);

        hs2_1_2_1.Add(vb2_1_2_1);
        hs2_1_2_1.Add(vb2_1_2_2);
        #endregion

        #region 第三级分割
        m_spriteListView = new ListViewCtrl();        //小图列表
        m_spriteListView.IsTextureView = false;
        m_spriteListView.Caption       = "小图";
        m_spriteListView.Name          = "spriteTreeView";

        m_spriteListView.onItemSelected     = OnSelectListItem;
        m_spriteListView.onItemCtrlSelected = OnSelectListItem;
        m_spriteListView.onItemSelectedR    = OnSelectListItemR;
        m_spriteListView.onItemSelectedRU   = OnSelectListItemRU;
        vb2_1_1.Add(m_spriteListView);
        vb2_1_2.Add(hs2_1_2_1);

        hs2_1_1.Add(vb2_1_1);
        hs2_1_1.Add(vb2_1_2);
        #endregion

        #region 第二级分割
        m_preview          = new MainViewCtrl();     //预览窗口
        m_preview.Name     = "_Preview";
        m_preview.bkColor  = Color.grey;
        m_preview.Is2DView = true;

        m_inspector             = new InspectorViewCtrl(); //属性窗口
        m_inspector.Name        = "_Inspector";
        m_inspector.onInspector = null;

        vb2_1.Add(hs2_1_1);
        vb2_2.Add(m_preview);
        vb2_3.Add(m_inspector);

        vs2_1.Add(vb2_1);
        vs2_1.Add(vs2_2);

        vs2_2.Add(m_preview);
        vs2_2.Add(vb2_3);
        #endregion

        #region 第一级分割
        #region  方菜单条
        ButtonCtrl addImageBtn = new ButtonCtrl();
        addImageBtn.Caption = "添加小图";
        addImageBtn.Name    = "_AddImageBtn";
        addImageBtn.Size    = btnRect;
        addImageBtn.onClick = OnAddImageBtn;

        ButtonCtrl previewBtn = new ButtonCtrl();
        previewBtn.Caption = "生成预览";
        previewBtn.Name    = "_PreviewBtn";
        previewBtn.Size    = btnRect;
        previewBtn.onClick = OnPreviewBtn;

        ButtonCtrl makeAtlasBtn = new ButtonCtrl();
        makeAtlasBtn.Caption = "生成图集";
        makeAtlasBtn.Name    = "_MakeAtlasBtn";
        makeAtlasBtn.Size    = btnRect;
        makeAtlasBtn.onClick = OnMakeAtlasBtn;

        ButtonCtrl configImageBaseBtn = new ButtonCtrl();
        configImageBaseBtn.Caption = "配置图库路径";
        configImageBaseBtn.Name    = "_ConfigImageBaseBtn";
        configImageBaseBtn.Size    = btnRect;
        configImageBaseBtn.onClick = OnConfigImageBaseBtn;

        ButtonCtrl helpBtn = new ButtonCtrl();
        helpBtn.Caption  = "帮助";
        helpBtn.Size     = btnRect;
        helpBtn.onClick += OnHelp;

        hb1.Add(addImageBtn);
        hb1.Add(previewBtn);
        hb1.Add(makeAtlasBtn);
        hb1.Add(configImageBaseBtn);
        hb1.Add(helpBtn);
        #endregion

        hb2.Add(vs2_1);

        hs1.Add(hb1);
        hs1.Add(hs2);

        hs2.Add(hb2);
        hs2.Add(hb3);
        #endregion

        #endregion

        //设置窗口根控件
        s_root.RootCtrl = hs1;

        //注册UIAtlasEditorModel回调函数
        UIAtlasEditorModel.GetInstance().onNewProject          = OnNewProject;
        UIAtlasEditorModel.GetInstance().onSpriteImageLoad     = OnSpriteImageLoad;
        UIAtlasEditorModel.GetInstance().onClearCurrentProject = OnClearCurrentProject;

        UIAtlasEditorModel.GetInstance().onAddSpriteImageCommand    = OnAddSpriteImageCommand;
        UIAtlasEditorModel.GetInstance().onDeleteSpriteImageCommand = OnDeleteSpriteImageCommand;
        UIAtlasEditorModel.GetInstance().onMakeAtlasCommand         = OnMakeAtlasCommand;
        UIAtlasEditorModel.GetInstance().onSpriteZoomChangedCommand = OnSpriteImageZoomChangedCommand;

        //注册编辑器窗口OnGui回调函数
        s_root.onGUI        = OnEditorGUI;
        m_Counter           = new GameObject();
        m_Counter.name      = "AtlasCmdCounter";
        m_Counter.hideFlags = HideFlags.HideAndDontSave;
        m_Counter.AddComponent <UIAtlasCommandCounter>();
        m_CommandCounter = m_Counter.GetComponent <UIAtlasCommandCounter>();
    }
コード例 #4
0
    public static void InitControls(EditorRoot editorRoot)
    {
        SearchSpriteEditor searchSpriteEditor = editorRoot as SearchSpriteEditor;

        if (editorRoot == null)
        {
            //提示程序错误Message
            EditorUtility.DisplayDialog("运行错误",
                                        "窗口初始化失败",
                                        "确认");
            return;
        }

        m_EditorRoot = searchSpriteEditor;

        m_EditorRoot.position = new Rect(100f, 100f, m_RootWidth, 768f);


        #region 创建窗口布局元素
        Rect searchTextRect = new Rect(0, 0, 300, 20);

        #region 第一级分割
        HSpliterCtrl hs1 = new HSpliterCtrl();
        hs1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30f);

        HSpliterCtrl hs2 = new HSpliterCtrl();
        hs2.MinOffset        = 100f;
        hs2.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30f, true);
        hs2.Dragable         = true;

        HBoxCtrl hb1 = new HBoxCtrl();      //搜索栏 HB
        HBoxCtrl hb2 = new HBoxCtrl();      //预览区 HB
        VBoxCtrl vb3 = new VBoxCtrl();      //结果List HB
        #endregion

        #region 第二级分割
        VSpliterCtrl vs2_1 = new VSpliterCtrl();
        vs2_1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(m_RootWidth / 2);
        vs2_1.Dragable         = true;

        VBoxCtrl vb2_1 = new VBoxCtrl();
        VBoxCtrl vb2_2 = new VBoxCtrl();
        #endregion

        #region 第三级分割
        HSpliterCtrl hs2_1_1 = new HSpliterCtrl();
        hs2_1_1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(10f, true);

        HSpliterCtrl hs2_2_1 = new HSpliterCtrl();
        hs2_2_1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(10f, true);

        HBoxCtrl hb2_1_1 = new HBoxCtrl();
        HBoxCtrl hb2_1_2 = new HBoxCtrl();

        HBoxCtrl hb2_2_1 = new HBoxCtrl();
        HBoxCtrl hb2_2_2 = new HBoxCtrl();
        #endregion
        #endregion

        #region 布置窗口
        TextBoxCtrl searchTextBox = new TextBoxCtrl();
        searchTextBox.Size    = searchTextRect;
        searchTextBox.Icon    = UnityInternalIconCache.GetInstance().GetCacheIcon("d_ViewToolZoom");
        searchTextBox.Name    = m_SearchTextBoxName;
        searchTextBox.Caption = "搜索";

        ButtonCtrl vagueSearchBtn = new ButtonCtrl();
        vagueSearchBtn.Name    = m_VagueSearchBtnName;
        vagueSearchBtn.Caption = "模糊搜索";
        vagueSearchBtn.onClick = searchSpriteEditor.OnSearchBtn;

        ButtonCtrl searchBtn = new ButtonCtrl();
        searchBtn.Name    = m_SearchBtnName;
        searchBtn.Caption = "精确搜索";
        searchBtn.onClick = searchSpriteEditor.OnSearchBtn;

        ButtonCtrl setBtn = new ButtonCtrl();
        setBtn.Name    = m_SetBtnName;
        setBtn.Caption = "设置";
        setBtn.onClick = searchSpriteEditor.OnSetBtn;

        ButtonCtrl helpBtn = new ButtonCtrl();
        helpBtn.Name    = m_HelpBtnName;
        helpBtn.Caption = "帮助";
        helpBtn.onClick = searchSpriteEditor.OnHelpBtnClick;

        hb1.Add(searchTextBox);
        hb1.Add(vagueSearchBtn);
        hb1.Add(searchBtn);
        hb1.Add(setBtn);
        hb1.Add(helpBtn);

        MainViewCtrl spriteView = new MainViewCtrl();
        spriteView.Name     = m_SpriteViewName;
        spriteView.bkColor  = Color.gray;
        spriteView.Is2DView = true;

        LabelCtrl spriteInfoLabel = new LabelCtrl();
        spriteInfoLabel.Name    = m_SpriteInfoLabel;
        spriteInfoLabel.Caption = "";

        MainViewCtrl atlasView = new MainViewCtrl();
        atlasView.Name     = m_AtlasViewName;
        atlasView.bkColor  = Color.gray;
        atlasView.Is2DView = true;

        LabelCtrl atlasInfoLabel = new LabelCtrl();
        atlasInfoLabel.Name    = m_AtlasInfoLabel;
        atlasInfoLabel.Caption = "";

        hb2_1_1.Add(spriteView);
        hb2_1_2.Add(spriteInfoLabel);

        hb2_2_1.Add(atlasView);
        hb2_2_2.Add(atlasInfoLabel);

        hs2_1_1.Add(hb2_1_1);
        hs2_1_1.Add(hb2_1_2);

        hs2_2_1.Add(hb2_2_1);
        hs2_2_1.Add(hb2_2_2);

        vb2_1.Add(hs2_1_1);
        vb2_2.Add(hs2_2_1);

        vs2_1.Add(vb2_1);
        vs2_1.Add(vb2_2);

        hb2.Add(vs2_1);

        ListViewCtrl searchResultList = new ListViewCtrl();
        searchResultList.Name            = m_SearchResultListName;
        searchResultList.onItemSelected  = searchSpriteEditor.OnSelectListItem;
        searchResultList.onItemSelectedR = searchSpriteEditor.OnSelectListItem;

        SpaceCtrl spaceCtrl = new SpaceCtrl();
        spaceCtrl.CurrValue = 30f;

        vb3.Add(searchResultList);
        vb3.Add(spaceCtrl);

        hs1.Add(hb1);
        hs1.Add(hs2);

        hs2.Add(hb2);
        hs2.Add(vb3);

        m_EditorRoot.RootCtrl = hs1;
        #endregion

        m_EditorRoot.onGUI = searchSpriteEditor.OnEditorGUI;
    }
コード例 #5
0
    void OnSelectListItem(EditorControl c, int index)
    {
        if (
            (m_SearchResultInfo == null) ||
            (m_SearchResultInfo.SearchSpriteInfo == null)
            )
        {
            return;
        }

        ListViewCtrl searchList = c as ListViewCtrl;

        if (null == searchList)
        {
            return;
        }

        MainViewCtrl spriteView = _GetControl <MainViewCtrl>(m_SpriteViewName);

        if (null == spriteView)
        {
            return;
        }

        MainViewCtrl atlasView = _GetControl <MainViewCtrl>(m_AtlasViewName);

        if (null == atlasView)
        {
            return;
        }

        LabelCtrl spriteInfo = _GetControl <LabelCtrl>(m_SpriteInfoLabel);

        if (null == spriteInfo)
        {
            return;
        }

        LabelCtrl atlasInfo = _GetControl <LabelCtrl>(m_AtlasInfoLabel);

        if (null == atlasInfo)
        {
            return;
        }

        SearchSpriteInfo info = m_SearchResultInfo.SearchSpriteInfo[index];

        Texture atlasTex = info.AtlasTexture;

        //获取Sprite在Atlas中的位置
        Rect spriteUVRect = info.SpriteRect;
        //m_SearchResultInfo.GetSpirteUVRect(index);
        Rect spriteUVRectReal = UtilityForNGUI.ConvertToTexCoords(spriteUVRect, atlasTex.width, atlasTex.height);

        float aspect = (float)atlasTex.width / (float)atlasTex.height;
        float w1     = 10.0f;
        float h1     = w1 / aspect;

        float aspect2 = (float)spriteUVRect.width / (float)spriteUVRect.height;
        float w2      = 3.0f;
        float h2      = w2 / aspect2;

        //创建预览Object
        GameObject spritePreviewObj = _GenTexturePreviewObject(w2, h2, atlasTex, spriteUVRectReal);
        GameObject atlasPreviewObj  = _GenTexturePreviewObject(w1, h1, atlasTex, new Rect(0, 0, 1, 1));

        //将预览Object绑定至MainView的主相机之下
        UniversalEditorUtility.DestoryChildren(spriteView.GetBindingTarget());
        spritePreviewObj.transform.parent        = spriteView.GetBindingTarget().transform;
        spritePreviewObj.transform.localPosition = Vector3.zero;

        UniversalEditorUtility.DestoryChildren(atlasView.GetBindingTarget());
        atlasPreviewObj.transform.parent        = atlasView.GetBindingTarget().transform;
        atlasPreviewObj.transform.localPosition = Vector3.zero;

        //更新预览信息
        string atlasName = Path.GetFileNameWithoutExtension(info.AtlasPath);

        spriteInfo.Caption = "Sprite: " + info.SpriteName + " , " + spriteUVRect.width + " * " + spriteUVRect.height;
        atlasInfo.Caption  = "Atlas: " + atlasName + " , " + info.AtlasTexture.width + " * " + info.AtlasTexture.height;
        //spriteView.mainViewUVRect = spriteUVRect;

        RequestRepaint();
    }