Exemplo n.º 1
0
    public void EditOrReviewStepDetail(StepDetail detailAction)
    {
        if (detailPanel != null)
        {
            Destroy(detailPanel);
        }

        detailPanel = (GameObject)Instantiate(stepDetailPanel);

        detailPanel.transform.SetParent(selectionPanel.transform);
        //detailPanel.transform.position = new Vector3(0, 0, 0);
        detailPanel.GetComponent <RectTransform>().offsetMin = new Vector2(0, 0); //left bottom
        detailPanel.GetComponent <RectTransform>().offsetMax = new Vector2(0, 0); //right top
        detailPanel.transform.localScale = new Vector3(1f, 1f, 1f);

        detailPanel.name = "StepDetailPanel";
        stepDetailPAnel panelscript = detailPanel.GetComponent <stepDetailPAnel>();

        panelscript.Setup(this);
        panelscript.detailIntro.text = detailAction.stepDetailInfo;

        panelscript.scrollView.GetComponent <DetailStepScrollview>().storeData = storedData;

        createOperatorOnMap();

        storedData.isUpdated = true;
    }
Exemplo n.º 2
0
    public void AddSteps()
    {
        if (detailPanel != null)
        {
            Destroy(detailPanel);
        }

        detailPanel     = (GameObject)Instantiate(stepDetailPanel);
        IndetailActions = true;
        detailPanel.transform.SetParent(selectionPanel.transform);
        //detailPanel.transform.position = new Vector3(0,0,0);
        detailPanel.GetComponent <RectTransform>().offsetMin = new Vector2(0, 0); //left bottom
        detailPanel.GetComponent <RectTransform>().offsetMax = new Vector2(0, 0); //right top
        detailPanel.transform.localScale = new Vector3(1f, 1f, 1f);
        detailPanel.name = "StepDetailPanel";
        stepDetailPAnel panelscript = detailPanel.GetComponent <stepDetailPAnel>();

        panelscript.Setup(this);
        StepDetail newDetail = new StepDetail();

        storedData.newStrategy.steps.Add(newDetail);
        storedData.chosenStepIndex = storedData.newStrategy.steps.Count - 1;
        newDetail.stepIndex        = storedData.newStrategy.steps.Count - 1;
        cancelDetailBtn.SetActive(true);
        //Debug.Log(panel.transform.position);
    }
Exemplo n.º 3
0
    //private void LoadByIO()
    //{

    //    //double startTime = (double)Time.time;
    //    //创建文件读取流
    //    FileStream fileStream = new FileStream(Application.persistentDataPath + "/CaptureScreenshot.png", FileMode.Open, FileAccess.Read);
    //    fileStream.Seek(0, SeekOrigin.Begin);
    //    //创建文件长度缓冲区
    //    byte[] bytes = new byte[fileStream.Length];
    //    //读取文件
    //    fileStream.Read(bytes, 0, (int)fileStream.Length);
    //    //释放文件读取流
    //    fileStream.Close();
    //    fileStream.Dispose();
    //    fileStream = null;

    //    //创建Texture
    //  Texture2D texture = new Texture2D(Screen.width, Screen.height);
    //texture.LoadImage(bytes);

    //    //创建Sprite


    //    //startTime = (double)Time.time - startTime;
    //    //Debug.Log("IO加载用时:" + startTime);
    //}



    // Update is called once per frame
    void Update()
    {
        //if (EventSystem.current.IsPointerOverGameObject())
        //{
        //    Debug.Log("当前触摸在UI上");
        //    return;

        //}

        if (fileSaved)
        {
            fileSaved = false;
            CommonData storeData = GetComponent <CommonData>();

            StepDetailAction action = new StepDetailAction();
            action.createTime   = System.DateTime.Now.ToString();
            action.imageType    = true;
            action.actionInfo   = descText.text;
            action.stepImageUrl = tempFile.Url.ToString();
            action.actionType   = "Image";
            action.parentFloor  = "10";
            StepDetail detail = storeData.newStrategy.steps[storeData.chosenStepIndex];
            if (detail.detailActions != null)
            {
                detail.detailActions.Add(action);
            }
            else
            {
                detail.detailActions = new List <StepDetailAction>();
                detail.detailActions.Add(action);
            }



            stepDetailPAnel panelScript = GetComponent <CommonControl>().detailPanel.GetComponent <stepDetailPAnel>();
            panelScript.scrollView.GetComponent <DetailStepScrollview>().storeData = storeData;
            storeData.isUpdated = true;
        }



        if (GetComponent <CommonControl>().canDrawLine)
        {
            if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
            {
                if (Input.touchCount == 1)
                {
                    Touch touch = Input.touches[0];
                    if (touch.phase == TouchPhase.Began)
                    {
                        clone = (GameObject)Instantiate(lineObj, lineObj.transform.position, Quaternion.identity);
                        lineArray.Add(clone);
                        //获得该物体上的LineRender组件
                        line = clone.GetComponent <LineRenderer>();
                        //设置起始和结束的颜色
                        line.startColor = Color.red;

                        line.endColor = Color.red;
                        //设置起始和结束的宽度
                        line.startWidth = .2f;
                        line.endWidth   = .2f;
                        //计数
                        i = 0;
                    }

                    if (touch.phase == TouchPhase.Moved)
                    {
                        i++;
                        //设置顶点数
                        line.positionCount = i;
                        //设置顶点位置(顶点的索引,将鼠标点击的屏幕坐标转换为世界坐标)
                        line.SetPosition(i - 1, Camera.main.ScreenToWorldPoint(new Vector3(touch.position.x, touch.position.y, 15)));
                    }
                }
            }
            else
            {
                if (Input.GetMouseButtonDown(0))
                {
                    //实例化对象
                    clone = (GameObject)Instantiate(lineObj, lineObj.transform.position, Quaternion.identity);
                    lineArray.Add(clone);
                    //获得该物体上的LineRender组件
                    line = clone.GetComponent <LineRenderer>();
                    //设置起始和结束的颜色
                    line.startColor = Color.red;

                    line.endColor = Color.red;
                    //设置起始和结束的宽度
                    line.startWidth = .2f;
                    line.endWidth   = .2f;
                    //计数
                    i = 0;
                }
                if (Input.GetMouseButton(0))
                {
                    //每一帧检测,按下鼠标的时间越长,计数越多
                    i++;
                    //设置顶点数
                    line.positionCount = i;
                    //设置顶点位置(顶点的索引,将鼠标点击的屏幕坐标转换为世界坐标)
                    line.SetPosition(i - 1, Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 15)));
                }
            }
        }
    }
Exemplo n.º 4
0
    public void buttonClicked(GameObject btnObj)
    {
        if (DataObj.isDp)
        {
            ExitGames.Client.Photon.Hashtable h = new ExitGames.Client.Photon.Hashtable();
            h.Add("operator", btnObj.name);
            DataObj.lbc.LocalPlayer.SetCustomProperties(h);

            gameObject.SetActive(false);
            return;
        }

        controlScript.canAddOperation = false;

        OperatorObj operatorobj = new OperatorObj();

        foreach (OperatorObj op in operators)
        {
            if (op.name.Equals(btnObj.name))
            {
                operatorobj = op;
            }
        }


        GameObject cube1 = (GameObject)Instantiate(operatorobj.operatorPrefab);

        ghostObjInstance = Instantiate(cube1, cube1.transform.position, Quaternion.identity).GetComponent <Transform>();
        ghostObjInstance.transform.localScale *= controlScript.scaleChange;
        Debug.Log(controlScript.scaleChange);
        Vector3 pivotOffsetExtra;
        bool    objPivotIsBase = controlScript.isPivotInBase(ghostObjInstance, out pivotOffsetExtra);

        if (!objPivotIsBase)
        {
            ghostObjInstance = controlScript.CreateBasePivot(ghostObjInstance, pivotOffsetExtra);
        }
        Vector3 pos = rayhit.point;

        ghostObjInstance.position = pos;

        controlScript.AlignGhostToSurface(ghostObjInstance, rayhit.normal);

        ghostObjInstance = ghostObjInstance.GetComponent <PivotHelper>().DeletePivot();

        GameObject cube = Instantiate(operatorobj.operatorPrefab, ghostObjInstance.position, ghostObjInstance.rotation);

        Destroy(ghostObjInstance.gameObject);
        Destroy(cube1);
        cube.transform.SetParent(hitobject.transform);
        cube.transform.rotation = hitobject.transform.rotation;
        //cube.transform.localScale = new Vector3(0.012f, 0.012f, 0.012f);
        cube.transform.localScale *= controlScript.scaleChange;

        string currentFloor = controlScript.gameObject.GetComponent <MapObj>().currentFloorName;

        StepDetailAction action = new StepDetailAction(cube.transform, "Operator", currentFloor, hitobject.name);

        action.createTime = System.DateTime.Now.ToString();
        action.actionName = operatorobj.name;
        CommonData storeData = controlScript.gameObject.GetComponent <CommonData>();
        StepDetail detail    = storeData.newStrategy.steps[storeData.chosenStepIndex];

        if (detail.detailActions != null)
        {
            detail.detailActions.Add(action);
        }
        else
        {
            detail.detailActions = new List <StepDetailAction>();
            detail.detailActions.Add(action);
        }

        OperatorData cubeData = cube.GetComponent <OperatorData>();

        cubeData.createTime  = action.createTime;
        cubeData.actionName  = operatorobj.name;
        cubeData.parentFloor = currentFloor;
        cubeData.actionType  = "Operator";

        stepDetailPAnel panelScript = controlScript.detailPanel.GetComponent <stepDetailPAnel>();

        panelScript.scrollView.GetComponent <DetailStepScrollview>().storeData = storeData;

        storeData.Operators.Add(cube);


        Debug.Log(JsonUtility.ToJson(storeData));
        storeData.isUpdated = true;

        //controlScript.alreadyHavepoint = false;
        this.gameObject.SetActive(false);
    }