Ejemplo n.º 1
0
        private static bool IsValidTargetForRequiredComponent(SerializedProperty targetSerializedProperty, SerializedProperty actionSerializedProperty)
        {
            if (targetSerializedProperty.objectReferenceValue == null)
            {
                return(false);
            }

            Type type = actionSerializedProperty.GetTypeFromManagedFullTypeName();

            return(DOTweenActionEditorGUIUtility.CanActionBeAppliedToTarget(type, targetSerializedProperty.objectReferenceValue as GameObject));
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            float originY = position.y;

            Type type = property.GetTypeFromManagedFullTypeName();

            GUIContent displayName = DOTweenActionEditorGUIUtility.GetTypeDisplayName(type);

            position.x     += 10;
            position.width -= 20;

            EditorGUI.BeginProperty(position, GUIContent.none, property);

            float startingYPosition = position.y;

            EditorGUI.LabelField(position, displayName, EditorStyles.boldLabel);

            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

            foreach (SerializedProperty serializedProperty in property.GetChildren())
            {
                Rect propertyRect = position;
                EditorGUI.PropertyField(propertyRect, serializedProperty, true);

                position.y += EditorGUI.GetPropertyHeight(serializedProperty, true);
            }

            position.x     -= 10;
            position.width += 10;

            Rect boxPosition = position;

            boxPosition.y      = startingYPosition - 10;
            boxPosition.height = (position.y - startingYPosition) + 20;
            boxPosition.width += 20;
            GUI.Box(boxPosition, GUIContent.none, EditorStyles.helpBox);

            EditorGUI.EndProperty();
            property.SetPropertyDrawerHeight(position.y - originY);
        }
Ejemplo n.º 3
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            AdvancedDropdownItem root = new AdvancedDropdownItem("DOTween Actions");

            foreach (var typeToDisplayGUI in DOTweenActionEditorGUIUtility.TypeToDisplayName)
            {
                Type baseDOTweenActionType = typeToDisplayGUI.Key;

                AdvancedDropdownItem targetFolder = root;

                if (DOTweenActionEditorGUIUtility.TypeToParentDisplay.TryGetValue(baseDOTweenActionType, out GUIContent parent))
                {
                    AdvancedDropdownItem item = targetFolder.children.FirstOrDefault(dropdownItem =>
                                                                                     dropdownItem.name.Equals(parent.text, StringComparison.Ordinal));

                    if (item == null)
                    {
                        item = new AdvancedDropdownItem(parent.text)
                        {
                            icon = (Texture2D)parent.image
                        };
                        targetFolder.AddChild(item);
                    }

                    targetFolder = item;
                }

                DOTweenActionAdvancedDropdownItem doTweenActionAdvancedDropdownItem =
                    new DOTweenActionAdvancedDropdownItem(baseDOTweenActionType, typeToDisplayGUI.Value.text)
                {
                    enabled = !IsTypeAlreadyInUse(actionsList, baseDOTweenActionType) && DOTweenActionEditorGUIUtility.CanActionBeAppliedToTarget(baseDOTweenActionType, targetGameObject)
                };

                if (typeToDisplayGUI.Value.image != null)
                {
                    doTweenActionAdvancedDropdownItem.icon = (Texture2D)typeToDisplayGUI.Value.image;
                }

                targetFolder.AddChild(doTweenActionAdvancedDropdownItem);
            }

            return(root);
        }