Beispiel #1
0
        public void OnInspectorGUI(SerializedProperty requestProp, bool disableAddButton)
        {
            // SerializedProperty prop = objectsProp;
            objectsRL.displayAdd    = !disableAddButton && CanAddAttachObjects();
            objectsRL.displayRemove = CanRemoveSelectedAttachObject();
            EditorGUILayout.Space();
            if (strategy)
            {
                for (int c = 0; c < strategy.GetCategories().Length; c++)
                {
                    AttachCategoryDefinition category = strategy.GetCategories()[c];
                    if (category.max < 0 || GetCountForCategory(c) < category.max)
                    {
                        DoAttachDropArea(c, category.label);
                    }
                }
            }
            objectsRL.DoLayoutList();

            if (selectedObject != objectsRL.index)
            {
                selectedObject = objectsRL.index;
                if (selectedObject != -1)
                {
                    paramsRL = ParamListEditor.CreateReorderableList(serializedObject,
                                                                     objectsProp.GetArrayElementAtIndex(selectedObject)
                                                                     .FindPropertyRelative("_defaultParams._params"),
                                                                     "Default Params for " + GetLabelForAttachObject(selectedObject));
                }
                else
                {
                    paramsRL = null;
                }
            }

            if (paramsRL == null)
            {
                ResetParamsRL();
            }

            if (CanAddAttachObjects() || CanRemoveSelectedAttachObject())
            {
                EditorGUILayout.Space();
            }
            paramsRL.DoLayoutList();
        }
Beispiel #2
0
 void OnEnable()
 {
     // attachPoint = (AttachPoint) target;
     paramsRL = ParamListEditor.CreateReorderableList(serializedObject,
                                                      serializedObject.FindProperty("baseParams._params"), "Params");
 }
        void OnGUI()
        {
            if (!Selection.activeObject || !(Selection.activeObject is SpriteParams))
            {
                Reset();
                GUILayout.Label("No Clingy Sprite Params selected");
                return;
            }

            SpriteParams _spriteParams = (SpriteParams)Selection.activeObject;

            if (spriteParams != _spriteParams || serializedObject == null)
            {
                Reset();
                spriteParams     = _spriteParams;
                serializedObject = new SerializedObject(spriteParams);
            }

            viewSize = new Vector2(position.width, position.height) * 1.5f;

            serializedObject.Update();

            SerializedProperty framesProp = serializedObject.FindProperty("frames");

            if (framesProp.arraySize == 0)
            {
                paramsRL    = null;
                frameToEdit = -1;
                GUILayout.Label("Add some sprites in the inspector to get started!");
                return;
            }

            int _frameToEdit = serializedObject.FindProperty("frameToEdit").intValue;

            if (_frameToEdit >= framesProp.arraySize)
            {
                _frameToEdit = 0;
            }

            SerializedProperty frameProp = framesProp.GetArrayElementAtIndex(_frameToEdit);

            if (_frameToEdit != frameToEdit || paramsRL == null)
            {
                paramsRL = ParamListEditor.CreateReorderableList(serializedObject,
                                                                 frameProp.FindPropertyRelative("paramList._params"), "Params");
            }
            frameToEdit = _frameToEdit;
            SerializedProperty spriteProp = frameProp.FindPropertyRelative("sprite");
            Sprite             sprite     = (Sprite)spriteProp.objectReferenceValue;

            if (!sprite)
            {
                return;
            }

            GUI.Box(new Rect(0, 0, position.width - 14, position.height - 14), "", new GUIStyle("preBackground"));

            scrollPos = GUI.BeginScrollView(new Rect(0, 0, position.width, position.height), scrollPos,
                                            new Rect(0, 0, viewSize.x, viewSize.y), true, true);
            SpriteParams.SpriteFrame frame = spriteParams.GetFrame(frameToEdit);
            SpriteParamsEditor.DrawSpriteAndPreview(frame,
                                                    (Sprite)serializedObject.FindProperty("previewSprite").objectReferenceValue,
                                                    GetSpriteAspectSize(frame.sprite), GetSpritePos(frame.sprite), clip: false);
            DoHandle(frame);
            GUI.EndScrollView();

            DrawParamsWindow();

            serializedObject.ApplyModifiedProperties();
        }