Пример #1
0
    private bool NewSetTextureGuidePos(string _key, int _step, string _fullName, float _offX, float _offY, float _offZ, GameObject _srcPrefab, string _texturePath, int _width, int _height, bool isSaveToServer = false, bool _isDel = false)
    {
        if (null == mRootTran)
        {
            return(false);
        }
        UIButton btn = null;

        guideTextureObj = null;

        if (guideTextureObj == null)
        {
            guideTextureObj = (GameObject)Instantiate(_srcPrefab) as GameObject;
            guideTextureObj.transform.parent        = mRootTran.Find(_fullName);
            guideTextureObj.transform.localPosition = new Vector3(_offX, _offY, _offZ);
            guideTextureObj.transform.localScale    = Vector3.one;
            btn = guideTextureObj.GetComponent <UIButton>();
            UIEventListener.Get(btn.gameObject).onClick += OnClickGuideTexture;
        }
        if (btn == null)
        {
            btn = guideTextureObj.GetComponent <UIButton>();
        }

        guideTextureObj.name = _fullName + _key + _step;

        TextureTeachStepInfo teachInfo = new TextureTeachStepInfo();

        teachInfo.teachID      = _key;
        teachInfo.stepID       = _step;
        teachInfo.delObj       = _isDel;
        teachInfo.objName      = guideTextureObj.name;
        teachInfo.saveToserver = isSaveToServer;
        btn.Data = teachInfo;

        UITexture tex = guideTextureObj.GetComponent <UITexture>();

        tex.mainTexture = Resources.Load(_texturePath, typeof(Texture2D)) as Texture2D;
        tex.width       = _width;
        tex.height      = _height;
        bool isHas = false;

        foreach (KeyValuePair <string, GameObject> item in TextureGuideDic)
        {
            if (item.Key == guideTextureObj.name)
            {
                isHas = true;
            }
        }
        if (!isHas)
        {
            TextureGuideDic.Add(guideTextureObj.name, guideTextureObj);
        }
        return(true);
    }
Пример #2
0
    private void OnClickGuideTexture(GameObject obj)
    {
        BoxCollider box = obj.GetComponent <BoxCollider>();

        Destroy(box);
        TextureTeachStepInfo teachInfo = (TextureTeachStepInfo)obj.GetComponent <UIButton>().Data;
        int    curStep  = teachInfo.stepID;
        string key      = teachInfo.teachID;
        int    nextStep = 1;

        if (teachInfo.delObj)
        {
            ClearTextureGuideDic();
        }

        if (curStep == TeachFinishedValue + 1)
        {
            return;
        }
        if (curStep == TeachFinishedValue)
        {
            curStep  = TeachFinishedValue - 1;
            nextStep = TeachFinishedValue;
        }
        else if (curStep == TeachXunHuanValue)
        {
            NewWriteSaveData(key, 0);
            return;
        }
        else
        {
            nextStep = curStep + 1;
        }

        if (nextStep == 0 || curStep == 0)
        {
            return;
        }

        if (nextStep > curStep)
        {
            NewWriteSaveData(key, nextStep, teachInfo.saveToserver);
            NewRefreshAllTeach();
        }
    }