void Awake() { SpriteRenderer spriteRenderer = gameObject.GetComponent <SpriteRenderer>(); lr = new GameObject("line").AddComponent <LineRenderer>(); sortingLayer = spriteRenderer.sortingLayerID; if (orderInLayer == -1) { orderInLayer = spriteRenderer.sortingOrder + 1; } sliceManager = gameObject.GetComponent <SliceManager>(); }
// Use this for initialization public void InstantiateSpriteObj() { spriteSliceObj = GameObject.Instantiate(spriteObj); spriteSliceObj.transform.localScale = Vector3.one * 1.1f; spriteSliceObj.transform.localPosition = Vector3.zero + Vector3.one * 0.1f; MiaoKids.SliceManager spriteSliceManager = spriteSliceObj.GetComponent <MiaoKids.SliceManager>(); spriteSliceManager.onStartSlice.AddListener(() => { Debug.Log("start slice"); }); spriteSliceManager.onEndSlice.AddListener((GameObject go1, GameObject go2, GameObject line) => { Debug.Log("end slice"); Debug.LogFormat("go1 是否是三角形 {0}", MiaoKids.JudgeFigure.IsTargetFigure(go1, MiaoKids.FigureType.triangle)); Debug.LogFormat("go2 是否是三角形 {0}", MiaoKids.JudgeFigure.IsTargetFigure(go2, MiaoKids.FigureType.triangle)); StartCoroutine(OnSliceEnd(go1, go2, line)); }); }