Exemplo n.º 1
0
        static void Tools_FlashTools_OpenSettings()
        {
            var settings_holder = SwfEditorUtils.GetSettingsHolder();

            Selection.objects = new Object[] { settings_holder };
            EditorGUIUtility.PingObject(settings_holder);
        }
Exemplo n.º 2
0
 public override void OnGUI(
     Rect position, SerializedProperty property, GUIContent label)
 {
     SwfEditorUtils.DoWithEnabledGUI(false, () => {
         EditorGUI.PropertyField(position, property, label, true);
     });
 }
Exemplo n.º 3
0
 public override void OnGUI(
     Rect position, SerializedProperty property, GUIContent label)
 {
     if (property.propertyType == SerializedPropertyType.Integer)
     {
         var attr      = attribute as SwfPowerOfTwoIfAttribute;
         var bool_prop = FindNextBoolProperty(property, attr.BoolProp);
         var need_pow2 = (bool_prop != null && (bool_prop.boolValue || bool_prop.hasMultipleDifferentValues));
         ValidateProperty(property, need_pow2, attr.MinPow2, attr.MaxPow2);
         SwfEditorUtils.DoWithMixedValue(
             property.hasMultipleDifferentValues, () => {
             if (need_pow2)
             {
                 var values = GenPowerOfTwoValues(attr.MinPow2, attr.MaxPow2);
                 var vnames = values.Select(p => new GUIContent(p.ToString())).ToArray();
                 EditorGUI.IntPopup(position, property, vnames, values, label);
             }
             else
             {
                 EditorGUI.PropertyField(position, property, label, true);
             }
         });
     }
     else
     {
         EditorGUI.LabelField(position, label.text, "Use SwfPowerOfTwoIf with integer attribute.");
     }
 }
Exemplo n.º 4
0
        // ---------------------------------------------------------------------
        //
        // Private
        //
        // ---------------------------------------------------------------------

        static Shader SafeLoadShader(string shader_name)
        {
            var filter = string.Format("t:Shader {0}", shader_name);
            var shader = SwfEditorUtils.LoadFirstAssetDBByFilter <Shader>(filter);

            if (!shader)
            {
                throw new UnityException(string.Format(
                                             "SwfMaterialCache. Shader not found: {0}",
                                             shader_name));
            }
            return(shader);
        }
Exemplo n.º 5
0
 public override void OnGUI(
     Rect position, SerializedProperty property, GUIContent label)
 {
     if (property.propertyType == SerializedPropertyType.String)
     {
         ValidateProperty(property);
         SwfEditorUtils.DoWithMixedValue(
             property.hasMultipleDifferentValues, () => {
             label = EditorGUI.BeginProperty(position, label, property);
             EditorGUI.BeginChangeCheck();
             var all_sorting_layers  = GetAllSortingLayers(true);
             var sorting_layer_index = EditorGUI.Popup(
                 position,
                 label,
                 property.hasMultipleDifferentValues
                                                         ? all_sorting_layers.FindIndex(p => string.IsNullOrEmpty(p))
                                                         : all_sorting_layers.FindIndex(p => p == property.stringValue),
                 all_sorting_layers.Select(p => new GUIContent(p)).ToArray());
             if (EditorGUI.EndChangeCheck())
             {
                 if (sorting_layer_index >= 0 && sorting_layer_index < all_sorting_layers.Count)
                 {
                     var new_value = all_sorting_layers[sorting_layer_index];
                     if (!string.IsNullOrEmpty(new_value))
                     {
                         if (property.hasMultipleDifferentValues)
                         {
                             property.stringValue = string.Empty;
                         }
                         property.stringValue = new_value;
                         property.serializedObject.ApplyModifiedProperties();
                     }
                 }
             }
             EditorGUI.EndProperty();
         });
     }
     else
     {
         EditorGUI.LabelField(position, label.text, "Use SwfSortingLayer with string attribute.");
     }
 }
Exemplo n.º 6
0
        static List <string> GetAllSortingLayers(bool include_empty)
        {
            var result     = new List <string>();
            var tag_assets = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset");

            if (tag_assets.Length > 0)
            {
                var layers = SwfEditorUtils.GetPropertyByName(
                    new SerializedObject(tag_assets[0]),
                    "m_SortingLayers");
                if (layers.isArray)
                {
                    for (var i = 0; i < layers.arraySize; ++i)
                    {
                        var layer_prop      = layers.GetArrayElementAtIndex(i);
                        var layer_prop_name = layer_prop != null
                                                        ? layer_prop.FindPropertyRelative("name")
                                                        : null;

                        var layer_name = layer_prop_name != null && layer_prop_name.propertyType == SerializedPropertyType.String
                                                        ? layer_prop_name.stringValue
                                                        : string.Empty;
                        if (!string.IsNullOrEmpty(layer_name))
                        {
                            result.Add(layer_name);
                        }
                    }
                }
            }
            if (!result.Contains(DefaultLayerName))
            {
                result.Add(DefaultLayerName);
            }
            if (include_empty)
            {
                result.Add(string.Empty);
            }
            return(result);
        }
Exemplo n.º 7
0
 static SwfAsset[] GetAllSwfAssets()
 {
     return(SwfEditorUtils.LoadAllAssetsDBByFilter <SwfAsset>("t:SwfAsset"));
 }