/// <summary>
        /// Called to opan the window and add/edit the style declaration
        /// </summary>
        /// <param name="serializedObject"></param>
        internal static void Execute(SerializedObject serializedObject)
        {
            _serializedObject = serializedObject;

            var dialog = StyleDeclarationDialog.Instance;
            dialog.title = "Add Style Declaration";
            _data = new StyleDeclarationDataObject();

            dialog.Reset();
            /**
             * Passing an empty DTO
             * */
            dialog.Data = _data;
            //dialog.Initialize();
            //dialog.StyleSheet = (eDrivenStyleSheetBase)target;
            dialog.Callback = DialogCallback;
            dialog.ShowUtility();
        }
        /// <summary>
        /// Called to opan the window and add/edit the style declaration
        /// </summary>
        /// <param name="serializedObject"></param>
        internal static void Execute(SerializedObject serializedObject)
        {
            _serializedObject = serializedObject;

            var dialog = StyleDeclarationDialog.Instance;

            dialog.title = "Add Style Declaration";
            _data        = new StyleDeclarationDataObject();

            dialog.Reset();

            /**
             * Passing an empty DTO
             * */
            dialog.Data = _data;
            //dialog.Initialize();
            //dialog.StyleSheet = (eDrivenStyleSheetBase)target;
            dialog.Callback = DialogCallback;
            dialog.ShowUtility();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called to opan the window and add/edit the style declaration
        /// </summary>
        /// <param name="declaration"></param>
        internal static void Execute(SerializedProperty declaration)
        {
            _declaration = declaration;

            var dialog = StyleDeclarationDialog.Instance;

            dialog.title = "Edit style declaration";
            dialog.Reset();

            _data = StyleDeclarationDataObject.FromSerializedProperty(declaration);
            if (string.IsNullOrEmpty(_data.ModuleId))
            {
                var t = GlobalTypeDictionary.Instance.Get(_data.Type);
                _data.ModuleId = StyleModuleManager.Instance.GetOwnerModule(t).Id;
            }

            var propertyList  = new List <StyleProperty>();
            var propertyArray = declaration.FindPropertyRelative("Properties");

            if (null != propertyArray)
            {
                var count = propertyArray.arraySize;
                //Debug.Log("count: " + count);

                for (int i = 0; i < count; i++)
                {
                    var p    = propertyArray.GetArrayElementAtIndex(i);
                    var name = p.FindPropertyRelative("Name").stringValue;
                    var type = p.FindPropertyRelative("Type").stringValue;

                    // NOTE: Not passing the value here!
                    // This is because:
                    // 1. The value cannot be read from serialized style declaration
                    // 2. We don't need the value in this dialog anyway
                    propertyList.Add(new StyleProperty {
                        Name = name, Type = type
                    });
                }
            }

            _data.StyleProperties = propertyList;

            var mediaQueryList  = new List <MediaQuery>();
            var mediaQueryArray = declaration.FindPropertyRelative("MediaQueries");

            if (null != mediaQueryArray)
            {
                var count = mediaQueryArray.arraySize;

                for (int i = 0; i < count; i++)
                {
                    var q    = mediaQueryArray.GetArrayElementAtIndex(i);
                    var name = q.FindPropertyRelative("Name").stringValue;
                    var type = q.FindPropertyRelative("Type").stringValue;

                    // NOTE: Not passing the value here!
                    // This is because:
                    // 1. The value cannot be read from serialized style declaration
                    // 2. We don't need the value in this dialog anyway
                    mediaQueryList.Add(new MediaQuery {
                        Name = name, Type = type
                    });
                }
            }

            _data.MediaQueries = mediaQueryList;

            dialog.Data = _data;
            //dialog.Initialize();

            //dialog.StyleSheet = (eDrivenStyleSheetBase)target;
            dialog.Callback = DialogCallback;
            dialog.ShowUtility();
        }
        /// <summary>
        /// Called to opan the window and add/edit the style declaration
        /// </summary>
        /// <param name="declaration"></param>
        internal static void Execute(SerializedProperty declaration)
        {
            _declaration = declaration;

            var dialog = StyleDeclarationDialog.Instance;
            dialog.title = "Edit style declaration";
            dialog.Reset();

            _data = StyleDeclarationDataObject.FromSerializedProperty(declaration);
            if (string.IsNullOrEmpty(_data.ModuleId))
            {
                var t = GlobalTypeDictionary.Instance.Get(_data.Type);
                _data.ModuleId = StyleModuleManager.Instance.GetOwnerModule(t).Id;
            }

            var propertyList = new List<StyleProperty>();
            var propertyArray = declaration.FindPropertyRelative("Properties");

            if (null != propertyArray)
            {
                var count = propertyArray.arraySize;
                //Debug.Log("count: " + count);

                for (int i = 0; i < count; i++)
                {
                    var p = propertyArray.GetArrayElementAtIndex(i);
                    var name = p.FindPropertyRelative("Name").stringValue;
                    var type = p.FindPropertyRelative("Type").stringValue;

                    // NOTE: Not passing the value here!
                    // This is because:
                    // 1. The value cannot be read from serialized style declaration
                    // 2. We don't need the value in this dialog anyway
                    propertyList.Add(new StyleProperty { Name = name, Type = type });
                }
            }

            _data.StyleProperties = propertyList;

            var mediaQueryList = new List<MediaQuery>();
            var mediaQueryArray = declaration.FindPropertyRelative("MediaQueries");

            if (null != mediaQueryArray)
            {
                var count = mediaQueryArray.arraySize;

                for (int i = 0; i < count; i++)
                {
                    var q = mediaQueryArray.GetArrayElementAtIndex(i);
                    var name = q.FindPropertyRelative("Name").stringValue;
                    var type = q.FindPropertyRelative("Type").stringValue;

                    // NOTE: Not passing the value here!
                    // This is because:
                    // 1. The value cannot be read from serialized style declaration
                    // 2. We don't need the value in this dialog anyway
                    mediaQueryList.Add(new MediaQuery { Name = name, Type = type });
                }
            }

            _data.MediaQueries = mediaQueryList;

            dialog.Data = _data;
            //dialog.Initialize();

            //dialog.StyleSheet = (eDrivenStyleSheetBase)target;
            dialog.Callback = DialogCallback;
            dialog.ShowUtility();
        }