Пример #1
0
    public static SceneSyncItemWindow CreateWindow()
    {
        Rect rect = new Rect(0, 0, 800, 700);
        SceneSyncItemWindow window = (SceneSyncItemWindow)EditorWindow.GetWindowWithRect(typeof(SceneSyncItemWindow), rect, true, "数据同步窗口");

        if (window.Init())
        {
            window.Show();
        }
        return(window);
    }
Пример #2
0
    void ItemInfoShow(ItemPosInfo posInfo, int i)
    {
        if (posInfo == null)
        {
            return;
        }
        EditorGUILayout.BeginVertical();

        if (selectIndex >= 0 && itemObjs[selectIndex] != null)
        {
            itemObjs[selectIndex].itemObj[i] = (GameObject)EditorGUILayout.ObjectField(itemObjs[selectIndex].itemObj[i], typeof(GameObject), true);
        }
        posInfo.type = (ItemType)EditorGUILayout.EnumPopup("物品类型:", posInfo.type);

        posInfo.pos    = EditorGUILayout.Vector3Field("位置", posInfo.pos);
        posInfo.rotate = EditorGUILayout.Vector3Field("旋转", posInfo.rotate);
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("位置概率");
        posInfo.percent = EditorGUILayout.FloatField(posInfo.percent);

        EditorGUILayout.EndHorizontal();
        int cameraIndex = 0;

        for (int m = 0; m < m_allCameraNode.Count; m++)
        {
            if (m_allCameraNode[m].Equals(posInfo.m_cameraNode))
            {
                cameraIndex = m;
                break;
            }
        }
        posInfo.m_cameraNode = m_allCameraNode[EditorGUILayout.Popup(cameraIndex, m_allCameraNode.ToArray())];
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("设置坐标"))
        {
            if (selectItem != null && selectIndex >= 0 && itemObjs[selectIndex] != null)
            {
                posInfo.pos    = itemObjs[selectIndex].itemObj[i].transform.position;
                posInfo.rotate = itemObjs[selectIndex].itemObj[i].transform.eulerAngles;
            }
        }

        if (GUILayout.Button("跳转"))
        {
            if (selectItem != null && selectIndex >= 0 && itemObjs[selectIndex] != null)
            {
                itemObjs[selectIndex].itemObj[i].transform.position    = posInfo.pos;
                itemObjs[selectIndex].itemObj[i].transform.eulerAngles = posInfo.rotate;
            }
        }

        if (GUILayout.Button("同步"))
        {
            if (selectItem == null)
            {
                return;
            }
            if (selectItem != null && selectIndex >= 0 && itemObjs[selectIndex] != null)
            {
                Transform itemTran = itemObjs[selectIndex].itemObj[i].transform;
                posInfo.pos    = itemTran.position;
                posInfo.rotate = itemTran.eulerAngles;
                SysncItem(selectItem.itemID, i, itemTran, posInfo.m_cameraNode);
            }
        }

        if (GUILayout.Button("同步单个"))
        {
            if (selectItem == null)
            {
                return;
            }
            if (selectItem != null && selectIndex >= 0 && itemObjs[selectIndex] != null)
            {
                Transform           itemTran    = itemObjs[selectIndex].itemObj[i].transform;
                SceneSyncItemWindow syncItemWin = SceneSyncItemWindow.CreateWindow();
                syncItemWin.SetData(m_allItemInfo, selectItem.itemID, i, itemTran.gameObject, selectDataIndex, selectItem.itemPos[i].m_cameraNode);
                //posInfo.pos = itemTran.position;
                //posInfo.rotate = itemTran.eulerAngles;
                //SysncItem(selectItem.itemID, i, itemTran.position, itemTran.localScale, itemTran.eulerAngles);
            }
        }

        if (GUILayout.Button("删除"))
        {
            if (selectItem != null)
            {
                selectItem.itemPos.Remove(posInfo);
                if (selectItem != null && selectIndex >= 0 && itemObjs[selectIndex] != null)
                {
                    UserLog.RemoveNodeSceneLog(m_allAssetName[selectDataIndex], selectItem.itemID, i);
                    GameObject.DestroyImmediate(itemObjs[selectIndex].itemObj[i]);
                    itemObjs[selectIndex].itemObj.RemoveAt(i);
                }
            }
        }

        if (GUILayout.Button("删除整组"))
        {
            if (selectItem != null)
            {
                SysncDeleteItem(selectItem.itemID, i);
                if (selectItem != null && selectIndex >= 0 && itemObjs[selectIndex] != null)
                {
                    GameObject.DestroyImmediate(itemObjs[selectIndex].itemObj[i]);
                    itemObjs[selectIndex].itemObj.RemoveAt(i);
                }
            }
        }

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();
        EditorGUILayout.LabelField("----------------------------------------------------------------------------------------------------------");
        EditorGUILayout.Space();
    }