Exemple #1
0
 public void CopyFrom(ActionObject src)
 {
     // mName = src.mName;
     mTotalTime = src.mTotalTime;
     mEvents    = new List <ActionEvent>();
     foreach (ActionEvent ev in src.mEvents)
     {
         ActionEvent dest = (ActionEvent)ev.Clone();
         dest.SetActionObject(this);
         mEvents.Add(dest);
     }
 }
Exemple #2
0
    public void Read(BinaryReader br)
    {
        // mName = br.ReadString();
        mTotalTime = br.ReadSingle();
        int count = br.ReadInt32();

        mEvents.Clear();
        for (int i = 0; i < count; i++)
        {
            ActionObject.ActionType actioinType = (ActionObject.ActionType)br.ReadInt32();
            ActionEvent             ev          = ActionFactory.CreateActionEvent(actioinType);
            if (ev != null)
            {
                ev.SetActionObject(this);
                ev.Read(br);
                mEvents.Add(ev);
            }
        }
    }
Exemple #3
0
    public void Draw(ActionTable actable)
    {
        GUILayout.BeginVertical();
        TimeLine();
        for (int i = 0; i < mEvents.Count; i++)
        {
            float rate = mEvents[i].mTime / mTotalTime;
            TimeLine(rate, Color.red);
        }
        if (mCurrentEvent != null)
        {
            float rate = mCurrentEvent.mTime / mTotalTime;
            TimeLine(rate, Color.blue);
        }
        mTotalTimelineBGTex.Apply();
        GUILayout.Label(mTotalTimelineBGTex);

        GUILayout.BeginHorizontal();
        GUILayout.Label("============== Action =================");
        GUILayout.EndHorizontal();

        {
            GUILayout.BeginHorizontal();

            GUILayout.BeginHorizontal();
            // this.mName = EditorGUILayout.TextField("Name",this.mName);
            this.mTotalTime  = EditorGUILayout.FloatField("Total Time", this.mTotalTime);
            mActionEventType = (ActionObject.ActionType)EditorGUILayout.EnumPopup("Event Type", mActionEventType);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Change Event"))
            {
                if (mCurrentEventIndex >= 0 && mCurrentEventIndex < mEvents.Count)
                {
                    ActionEvent ev = ActionFactory.CreateActionEvent(mActionEventType);
                    if (ev != null)
                    {
                        ev.SetActionObject(this);
                        this.mEvents[mCurrentEventIndex] = ev;
                        this.mCurrentEvent = ev;
                    }
                }
            }
            if (GUILayout.Button("Add Event"))
            {
                ActionEvent ev = ActionFactory.CreateActionEvent(mActionEventType);
                if (ev != null)
                {
                    ev.SetActionObject(this);
                    mCurrentEvent      = ev;
                    mCurrentEventIndex = mEvents.Count;
                    this.mEvents.Add(ev);
                }
            }
            if (GUILayout.Button("Delete Event"))
            {
                if (EditorUtility.DisplayDialog("Remove Event", "Are you sure to remove Event?", "Remove", "Cancel"))
                {
                    if (mCurrentEvent != null)
                    {
                        mEvents.Remove(mCurrentEvent);
                        mCurrentEvent      = null;
                        mCurrentEventIndex = -1;
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.EndHorizontal();
        }
        {
            GUILayout.BeginHorizontal();
            for (int i = 0; i < mEvents.Count; i++)
            {
                ActionEvent ev = this.mEvents[i];
                // ev.Draw(this);
                if (GUILayout.Button("" + i))
                {
                    mCurrentEvent      = ev;
                    mCurrentEventIndex = i;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginVertical();
            if (mCurrentEvent != null)
            {
                GUILayout.Label("============== Event " + mCurrentEventIndex + " =================");
                mCurrentEvent.Draw(this);
            }
            GUILayout.EndVertical();
        }
        GUILayout.EndVertical();
    }