コード例 #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DrawProjectedDecalElements
        /// # Draw all projected decal elements
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        public static Material DrawProjectedDecalElements(GenericProjectorDecal decal, bool comeFromEditor, Rect position, ConfigSaver configSaver)
        {
            if (decal)
            {
                EditorBasicFunctions.DrawEditorBox("Insert projected decals: Options", Color.white, position);

                if (!configSaver.parameters.hideBasicHelp)
                {
                    EditorBasicFunctions.DrawEditorBox("NOTE: Projected decals are experimental, they work but not perfectly!\n" + GetInsertModeHelpString() + " them", Color.yellow, position);
                }

                EditorGUILayout.Separator();

                configSaver.parameters.showProjectedDecalsConfigOptions = EditorGUILayout.Foldout(configSaver.parameters.showProjectedDecalsConfigOptions, new GUIContent("Show projected decals configuration options", "Show projected decals configuration options"));

                if (!configSaver.parameters.showProjectedDecalsConfigOptions)
                {
                    EditorGUILayout.Separator();
                }
                else
                {
                    EditorBasicFunctions.DrawEditorBox("Configuration", Color.yellow, position);

                    EditorGUILayout.Separator();

                    decal.attachToCollisionObject = EditorGUILayout.Toggle(new GUIContent("Attach to father", "Attach created decal to hit object"), decal.attachToCollisionObject);

                    if (comeFromEditor)
                    {
                        EditorGUILayout.Separator();

                        decal.scaleRange   = EditorGUILayout.Vector2Field(new GUIContent("Scale range", "Randomize decal scale between 2 values"), decal.scaleRange, new GUILayoutOption[] { GUILayout.Width(0.5f * position.width) });
                        decal.scaleRange.x = Mathf.Clamp(decal.scaleRange.x, 0.01f, 10);
                        decal.scaleRange.y = Mathf.Clamp(decal.scaleRange.y, 0.01f, 10);

                        EditorGUILayout.Separator();

                        decal.rotationRange   = EditorGUILayout.Vector2Field(new GUIContent("Rotation range", "Randomize decal rotation between 2 values"), decal.rotationRange, new GUILayoutOption[] { GUILayout.Width(0.5f * position.width) });
                        decal.rotationRange.x = Mathf.Clamp(decal.rotationRange.x, 0, 360);
                        decal.rotationRange.y = Mathf.Clamp(decal.rotationRange.y, 0, 360);
                    }

                    EditorGUILayout.Separator();
                    EditorGUILayout.Separator();
                }

                EditorBasicFunctions.DrawEditorBox("Choose projected decal!", Color.white, position);
                EditorGUILayout.Separator();
                EditorGUILayout.Separator();

                decal.material = EditorBasicFunctions.ShowObjectField <Material> ("Actual selected material ", decal.material);

                decal.material = EditorBasicFunctions.DrawProjectedDecalMaterialList(decal.material, Screen.width);

                EditorGUILayout.Separator();
                EditorGUILayout.Separator();

                if (decal.material)
                {
                    List <Sprite> spriteListFromTexture = EditorBasicFunctions.GetSpriteListFromTexture(decal.material.mainTexture);

                    if (spriteListFromTexture.Count > 0)
                    {
                        decal.sprite = spriteListFromTexture [0];
                    }

                    if (!comeFromEditor)
                    {
                        EditorBasicFunctions.DrawEditorBox("Info", Color.white, position);

                        EditorGUILayout.Separator();
                    }

                    return(decal.material);
                }
            }


            return(null);
        }