void OnEnable()
 {
     m_Tweens       = serializedObject.FindProperty("m_Tweens");
     m_ScriptTarget = (EasyTween)target;
     EnforceListLengths();
 }
Пример #2
0
 void OnEnable()
 {
     m_ScriptTarget = (EasyTween)target;
     EnforceListLengths();
 }
Пример #3
0
        private void ConfigureTargetValue(ref EasyTween.EasyTweenSubObject subObject, int tweenIndex, int subIndex)
        {
            string[] subStrings = { "" };

            if (subObject.variableType == "Int32" || subObject.variableType == "Single")
            {
                subStrings = new[] { "value" };
            }
            if (subObject.variableType == "Vector2")
            {
                subStrings = new[] { "X", "Y" };
            }
            if (subObject.variableType == "Vector3")
            {
                subStrings = new[] { "X", "Y", "Z" };
            }
            if (subObject.variableType == "Vector4")
            {
                subStrings = new[] { "X", "Y", "Z", "W" };
            }
            if (subObject.variableType == "Rect")
            {
                subStrings = new[] { "X", "Y", "Width", "Height" };
            }
            if (subObject.variableType == "Color")
            {
                subStrings = new[] { "R", "G", "B", "A" };
            }

            EditorGUILayout.Space();

			using (new GUILayout.HorizontalScope())
			{
				EditorGUILayout.LabelField("Target values", GUILayout.Width(CalcWidth("TargetValues") + 8f));
			}
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Copy from gameObject", GUILayout.Width(CalcWidth("Copy from gameObject") + 8f)))
            {
                object theValue;

                if (subObject.isProperty)
                {
					Component component = m_ScriptTarget.GetComponent<EasyTween>().tweens[tweenIndex].targetGameObject.GetComponent(
						m_ScriptTarget.GetComponent<EasyTween>().tweens[tweenIndex].subTweens[subIndex].targetComponentName);

                    string variableName =
						m_ScriptTarget.GetComponent<EasyTween>().tweens[tweenIndex].subTweens[subIndex].targetVariableName;

                    theValue = component.GetType().GetProperty(variableName).GetValue(component, null);
                }
                else
                {
					Component component = m_ScriptTarget.GetComponent<EasyTween>().tweens[tweenIndex].targetGameObject.GetComponent(
						m_ScriptTarget.GetComponent<EasyTween>().tweens[tweenIndex].subTweens[subIndex].targetComponentName);

                    string variableName =
						m_ScriptTarget.GetComponent<EasyTween>().tweens[tweenIndex].subTweens[subIndex].targetVariableName;

                    theValue = component.GetType().GetField(variableName).GetValue(component);
                }

                subObject.targetValue = ObjectToVector4(subObject.variableType, theValue);
            }

            if (GUILayout.Button("Apply to gameObject", GUILayout.Width(CalcWidth("Apply to gameObject") + 8f)))
            {
                if (subObject.isProperty)
                {
					Component component = m_ScriptTarget.GetComponent<EasyTween>().tweens[tweenIndex].targetGameObject.GetComponent(
						m_ScriptTarget.GetComponent<EasyTween>().tweens[tweenIndex].subTweens[subIndex].targetComponentName);

                    string variableName =
						m_ScriptTarget.GetComponent<EasyTween>().tweens[tweenIndex].subTweens[subIndex].targetVariableName;

                    component.GetType().GetProperty(variableName).SetValue(component, Vector4ToObject(subObject.variableType, subObject.targetValue), null);
                }
                else
                {
					Component component = m_ScriptTarget.GetComponent<EasyTween>().tweens[tweenIndex].targetGameObject.GetComponent(
						m_ScriptTarget.GetComponent<EasyTween>().tweens[tweenIndex].subTweens[subIndex].targetComponentName);

                    string variableName =
						m_ScriptTarget.GetComponent<EasyTween>().tweens[tweenIndex].subTweens[subIndex].targetVariableName;

                    component.GetType().GetField(variableName).SetValue(component, Vector4ToObject(subObject.variableType, subObject.targetValue));
                }
            }

            for (int i = 0; i < subObject.targetValueLength; i++)
            {
				using (new GUILayout.HorizontalScope())
				{
					subObject.modifyParameters[i] = GUILayout.Toggle(subObject.modifyParameters[i], "Tween " + subStrings[i]);
					
					if (subObject.modifyParameters[i])
					{
						subObject.targetValue[i] = EditorGUILayout.FloatField(subObject.targetValue[i]);
					}
				}
            }
        }
Пример #4
0
        private void AddSubTweener(EasyTween.EasyTweenObject tweenObject)
        {
			tweenObject.subTweens.Add(new EasyTween.EasyTweenSubObject());
        }
Пример #5
0
        private void ConfgureSubObject(ref EasyTween.EasyTweenSubObject subObject, int tweenIndex, int subIndex)
        {
			using (new GUILayout.HorizontalScope())
			{
				GUILayout.Label("Variable");
				
				if (GUILayout.Button(subObject.targetComponentName + "/" + subObject.targetVariableName, GUI.skin.GetStyle("Popup")))
				{
					m_TempTweenIndex = tweenIndex;
					m_TempSubTweenIndex = subIndex;
					VariableMenu(m_ScriptTarget.tweens[m_TempTweenIndex].targetGameObject, m_ScriptTarget.tweens[m_TempTweenIndex]).ShowAsContext();
					return;
				}
				
				if (m_ScriptTarget.tweens[tweenIndex].subTweens.Count > 1)
				{
					if (GUILayout.Button("-", GUILayout.Width(CalcWidth("-") + 8f), GUILayout.Height(18f)))
					{
						RemoveSubTweener(tweenIndex, subIndex);
					}
				}
			}

            if (subObject.targetComponent != null)
            {
                ConfigureTargetValue(ref subObject, tweenIndex, subIndex);
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
        }
Пример #6
0
 void OnEnable()
 {
     m_ScriptTarget = (EasyTween)target;
     EnforceListLengths();
 }
Пример #7
0
        private void ConfigureTweenObject(ref EasyTween.EasyTweenObject tweenObject, int tweenIndex)
        {
			using (new GUILayout.HorizontalScope())
			{
				tweenObject.optionsVisible = EditorGUILayout.Foldout(tweenObject.optionsVisible, tweenObject.tag);
				if (tweenIndex == 0)
				{
					if (GUILayout.Button("+", GUILayout.Width(CalcWidth("+") + 8f)))
					{
						AddTweener();
					}
				}
				if (m_ScriptTarget.tweens.Count > 1)
				{
					if (GUILayout.Button("-", GUILayout.Width(CalcWidth("-") + 8f)))
					{
						RemoveTweener(tweenIndex);
					}
				}
			}

            if (tweenObject.optionsVisible)
            {
				using (new GUILayout.VerticalScope("Box"))
				{
					tweenObject.tag = EditorGUILayout.TextField("Tag", tweenObject.tag);
					
					using (new GUILayout.HorizontalScope ())
					{
						tweenObject.targetGameObject = (GameObject)EditorGUILayout.ObjectField("Target GameObject", tweenObject.targetGameObject, typeof(GameObject), true);
						
						m_TempString = "This";
						if (GUILayout.Button(m_TempString, GUILayout.Width(CalcWidth(m_TempString) + 8f)))
						{
							tweenObject.targetGameObject = m_ScriptTarget.gameObject;
						}
					}
					
					tweenObject.tweenType = (Tween.TweenType)EditorGUILayout.EnumPopup("Tween type", tweenObject.tweenType);
					
					if (tweenObject.tweenType == Tween.TweenType.Custom)
					{
						tweenObject.customCurve = EditorGUILayout.CurveField(tweenObject.customCurve);
						
						if (tweenObject.customCurve.keys[0].time != 0f || tweenObject.customCurve.keys[tweenObject.customCurve.keys.Length - 1].time != 1f)
						{
							tweenObject.customCurve = new AnimationCurve(new[] { new Keyframe(0f, 0f), new Keyframe(1f, 1f) });
						}
						
					}
					
					tweenObject.duration = EditorGUILayout.FloatField("Duration", tweenObject.duration);
					
					tweenObject.delay = EditorGUILayout.FloatField("Delay", tweenObject.delay);
					
					tweenObject.tweenOnStart = EditorGUILayout.Toggle("Tween on Start", tweenObject.tweenOnStart);
					
					tweenObject.hasCallback = EditorGUILayout.Toggle("Call method when done", tweenObject.hasCallback);
					
					using (new GUILayout.HorizontalScope())
					{
						if (tweenObject.hasCallback)
						{
							tweenObject.callbackGameObject =
								(GameObject)EditorGUILayout.ObjectField("GameObject", tweenObject.callbackGameObject, typeof(GameObject), true);
						}
					}
					
					if (tweenObject.hasCallback && tweenObject.callbackGameObject != null)
					{
						using (new GUILayout.HorizontalScope())
						{
							if (tweenObject.hasCallback)
							{
								GUILayout.Label("Method");
								if (GUILayout.Button(tweenObject.callbackComponentName + "/" + tweenObject.callbackName, GUI.skin.GetStyle("Popup")))
								{
									m_TempTweenIndex = tweenIndex;
									MethodMenu(tweenObject).ShowAsContext();
									return;
								}
							}
						}
					}
					
					EditorGUILayout.Space();
					
					if (tweenObject.targetGameObject)
					{
						using (new GUILayout.HorizontalScope())
						{
							tweenObject.subOptionsVisible = EditorGUILayout.Foldout(tweenObject.subOptionsVisible,
								tweenObject.tag + " Subtweens");
							
							if (tweenObject.subOptionsVisible)
							{
								if (GUILayout.Button("+", GUILayout.Width(CalcWidth("+") + 8f)))
								{
									AddSubTweener(tweenObject);
								}
							}
						}
						
						if (tweenObject.subOptionsVisible)
						{
							for (int i = 0; i < tweenObject.subTweens.Count; i++)
							{
								EasyTween.EasyTweenSubObject subObject = tweenObject.subTweens[i];
								
								using (new GUILayout.VerticalScope("Box"))
								{
									ConfgureSubObject(ref subObject, tweenIndex, i);
								}
							}
						}
					}
				}
                EditorGUILayout.Space();
                EditorGUILayout.Space();
            }
        }
Пример #8
0
        private GenericMenu MethodMenu(EasyTween.EasyTweenObject tweenObject)
        {
            GenericMenu thisMenu = new GenericMenu();
            string[] componentStrings = FindComponentStrings(tweenObject.callbackGameObject);

            for (int i = 0; i < componentStrings.Length; i++)
            {
                string[] methodStrings = FindMethodStrings(tweenObject.callbackGameObject, componentStrings[i]);

                for (int j = 0; j < methodStrings.Length; j++)
                {
                    thisMenu.AddItem(new GUIContent(componentStrings[i] + "/" + methodStrings[j]), false, MethodMenuCallback, (object)componentStrings[i] + "/" + methodStrings[j]);
                }
            }

            return thisMenu;
        }
Пример #9
0
        private GenericMenu VariableMenu(GameObject targetGameObject, EasyTween.EasyTweenObject tweenObject)
        {
            GenericMenu thisMenu = new GenericMenu();
            string[] componentStrings = FindComponentStrings(targetGameObject);

            for (int i = 0; i < componentStrings.Length; i++)
            {
                string[] variableStrings = FindVariableStrings(targetGameObject, componentStrings[i]);

                for (int j = 0; j < variableStrings.Length; j++)
                {
                    thisMenu.AddItem(new GUIContent(componentStrings[i] + "/" + variableStrings[j]), false, VariableMenuCallback, (object)componentStrings[i] + "/" + variableStrings[j]);
                }
            }

            return thisMenu;
        }