public bool Play(string file, OnSitcomComplete onComplete) { if (isPlaying) { return(false); } mSitcomId = -1; onSitcomComplete = onComplete; mSitcomAxis = TimeMgr.single.GetTimeAxis("Sitcom", true); mSitcomAxis.SetParent(TimeMgr.single.realTimeAxis, 0); RunScript(file); return(true); }
public void OnPointerClick(PointerEventData eventData) { Vector2 localPos = Vector2.zero; if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(mRectTran, eventData.position, eventData.pressEventCamera, out localPos)) { return; } localPos.x = 0.5f * mImageW + localPos.x; localPos.y = 0.5f * mImageH + localPos.y; Debug.LogError("===" + eventData.clickCount); if (eventData.clickCount == 2) { //双击 if (eventData.pointerId == -1) { //left button TimeMgr.TimeAxis ta = getPointTimeAxis(localPos); if (ta == null) { return; } mParentTimeAxis = ta; mSelTimeAxis = null; updateView(); } else if (eventData.pointerId == -2) { //right button if (mParentTimeAxis.parent == null) { return; } mParentTimeAxis = mParentTimeAxis.parent; mSelTimeAxis = null; updateView(); } } else if (eventData.clickCount == 1) { TimeMgr.TimeAxis ta = getPointTimeAxis(localPos); if (ta == null || object.ReferenceEquals(mSelTimeAxis, ta)) { return; } mSelTimeAxis = ta; updateView(); } }
TimeMgr.TimeAxis getPointTimeAxis(Vector2 v) { float t = getPointTime(v); int y = (int)v.y + mYOffset; int i = y / BandWidth; List <TimeMgr.TimeAxis> tas = mParentTimeAxis.childs; if (i >= tas.Count) { return(null); } TimeMgr.TimeAxis ta = mParentTimeAxis.childs [i]; if (ta.startTime < t && ta.endTime + mCMTimeUnit > t) { return(ta); } return(null); }
void drawTimeAxis() { mMaxTime = 0; List <TimeMgr.TimeAxis> tas = mParentTimeAxis.childs; for (int i = 0, max = tas.Count; i < max; ++i) { TimeMgr.TimeAxis ta = tas [i]; float startTime = ta.startTime; float endTime = ta.endTime + mCMTimeUnit; if (mMaxTime < endTime) { mMaxTime = endTime; } int x1 = timeToX(startTime); int x2 = timeToX(endTime); if (x2 < 0 || x1 >= mAxisTexture.width) { continue; } bool isSel = object.ReferenceEquals(ta, mSelTimeAxis); drawTimeBand(x1, x2, i * BandWidth - mYOffset, isSel?Color.white:bandColor[i % 5], BandWidth); List <TimeMgr.Action> tes = ta.actions; for (int j = 0, jmax = tes.Count; j < jmax; ++j) { int x = timeToX(startTime + tes [j].doTime); if (x < 0 || x >= mAxisTexture.width) { continue; } drawTimeEvent(x, (int)((1.0f * i + 0.5f) * BandWidth) - mYOffset, Color.black, BandWidth); } } mMaxY = tas.Count * BandWidth; }