Esempio n. 1
0
    public override void OnInspectorGUI()
    {
        BCEditorTools.SetLabelWidth(95f);
        _target.randMaker = (BCRandomMaker)EditorGUILayout.ObjectField("Random Maker", _target.randMaker, typeof(BCRandomMaker));
        GUILayout.Space(5f);
        _target.durationRule = (BCTweenRandTrigger.TweenTimeRule)EditorGUILayout.EnumPopup("Duration", _target.durationRule);
        if (_target.durationRule == BCTweenRandTrigger.TweenTimeRule.ConstValue)
        {
            _target.duration = EditorGUILayout.FloatField("-> value", _target.duration);
        }
        else
        {
            _target.ruleTagDuration = EditorGUILayout.TextField("-> Tag", _target.ruleTagDuration);
        }
        _target.delayRule = (BCTweenRandTrigger.TweenTimeRule)EditorGUILayout.EnumPopup("Start Delay", _target.delayRule);
        if (_target.delayRule == BCTweenRandTrigger.TweenTimeRule.ConstValue)
        {
            _target.delay = EditorGUILayout.FloatField("-> value", _target.delay);
        }
        else
        {
            _target.ruleTagDelay = EditorGUILayout.TextField("-> Tag", _target.ruleTagDelay);
        }
        GUILayout.Space(5f);

        if (BCEditorTools.DrawHeader("Tween Transfrom"))
        {
            BCEditorTools.BeginContents();
            BCEditorTools.SetLabelWidth(110f);


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("From", GUILayout.Width(40));
            BCEditorTools.BeginContents();
            EditorGUILayout.BeginVertical();
            _target.from_rule[0] = (BCTweenRandTrigger.TweenFromRule)EditorGUILayout.EnumPopup(_target.from_rule[0]);
            if (_target.from_rule[0] == BCTweenRandTrigger.TweenFromRule.ConstValue)
            {
                _target.from.x = EditorGUILayout.FloatField(_target.from.x);
            }
            else if (_target.from_rule[0] == BCTweenRandTrigger.TweenFromRule.RandValue)
            {
                BCEditorTools.SetLabelWidth(30f);
                _target.ruleTagFrom[0] = EditorGUILayout.TextField("Tag", _target.ruleTagFrom[0]);
                BCEditorTools.SetLabelWidth(110f);
            }
            EditorGUILayout.EndVertical();
            BCEditorTools.EndContents();
            BCEditorTools.BeginContents();
            EditorGUILayout.BeginVertical();
            _target.from_rule[1] = (BCTweenRandTrigger.TweenFromRule)EditorGUILayout.EnumPopup(_target.from_rule[1]);
            if (_target.from_rule[1] == BCTweenRandTrigger.TweenFromRule.ConstValue)
            {
                _target.from.y = EditorGUILayout.FloatField(_target.from.y);
            }
            else if (_target.from_rule[1] == BCTweenRandTrigger.TweenFromRule.RandValue)
            {
                BCEditorTools.SetLabelWidth(30f);
                _target.ruleTagFrom[1] = EditorGUILayout.TextField("Tag", _target.ruleTagFrom[1]);
                BCEditorTools.SetLabelWidth(110f);
            }
            EditorGUILayout.EndVertical();
            BCEditorTools.EndContents();
            BCEditorTools.BeginContents();
            EditorGUILayout.BeginVertical();
            _target.from_rule[2] = (BCTweenRandTrigger.TweenFromRule)EditorGUILayout.EnumPopup(_target.from_rule[2]);
            if (_target.from_rule[2] == BCTweenRandTrigger.TweenFromRule.ConstValue)
            {
                _target.from.z = EditorGUILayout.FloatField(_target.from.z);
            }
            else if (_target.from_rule[2] == BCTweenRandTrigger.TweenFromRule.RandValue)
            {
                BCEditorTools.SetLabelWidth(30f);
                _target.ruleTagFrom[2] = EditorGUILayout.TextField("Tag", _target.ruleTagFrom[2]);
                BCEditorTools.SetLabelWidth(110f);
            }
            EditorGUILayout.EndVertical();
            BCEditorTools.EndContents();
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(10);
            //----------------------------------------------------------
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("To", GUILayout.Width(40));
            BCEditorTools.BeginContents();
            EditorGUILayout.BeginVertical();
            _target.to_rule[0] = (BCTweenRandTrigger.TweenToRule)EditorGUILayout.EnumPopup(_target.to_rule[0]);
            if (_target.to_rule[0] == BCTweenRandTrigger.TweenToRule.ConstValue)
            {
                _target.to.x = EditorGUILayout.FloatField(_target.to.x);
            }
            else
            {
                BCEditorTools.SetLabelWidth(30f);
                _target.ruleTagTo[0] = EditorGUILayout.TextField("Tag", _target.ruleTagTo[0]);
                BCEditorTools.SetLabelWidth(110f);
            }
            EditorGUILayout.EndVertical();
            BCEditorTools.EndContents();
            BCEditorTools.BeginContents();
            EditorGUILayout.BeginVertical();
            _target.to_rule[1] = (BCTweenRandTrigger.TweenToRule)EditorGUILayout.EnumPopup(_target.to_rule[1]);
            if (_target.to_rule[1] == BCTweenRandTrigger.TweenToRule.ConstValue)
            {
                _target.to.y = EditorGUILayout.FloatField(_target.to.y);
            }
            else
            {
                BCEditorTools.SetLabelWidth(30f);
                _target.ruleTagTo[1] = EditorGUILayout.TextField("Tag", _target.ruleTagTo[1]);
                BCEditorTools.SetLabelWidth(110f);
            }
            EditorGUILayout.EndVertical();
            BCEditorTools.EndContents();
            BCEditorTools.BeginContents();
            EditorGUILayout.BeginVertical();
            _target.to_rule[2] = (BCTweenRandTrigger.TweenToRule)EditorGUILayout.EnumPopup(_target.to_rule[2]);
            if (_target.to_rule[2] == BCTweenRandTrigger.TweenToRule.ConstValue)
            {
                _target.to.z = EditorGUILayout.FloatField(_target.to.z);
            }
            else
            {
                BCEditorTools.SetLabelWidth(30f);
                _target.ruleTagTo[2] = EditorGUILayout.TextField("Tag", _target.ruleTagTo[2]);
                BCEditorTools.SetLabelWidth(110f);
            }
            EditorGUILayout.EndVertical();
            BCEditorTools.EndContents();
            EditorGUILayout.EndHorizontal();

            BCEditorTools.EndContents();
        }
    }
    protected void DrawCommonProperties()
    {
        if (null == tw || null == onFinished || null == onWePointed1)
        {
            init();
        }

        if (Application.isPlaying)
        {
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("PlayForward"))
            {
                tw.PlayForward();
            }
            if (GUILayout.Button("PlayReverse"))
            {
                tw.PlayReverse();
            }
            if (GUILayout.Button("PlayForwardForce"))
            {
                tw.PlayForwardForce();
            }
            if (GUILayout.Button("PlayReverseForce"))
            {
                tw.PlayReverseForce();
            }
            if (GUILayout.Button("Stop"))
            {
                tw.Stop();
            }
            EditorGUILayout.EndHorizontal();
        }
        else
        {
            EditorGUILayout.HelpBox("Some buttons will appear when running.", MessageType.Info);
        }

        if (BCEditorTools.DrawHeader("Tweener"))
        {
            BCEditorTools.BeginContents();
            BCEditorTools.SetLabelWidth(110f);

            GUI.changed = false;

            BCUITweener.Style style = (BCUITweener.Style)EditorGUILayout.EnumPopup("Play Style", tw.style);

            if (style == BCUITweener.Style.Once)
            {
                GUILayout.BeginHorizontal();
                GUI.color = Color.white;
                GUILayout.EndHorizontal();
            }

            AnimationCurve curve = EditorGUILayout.CurveField("Animation Curve", tw.animationCurve, GUILayout.Width(170f), GUILayout.Height(62f));
            //UITweener.Method method = (UITweener.Method)EditorGUILayout.EnumPopup("Play Method", tw.method);

            GUILayout.BeginHorizontal();
            float dur = EditorGUILayout.FloatField("Duration", tw.duration, GUILayout.Width(170f));
            GUILayout.Label("seconds");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            float del = EditorGUILayout.FloatField("Start Delay", tw.delay, GUILayout.Width(170f));
            GUILayout.Label("seconds");
            GUILayout.EndHorizontal();

            //int tg = EditorGUILayout.IntField("Tween Group", tw.tweenGroup, GUILayout.Width(170f));
            bool ts = EditorGUILayout.Toggle("Ignore TimeScale", tw.ignoreTimeScale);

            if (GUI.changed)
            {
                BCEditorTools.RegisterUndo("Tween Change", tw);
                tw.animationCurve = curve;
                //tw.method = method;
                tw.style           = style;
                tw.ignoreTimeScale = ts;
                //tw.tweenGroup = tg;
                tw.duration = dur;
                tw.delay    = del;
                BCEditorTools.SetDirty(tw);
                GUI.changed = false;
            }
            BCEditorTools.EndContents();
        }

        BCEditorTools.SetLabelWidth(80f);
        serializedObject.Update();
        EditorGUILayout.PropertyField(onFinished);


        BCEditorTools.SetLabelWidth(120f);
        tw.EventPointsCount = EditorGUILayout.IntPopup("Events We Point", tw.EventPointsCount, chooseNumStr, chooseNum);
        if (tw.EventPointsCount > 0)
        {
            tw.tWePoint[0] = EditorGUILayout.Slider("Time We Point 1", tw.tWePoint[0], 0f, 1f);
            BCEditorTools.SetLabelWidth(80f);
            EditorGUILayout.PropertyField(onWePointed1);
        }
        BCEditorTools.SetLabelWidth(120f);
        if (tw.EventPointsCount > 1)
        {
            tw.tWePoint[1] = EditorGUILayout.Slider("Time We Point 2", tw.tWePoint[1], 0f, 1f);
            BCEditorTools.SetLabelWidth(80f);
            EditorGUILayout.PropertyField(onWePointed2);
        }
        BCEditorTools.SetLabelWidth(120f);
        if (tw.EventPointsCount > 2)
        {
            tw.tWePoint[2] = EditorGUILayout.Slider("Time We Point 3", tw.tWePoint[2], 0f, 1f);
            BCEditorTools.SetLabelWidth(80f);
            EditorGUILayout.PropertyField(onWePointed3);
        }
        serializedObject.ApplyModifiedProperties();
    }