diff options
Diffstat (limited to 'Assets/ProFlares/Editor')
17 files changed, 0 insertions, 3985 deletions
diff --git a/Assets/ProFlares/Editor/FlareEditorHelper.cs b/Assets/ProFlares/Editor/FlareEditorHelper.cs deleted file mode 100644 index c12d828..0000000 --- a/Assets/ProFlares/Editor/FlareEditorHelper.cs +++ /dev/null @@ -1,305 +0,0 @@ -/// ProFlares - v1.08 - Copyright 2014-2015 All rights reserved - ProFlares.com - -/// <summary> -/// FlareEditorHelper.cs -/// Helper class that contains a number of functions that other Editor Scripts use. -/// </summary> - -using UnityEngine; -using UnityEditor; -using System.Collections; - -public class FlareEditorHelper : MonoBehaviour { - - const int menuPos = 10000; - - //public static bool ProFlaresDebugMessages = false; - - [MenuItem ("Window/ProFlares/Create Setup",false,menuPos+0)] - static void CreateSetup () { - GameObject rootGO = new GameObject("ProFlareSetup"); - rootGO.layer = 8; - GameObject cameraGO = new GameObject("ProFlareCamera"); - cameraGO.layer = 8; - Camera camera = cameraGO.AddComponent<Camera>(); - - cameraGO.transform.parent = rootGO.transform; - - camera.clearFlags = CameraClearFlags.Depth; - - camera.orthographic = true; - - camera.orthographicSize = 1; - - camera.farClipPlane = 2; - - camera.nearClipPlane = -2; - - camera.depth++; - - camera.cullingMask = 1 << 8; - - GameObject batchGO = new GameObject("ProFlareBatch"); - - batchGO.layer = 8; - - batchGO.transform.parent = cameraGO.transform; - - ProFlareBatch batch = batchGO.AddComponent<ProFlareBatch>(); - - batch.FlareCamera = camera; - - GameObject MainCameraGo = GameObject.FindWithTag("MainCamera"); - if(MainCameraGo){ - -#if UNITY_5 - batch.GameCamera = MainCameraGo.GetComponent<Camera>(); - - batch.GameCameraTrans = MainCameraGo.transform; - -#else - batch.GameCamera = MainCameraGo.GetComponent<Camera>(); - - batch.GameCameraTrans = MainCameraGo.transform; - -#endif - } - Selection.activeGameObject = batchGO; - - } - - [MenuItem ("Window/ProFlares/Create Setup On Selected Camera",false,menuPos+0)] - static void CreateSetupOnExisting () { - - GameObject cameraGO = null; - Camera camera = null; - - if(Selection.activeGameObject){ - - camera = Selection.activeGameObject.GetComponent<Camera>(); - if(camera == null){ - Debug.LogError("ProFlares - No Camera Selected"); - return; - }else{ - cameraGO = Selection.activeGameObject; - } - }else{ - Debug.LogError("ProFlares - Nothing Selected"); - return; - } - - Vector3 worldScale = cameraGO.transform.localScale; - - Transform parent = cameraGO.transform.parent; - - while (parent != null) - { - worldScale = Vector3.Scale(worldScale,parent.localScale); - parent = parent.parent; - } - - // Debug.LogError(worldScale.x + " " + worldScale.y + " " + worldScale.z); - - // Debug.LogError(1f/worldScale.x + " " + 1f/worldScale.y + " " + 1f/worldScale.z); - - int layerNumber = cameraGO.layer; - - GameObject batchGO = new GameObject("ProFlareBatch"); - - batchGO.layer = layerNumber; - - batchGO.transform.parent = cameraGO.transform; - - batchGO.transform.localPosition = Vector3.zero; - - batchGO.transform.localScale = new Vector3(1f/worldScale.x,1f/worldScale.y,1f/worldScale.z); - - ProFlareBatch batch = batchGO.AddComponent<ProFlareBatch>(); - - batch.FlareCamera = camera; - batch.FlareCameraTrans = camera.transform; - - GameObject MainCameraGo = GameObject.FindWithTag("MainCamera"); - - if(MainCameraGo){ -#if UNITY_5 - batch.GameCamera = MainCameraGo.GetComponent<Camera>(); - batch.GameCameraTrans = MainCameraGo.transform; -#else - batch.GameCamera = MainCameraGo.GetComponent<Camera>(); - batch.GameCameraTrans = MainCameraGo.transform; -#endif - } - - Selection.activeGameObject = batchGO; - } - - [MenuItem ("Window/ProFlares/Create Single Camera Setup On Selected Main Camera",false,menuPos+1)] - static void CreateSetupOnExistingGameCamera () { - - GameObject cameraGO = null; - Camera camera = null; - - if(Selection.activeGameObject){ - camera = Selection.activeGameObject.GetComponent<Camera>(); - if(camera == null){ - Debug.LogError("ProFlares - No Camera Selected"); - return; - }else{ - cameraGO = Selection.activeGameObject; - } - }else{ - Debug.LogError("ProFlares - Nothing Selected"); - return; - } - - // Vector3 worldScale = cameraGO.transform.localScale; - - // Transform parent = cameraGO.transform.parent; - - int layerNumber = cameraGO.layer; - - GameObject batchGO = new GameObject("ProFlareBatch"); - - batchGO.layer = layerNumber; - - batchGO.transform.parent = cameraGO.transform; - - batchGO.transform.localPosition = Vector3.zero; - - batchGO.transform.localRotation = Quaternion.identity; - - batchGO.transform.localScale = Vector3.one; - - ProFlareBatch batch = batchGO.AddComponent<ProFlareBatch>(); - - batch.FlareCamera = camera; - - batch.GameCamera = camera; - - batch.FlareCameraTrans = camera.transform; - - batch.mode = ProFlareBatch.Mode.SingleCamera; - - batch.SingleCamera_Mode = true; - - batch.zPos = 1; - /* - GameObject MainCameraGo = GameObject.FindWithTag("MainCamera"); - - if(MainCameraGo){ - batch.GameCamera = MainCameraGo.camera; - batch.GameCameraTrans = MainCameraGo.transform; - }*/ - - Selection.activeGameObject = batchGO; - - } - - [MenuItem ("Window/ProFlares/Create Flare",false,menuPos+12)] - static void CreateFlare () { - - GameObject flareGO = new GameObject("Flare"); - flareGO.layer = 8; - flareGO.AddComponent<ProFlare>(); - Selection.activeGameObject = flareGO; - } - - - - - [MenuItem ("Window/ProFlares/Help",false,menuPos+71)] - static void ProFlareHelp () { - Application.OpenURL("http://www.proflares.com/help"); - } - - public static void DrawGuiInBoxDivider(){ - - GUILayout.Space(8f); - - if (Event.current.type == EventType.Repaint) - { - - int extra = 0; - #if UNITY_4_3 - extra = 10; - #endif - - Texture2D tex = EditorGUIUtility.whiteTexture; - Rect rect = GUILayoutUtility.GetLastRect(); - GUI.color = new Color(0.5f, 0.5f, 0.5f, 0.25f); - GUI.DrawTexture(new Rect(5f+extra, rect.yMin + 5f, Screen.width-11, 1f), tex); - GUI.color = Color.white; - } - } - - - public static void DrawGuiDivider(){ - - GUILayout.Space(12f); - - if (Event.current.type == EventType.Repaint) - { - Texture2D tex = EditorGUIUtility.whiteTexture; - Rect rect = GUILayoutUtility.GetLastRect(); - GUI.color = new Color(0f, 0f, 0f, 0.25f); - GUI.DrawTexture(new Rect(0f, rect.yMin + 6f, Screen.width, 4f), tex); - GUI.DrawTexture(new Rect(0f, rect.yMin + 6f, Screen.width, 1f), tex); - GUI.DrawTexture(new Rect(0f, rect.yMin + 9f, Screen.width, 1f), tex); - GUI.color = Color.white; - } - } - - public static GUIStyle TitleStyle(){ - GUIStyle title = new GUIStyle(EditorStyles.largeLabel); - - title.fontSize = 16; - - title.clipping = TextClipping.Overflow; - - return title; - } - - public static GUIStyle ThinButtonStyle(){ - GUIStyle thinButton = new GUIStyle(EditorStyles.toolbarButton); - thinButton.fontStyle = FontStyle.Bold; - thinButton.fixedHeight = 24f; - return thinButton; - } - - public static GUIStyle ThinButtonRedStyle(){ - GUIStyle thinButtonRed = new GUIStyle(EditorStyles.toolbarButton); - thinButtonRed.fontStyle = FontStyle.Bold; - thinButtonRed.fixedHeight = 24f; - thinButtonRed.normal.textColor = Color.red; - return thinButtonRed; - } - - public static GUIStyle ThinButtonPressedStyle(){ - GUIStyle thinButtonPressed = new GUIStyle(EditorStyles.toolbarButton); - thinButtonPressed.fontStyle = FontStyle.Bold; - thinButtonPressed.fixedHeight = 24f; - return thinButtonPressed; - } - - public static GUIStyle DropDownButtonStyle(){ - GUIStyle dropDownButton = new GUIStyle(EditorStyles.toolbarDropDown); - dropDownButton.fontStyle = FontStyle.Bold; - dropDownButton.fixedHeight = 20f; - return dropDownButton; - } - - public static GUIStyle EnumStyleButton(){ - GUIStyle enumStyleButton = new GUIStyle(EditorStyles.toolbarDropDown); - enumStyleButton.onActive.background = ThinButtonStyle().onActive.background; - enumStyleButton.fixedHeight = 24f; - return enumStyleButton; - } - - public static GUIStyle FoldOutButtonStyle(){ - GUIStyle foldOutButton = new GUIStyle(EditorStyles.foldout); - foldOutButton.fontStyle = FontStyle.Bold; - return foldOutButton; - } - -}
\ No newline at end of file diff --git a/Assets/ProFlares/Editor/FlareEditorHelper.cs.meta b/Assets/ProFlares/Editor/FlareEditorHelper.cs.meta deleted file mode 100644 index c26696a..0000000 --- a/Assets/ProFlares/Editor/FlareEditorHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 34cd8af729f81f94289f7610f88c5db5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ProFlares/Editor/FlareJson.cs b/Assets/ProFlares/Editor/FlareJson.cs deleted file mode 100644 index f49d17f..0000000 --- a/Assets/ProFlares/Editor/FlareJson.cs +++ /dev/null @@ -1,1163 +0,0 @@ -using System; -using System.Collections; -using System.Text; -using System.Collections.Generic; -using UnityEngine; - -// Source: UIToolkit -- https://github.com/prime31/UIToolkit/blob/master/Assets/Plugins/MiniJSON.cs - -// Based on the JSON parser from -// http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html - -/// <summary> -/// This class encodes and decodes JSON strings. -/// Spec. details, see http://www.json.org/ -/// -/// JSON uses Arrays and Objects. These correspond here to the datatypes ArrayList and Hashtable. -/// All numbers are parsed to doubles. -/// </summary> - -public class FlareJson -{ - private const int TOKEN_NONE = 0; - private const int TOKEN_CURLY_OPEN = 1; - private const int TOKEN_CURLY_CLOSE = 2; - private const int TOKEN_SQUARED_OPEN = 3; - private const int TOKEN_SQUARED_CLOSE = 4; - private const int TOKEN_COLON = 5; - private const int TOKEN_COMMA = 6; - private const int TOKEN_STRING = 7; - private const int TOKEN_NUMBER = 8; - private const int TOKEN_TRUE = 9; - private const int TOKEN_FALSE = 10; - private const int TOKEN_NULL = 11; - private const int BUILDER_CAPACITY = 2000; - - /// <summary> - /// On decoding, this value holds the position at which the parse failed (-1 = no error). - /// </summary> - protected static int lastErrorIndex = -1; - protected static string lastDecode = ""; - - public static Color decodeColor(Hashtable table){ - - float r = float.Parse(table["r"].ToString()); - float g = float.Parse(table["g"].ToString()); - float b = float.Parse(table["b"].ToString()); - float a = float.Parse(table["a"].ToString()); - - return new Color(r,g,b,a); - } - - public static Vector4 decodeVector4(Hashtable table){ - - float r = float.Parse(table["r"].ToString()); - float g = float.Parse(table["g"].ToString()); - float b = float.Parse(table["b"].ToString()); - float a = float.Parse(table["a"].ToString()); - - return new Vector4(r,g,b,a); - } - - public static Vector3 decodeVector3(Hashtable table){ - - float r = float.Parse(table["r"].ToString()); - float g = float.Parse(table["g"].ToString()); - float b = float.Parse(table["b"].ToString()); - - return new Vector4(r,g,b); - } - - public static Vector2 decodeVector2(Hashtable table){ - - float x = float.Parse(table["x"].ToString()); - float y = float.Parse(table["y"].ToString()); - - return new Vector2(x,y); - } - - - public static AnimationCurve decodeAnimCurve(Hashtable table){ - - AnimationCurve curve = new AnimationCurve (); - - - foreach (System.Collections.DictionaryEntry key in table) { - - - Hashtable keyTable = (Hashtable)table [key.Key]; - - - float time = float.Parse(keyTable["time"].ToString()); - float value = float.Parse(keyTable["value"].ToString()); - float _in = float.Parse(keyTable["in"].ToString()); - float _out = float.Parse(keyTable["out"].ToString()); -// float tangentMode = float.Parse(keyTable["tangentMode"].ToString()); - - Keyframe newKey = new Keyframe(time,value,_in,_out); - // newKey.tangentMode = tangentMode; - - curve.AddKey(newKey); - - } - - return curve; - } - - public static bool decodeBool(string str){ - - int num = int.Parse(str); - if(num == 1) - return true; - else - return false; - } - - public static void LoadFlareData (ProFlare flare, TextAsset asset) - { - - string jsonString = asset.text; - -// Debug.Log ("LoadFlareData"); - - Hashtable decodedHash = jsonDecode (jsonString) as Hashtable; - - if (decodedHash == null) { - Debug.LogWarning ("Unable to parse Json file: " + asset.name); - return; - } - - Hashtable meta = (Hashtable)decodedHash["meta"]; - - flare.GlobalScale = float.Parse(meta["GlobalScale"].ToString()); - - flare.GlobalBrightness = float.Parse(meta["GlobalBrightness"].ToString()); - - flare.GlobalTintColor = FlareJson.decodeColor((Hashtable)meta["GlobalTintColor"]); - - flare.MultiplyScaleByTransformScale = FlareJson.decodeBool(meta["MultiplyScaleByTransformScale"].ToString()); - - //Distance Fall off - flare.useMaxDistance = FlareJson.decodeBool(meta["useMaxDistance"].ToString()); - - flare.useDistanceScale = FlareJson.decodeBool(meta["useDistanceScale"].ToString()); - - flare.useDistanceFade = FlareJson.decodeBool(meta["useDistanceFade"].ToString()); - - flare.GlobalMaxDistance = float.Parse(meta["GlobalMaxDistance"].ToString()); - - - //Angle Culling Properties - flare.UseAngleLimit = FlareJson.decodeBool(meta["UseAngleLimit"].ToString()); - - flare.maxAngle = float.Parse(meta["maxAngle"].ToString()); - - flare.UseAngleScale = FlareJson.decodeBool(meta["UseAngleScale"].ToString()); - - flare.UseAngleBrightness = FlareJson.decodeBool(meta["UseAngleBrightness"].ToString()); - - flare.UseAngleCurve = FlareJson.decodeBool(meta["UseAngleCurve"].ToString()); - - flare.AngleCurve = FlareJson.decodeAnimCurve ((Hashtable)meta ["AngleCurve"]); - - // public LayerMask mask = 1; - - flare.RaycastPhysics = FlareJson.decodeBool(meta["RaycastPhysics"].ToString()); - - flare.OffScreenFadeDist = float.Parse(meta["OffScreenFadeDist"].ToString()); - - flare.useDynamicEdgeBoost = FlareJson.decodeBool(meta["useDynamicEdgeBoost"].ToString()); - - flare.DynamicEdgeBoost = float.Parse(meta["DynamicEdgeBoost"].ToString()); - - flare.DynamicEdgeBrightness = float.Parse(meta["DynamicEdgeBrightness"].ToString()); - - flare.DynamicEdgeRange = float.Parse(meta["DynamicEdgeRange"].ToString()); - - flare.DynamicEdgeBias = float.Parse(meta["DynamicEdgeBias"].ToString()); - - flare.DynamicEdgeCurve = FlareJson.decodeAnimCurve ((Hashtable)meta ["DynamicEdgeCurve"]); - - flare.useDynamicCenterBoost = FlareJson.decodeBool(meta["useDynamicCenterBoost"].ToString()); - - flare.DynamicCenterBoost = float.Parse(meta["DynamicCenterBoost"].ToString()); - - flare.DynamicCenterBrightness = float.Parse(meta["DynamicCenterBrightness"].ToString()); - - flare.DynamicCenterRange = float.Parse(meta["DynamicCenterRange"].ToString()); - - flare.DynamicCenterBias = float.Parse(meta["DynamicCenterBias"].ToString()); - - flare.neverCull = FlareJson.decodeBool(meta["neverCull"].ToString()); - - flare.Elements.Clear (); - - Hashtable elements = (Hashtable)meta["Elements"]; - - foreach (System.Collections.DictionaryEntry item in elements) { - - Hashtable element = (Hashtable)elements[item.Key]; - - ProFlareElement elementNew = new ProFlareElement(); - - elementNew.Editing = FlareJson.decodeBool(element["Editing"].ToString()); - - elementNew.Visible = FlareJson.decodeBool(element["Visible"].ToString()); - - elementNew.SpriteName = element["SpriteName"].ToString(); - - elementNew.flare = flare; - - elementNew.flareAtlas = flare._Atlas; - - elementNew.Brightness = float.Parse(element["Brightness"].ToString()); - - elementNew.Scale = float.Parse(element["Scale"].ToString()); - - elementNew.ScaleRandom = float.Parse(element["ScaleRandom"].ToString()); - - elementNew.ScaleFinal = float.Parse(element["ScaleFinal"].ToString()); - - elementNew.RandomColorAmount = FlareJson.decodeVector4((Hashtable)element["RandomColorAmount"]); - -// //Element OffSet Properties - elementNew.position = float.Parse(element["position"].ToString()); - - elementNew.useRangeOffset = FlareJson.decodeBool(element["useRangeOffset"].ToString()); - - elementNew.SubElementPositionRange_Min = float.Parse(element["SubElementPositionRange_Min"].ToString()); - - elementNew.SubElementPositionRange_Max = float.Parse(element["SubElementPositionRange_Max"].ToString()); - - elementNew.SubElementAngleRange_Min = float.Parse(element["SubElementAngleRange_Min"].ToString()); - - elementNew.SubElementAngleRange_Max = float.Parse(element["SubElementAngleRange_Max"].ToString()); - - elementNew.OffsetPosition = FlareJson.decodeVector3((Hashtable)element["OffsetPosition"]); - - elementNew.Anamorphic = FlareJson.decodeVector3((Hashtable)element["Anamorphic"]); - - elementNew.OffsetPostion = FlareJson.decodeVector3((Hashtable)element["OffsetPostion"]); - -// //Element Rotation Properties - elementNew.angle = float.Parse(element["angle"].ToString()); - - elementNew.useRandomAngle = FlareJson.decodeBool(element["useRandomAngle"].ToString()); - - elementNew.useStarRotation = FlareJson.decodeBool(element["useStarRotation"].ToString()); - - elementNew.AngleRandom_Min = float.Parse(element["AngleRandom_Min"].ToString()); - - elementNew.AngleRandom_Max = float.Parse(element["AngleRandom_Max"].ToString()); - - elementNew.OrientToSource = FlareJson.decodeBool(element["OrientToSource"].ToString()); - - elementNew.rotateToFlare = FlareJson.decodeBool(element["rotateToFlare"].ToString()); - - elementNew.rotationSpeed = float.Parse(element["rotationSpeed"].ToString()); - - elementNew.rotationOverTime = float.Parse(element["rotationOverTime"].ToString()); - -// //Colour Properties, - elementNew.useColorRange = FlareJson.decodeBool(element["useColorRange"].ToString()); - - elementNew.OffsetPosition = FlareJson.decodeVector3((Hashtable)element["OffsetPosition"]); - - elementNew.ElementTint = FlareJson.decodeColor((Hashtable)element["ElementTint"]); - - elementNew.SubElementColor_Start = FlareJson.decodeColor((Hashtable)element["SubElementColor_Start"]); - - elementNew.SubElementColor_End = FlareJson.decodeColor((Hashtable)element["SubElementColor_End"]); - -// //Scale Curve - elementNew.useScaleCurve = FlareJson.decodeBool(element["useScaleCurve"].ToString()); - - elementNew.ScaleCurve = FlareJson.decodeAnimCurve ((Hashtable)element ["ScaleCurve"]); - -// //Override Properties - elementNew.OverrideDynamicEdgeBoost = FlareJson.decodeBool(element["OverrideDynamicEdgeBoost"].ToString()); - - elementNew.DynamicEdgeBoostOverride = float.Parse(element["DynamicEdgeBoostOverride"].ToString()); - - elementNew.OverrideDynamicCenterBoost = FlareJson.decodeBool(element["OverrideDynamicCenterBoost"].ToString()); - - elementNew.DynamicCenterBoostOverride = float.Parse(element["DynamicCenterBoostOverride"].ToString()); - - elementNew.OverrideDynamicEdgeBrightness = FlareJson.decodeBool(element["OverrideDynamicEdgeBrightness"].ToString()); - - elementNew.DynamicEdgeBrightnessOverride = float.Parse(element["DynamicEdgeBrightnessOverride"].ToString()); - - elementNew.OverrideDynamicCenterBrightness = FlareJson.decodeBool(element["OverrideDynamicCenterBrightness"].ToString()); - - elementNew.DynamicCenterBrightnessOverride = float.Parse(element["DynamicCenterBrightnessOverride"].ToString()); - - elementNew.type = (ProFlareElement.Type)(int.Parse(element["type"].ToString())); - - - elementNew.size = FlareJson.decodeVector2((Hashtable)element["size"]); - - Hashtable subElements = (Hashtable)element["subElements"]; - - if(subElements != null) - foreach (System.Collections.DictionaryEntry subItem in subElements) { - - Hashtable subElement = (Hashtable)subElements[subItem.Key]; - - SubElement subElementNew = new SubElement(); - - subElementNew.color = FlareJson.decodeColor((Hashtable)subElement["color"]); - - subElementNew.position = float.Parse(subElement["position"].ToString()); - - subElementNew.offset = FlareJson.decodeVector3((Hashtable)subElement["offset"]); - - subElementNew.angle = float.Parse(subElement["angle"].ToString()); - - subElementNew.scale = float.Parse(subElement["scale"].ToString()); - - subElementNew.random = float.Parse(subElement["random"].ToString()); - - subElementNew.random2 = float.Parse(subElement["random2"].ToString()); - - subElementNew.RandomScaleSeed = float.Parse(subElement["RandomScaleSeed"].ToString()); - - subElementNew.RandomColorSeedR = float.Parse(subElement["RandomColorSeedR"].ToString()); - - subElementNew.RandomColorSeedG = float.Parse(subElement["RandomColorSeedG"].ToString()); - - subElementNew.RandomColorSeedB = float.Parse(subElement["RandomColorSeedB"].ToString()); - - subElementNew.RandomColorSeedA = float.Parse(subElement["RandomColorSeedA"].ToString()); - - elementNew.subElements.Add(subElementNew); - } - - bool Found = false; - - for(int i2 = 0; i2 < flare._Atlas.elementsList.Count; i2++){ - if(elementNew.SpriteName == flare._Atlas.elementsList[i2].name){ - Found = true; - elementNew.elementTextureID = i2; - } - } - - if(Found) - flare.Elements.Add(elementNew); - else - Debug.LogWarning("ProFlares - Flare Element Missing From Atlas Not Adding - "+elementNew.SpriteName); - - } - - foreach (ProFlareBatch batch in flare.FlareBatches) { - batch.dirty = true; - } - } - /// <summary> - /// Parse the specified JSon file, loading sprite information for the specified atlas. - /// </summary> - - public static void LoadSpriteData (ProFlareAtlas atlas, TextAsset asset) - { - if (asset == null || atlas == null) return; - - string jsonString = asset.text; - - Hashtable decodedHash = jsonDecode(jsonString) as Hashtable; - - if (decodedHash == null) - { - Debug.LogWarning("Unable to parse Json file: " + asset.name); - return; - } - List<ProFlareAtlas.Element> oldElements = atlas.elementsList; - - atlas.elementsList = new List<ProFlareAtlas.Element>(); - - Vector2 TextureScale = Vector2.one; - - //Find Texture Size - Hashtable meta = (Hashtable)decodedHash["meta"]; - foreach (System.Collections.DictionaryEntry item in meta) - { - if(item.Key.ToString() == "size"){ - Hashtable sizeTable = (Hashtable)item.Value; - - TextureScale.x = int.Parse(sizeTable["w"].ToString()); - TextureScale.y = int.Parse(sizeTable["h"].ToString()); - } - } - - //Debug.LogError(TextureScale); - - Hashtable frames = (Hashtable)decodedHash["frames"]; - foreach (System.Collections.DictionaryEntry item in frames) - { - ProFlareAtlas.Element newElement = new ProFlareAtlas.Element(); - newElement.name = item.Key.ToString(); - - bool exists = false; - - // Check to see if this sprite exists - foreach (ProFlareAtlas.Element oldSprite in oldElements) - { - if (oldSprite.name.Equals(newElement.name, StringComparison.OrdinalIgnoreCase)) - { - exists = true; - break; - } - } - - if (!exists) - { - newElement.name = newElement.name.Replace(".png", ""); - newElement.name = newElement.name.Replace(".tga", ""); - newElement.name = newElement.name.Replace(".psd", ""); - newElement.name = newElement.name.Replace(".PSD", ""); - } - - Hashtable table = (Hashtable)item.Value; - Hashtable frame = (Hashtable)table["frame"]; - - int frameX = int.Parse(frame["x"].ToString()); - int frameY = int.Parse(frame["y"].ToString()); - int frameW = int.Parse(frame["w"].ToString()); - int frameH = int.Parse(frame["h"].ToString()); - - Rect finalUVs = new Rect(frameX, frameY, frameW, frameH); - - Rect rect = new Rect(frameX, frameY, frameW, frameH); - - float width = TextureScale.x; - float height = TextureScale.y; - - if (width != 0f && height != 0f) - { - finalUVs.xMin = rect.xMin / width; - finalUVs.xMax = rect.xMax / width; - finalUVs.yMin = 1f - rect.yMax / height; - finalUVs.yMax = 1f - rect.yMin / height; - } - - newElement.UV = finalUVs; - newElement.Imported = true; - - - - atlas.elementsList.Add(newElement); - } - - foreach (ProFlareAtlas.Element oldSprite in oldElements) - { - if (!oldSprite.Imported) - { - atlas.elementsList.Add(oldSprite); - } - } - - // Sort imported sprites alphabetically - - atlas.elementsList.Sort(CompareSprites); - - Debug.Log("PROFLARES - Imported " + atlas.elementsList.Count + " Elements"); - - // Unload the asset - asset = null; - Resources.UnloadUnusedAssets(); - } - - /// <summary> - /// Sprite comparison function for sorting. - /// </summary> - - static int CompareSprites (ProFlareAtlas.Element a, ProFlareAtlas.Element b) { return a.name.CompareTo(b.name); } - - /// <summary> - /// Copy the inner rectangle from one sprite to another. - /// </summary> - /* - static void CopyInnerRect (ProFlareAtlas.Element oldSprite, ProFlareAtlas.Element newElement) - { - float offsetX = oldSprite.inner.xMin - oldSprite.outer.xMin; - float offsetY = oldSprite.inner.yMin - oldSprite.outer.yMin; - float sizeX = oldSprite.inner.width; - float sizeY = oldSprite.inner.height; - - if (Mathf.Approximately(newElement.outer.width, oldSprite.outer.width)) - { - // The sprite has not been rotated or it's a square - newElement.inner = new Rect(newElement.outer.xMin + offsetX, newElement.outer.yMin + offsetY, sizeX, sizeY); - } - else if (Mathf.Approximately(newElement.outer.width, oldSprite.outer.height)) - { - // The sprite was rotated since the last time it was imported - newElement.inner = new Rect(newElement.outer.xMin + offsetY, newElement.outer.yMin + offsetX, sizeY, sizeX); - } - } - */ - /// <summary> - /// Parses the string json into a value - /// </summary> - /// <param name="json">A JSON string.</param> - /// <returns>An ArrayList, a Hashtable, a double, a string, null, true, or false</returns> - public static object jsonDecode( string json ) - { - // save the string for debug information - FlareJson.lastDecode = json; - - if( json != null ) - { - char[] charArray = json.ToCharArray(); - int index = 0; - bool success = true; - object value = FlareJson.parseValue( charArray, ref index, ref success ); - - if( success ){ - Debug.Log("jsonDecode success"); - FlareJson.lastErrorIndex = -1; - } - else{ - - FlareJson.lastErrorIndex = index; - } - return value; - } - else - { - return null; - } - } - - - /// <summary> - /// Converts a Hashtable / ArrayList / Dictionary(string,string) object into a JSON string - /// </summary> - /// <param name="json">A Hashtable / ArrayList</param> - /// <returns>A JSON encoded string, or null if object 'json' is not serializable</returns> - public static string jsonEncode( object json ) - { - var builder = new StringBuilder( BUILDER_CAPACITY ); - var success = FlareJson.serializeValue( json, builder ); - - return ( success ? builder.ToString() : null ); - } - - - /// <summary> - /// On decoding, this function returns the position at which the parse failed (-1 = no error). - /// </summary> - /// <returns></returns> - public static bool lastDecodeSuccessful() - { - return ( FlareJson.lastErrorIndex == -1 ); - } - - - /// <summary> - /// On decoding, this function returns the position at which the parse failed (-1 = no error). - /// </summary> - /// <returns></returns> - public static int getLastErrorIndex() - { - return FlareJson.lastErrorIndex; - } - - - /// <summary> - /// If a decoding error occurred, this function returns a piece of the JSON string - /// at which the error took place. To ease debugging. - /// </summary> - /// <returns></returns> - public static string getLastErrorSnippet() - { - if( FlareJson.lastErrorIndex == -1 ) - { - return ""; - } - else - { - int startIndex = FlareJson.lastErrorIndex - 5; - int endIndex = FlareJson.lastErrorIndex + 15; - if( startIndex < 0 ) - startIndex = 0; - - if( endIndex >= FlareJson.lastDecode.Length ) - endIndex = FlareJson.lastDecode.Length - 1; - - return FlareJson.lastDecode.Substring( startIndex, endIndex - startIndex + 1 ); - } - } - - - #region Parsing - - protected static Hashtable parseObject( char[] json, ref int index ) - { - Hashtable table = new Hashtable(); - int token; - - // { - nextToken( json, ref index ); - - bool done = false; - while( !done ) - { - token = lookAhead( json, index ); - if( token == FlareJson.TOKEN_NONE ) - { - return null; - } - else if( token == FlareJson.TOKEN_COMMA ) - { - nextToken( json, ref index ); - } - else if( token == FlareJson.TOKEN_CURLY_CLOSE ) - { - nextToken( json, ref index ); - return table; - } - else - { - // name - string name = parseString( json, ref index ); - if( name == null ) - { - return null; - } - - // : - token = nextToken( json, ref index ); - if( token != FlareJson.TOKEN_COLON ) - return null; - - // value - bool success = true; - object value = parseValue( json, ref index, ref success ); - if( !success ) - return null; - - table[name] = value; - } - } - - return table; - } - - - protected static ArrayList parseArray( char[] json, ref int index ) - { - ArrayList array = new ArrayList(); - - // [ - nextToken( json, ref index ); - - bool done = false; - while( !done ) - { - int token = lookAhead( json, index ); - if( token == FlareJson.TOKEN_NONE ) - { - return null; - } - else if( token == FlareJson.TOKEN_COMMA ) - { - nextToken( json, ref index ); - } - else if( token == FlareJson.TOKEN_SQUARED_CLOSE ) - { - nextToken( json, ref index ); - break; - } - else - { - bool success = true; - object value = parseValue( json, ref index, ref success ); - if( !success ) - return null; - - array.Add( value ); - } - } - - return array; - } - - - protected static object parseValue( char[] json, ref int index, ref bool success ) - { - switch( lookAhead( json, index ) ) - { - case FlareJson.TOKEN_STRING: - return parseString( json, ref index ); - case FlareJson.TOKEN_NUMBER: - return parseNumber( json, ref index ); - case FlareJson.TOKEN_CURLY_OPEN: - return parseObject( json, ref index ); - case FlareJson.TOKEN_SQUARED_OPEN: - return parseArray( json, ref index ); - case FlareJson.TOKEN_TRUE: - nextToken( json, ref index ); - return Boolean.Parse( "TRUE" ); - case FlareJson.TOKEN_FALSE: - nextToken( json, ref index ); - return Boolean.Parse( "FALSE" ); - case FlareJson.TOKEN_NULL: - nextToken( json, ref index ); - return null; - case FlareJson.TOKEN_NONE: - break; - } - - success = false; - return null; - } - - - protected static string parseString( char[] json, ref int index ) - { - string s = ""; - char c; - - eatWhitespace( json, ref index ); - - // " - c = json[index++]; - - bool complete = false; - while( !complete ) - { - if( index == json.Length ) - break; - - c = json[index++]; - if( c == '"' ) - { - complete = true; - break; - } - else if( c == '\\' ) - { - if( index == json.Length ) - break; - - c = json[index++]; - if( c == '"' ) - { - s += '"'; - } - else if( c == '\\' ) - { - s += '\\'; - } - else if( c == '/' ) - { - s += '/'; - } - else if( c == 'b' ) - { - s += '\b'; - } - else if( c == 'f' ) - { - s += '\f'; - } - else if( c == 'n' ) - { - s += '\n'; - } - else if( c == 'r' ) - { - s += '\r'; - } - else if( c == 't' ) - { - s += '\t'; - } - else if( c == 'u' ) - { - int remainingLength = json.Length - index; - if( remainingLength >= 4 ) - { - char[] unicodeCharArray = new char[4]; - Array.Copy( json, index, unicodeCharArray, 0, 4 ); - - // Drop in the HTML markup for the unicode character - s += "&#x" + new string( unicodeCharArray ) + ";"; - - /* -uint codePoint = UInt32.Parse(new string(unicodeCharArray), NumberStyles.HexNumber); -// convert the integer codepoint to a unicode char and add to string -s += Char.ConvertFromUtf32((int)codePoint); -*/ - - // skip 4 chars - index += 4; - } - else - { - break; - } - - } - } - else - { - s += c; - } - - } - - if( !complete ) - return null; - - return s; - } - - - protected static double parseNumber( char[] json, ref int index ) - { - eatWhitespace( json, ref index ); - - int lastIndex = getLastIndexOfNumber( json, index ); - int charLength = ( lastIndex - index ) + 1; - char[] numberCharArray = new char[charLength]; - - Array.Copy( json, index, numberCharArray, 0, charLength ); - index = lastIndex + 1; - return Double.Parse( new string( numberCharArray ) ); // , CultureInfo.InvariantCulture); - } - - - protected static int getLastIndexOfNumber( char[] json, int index ) - { - int lastIndex; - for( lastIndex = index; lastIndex < json.Length; lastIndex++ ) - if( "0123456789+-.eE".IndexOf( json[lastIndex] ) == -1 ) - { - break; - } - return lastIndex - 1; - } - - - protected static void eatWhitespace( char[] json, ref int index ) - { - for( ; index < json.Length; index++ ) - if( " \t\n\r".IndexOf( json[index] ) == -1 ) - { - break; - } - } - - - protected static int lookAhead( char[] json, int index ) - { - int saveIndex = index; - return nextToken( json, ref saveIndex ); - } - - - protected static int nextToken( char[] json, ref int index ) - { - eatWhitespace( json, ref index ); - - if( index == json.Length ) - { - return FlareJson.TOKEN_NONE; - } - - char c = json[index]; - index++; - switch( c ) - { - case '{': - return FlareJson.TOKEN_CURLY_OPEN; - case '}': - return FlareJson.TOKEN_CURLY_CLOSE; - case '[': - return FlareJson.TOKEN_SQUARED_OPEN; - case ']': - return FlareJson.TOKEN_SQUARED_CLOSE; - case ',': - return FlareJson.TOKEN_COMMA; - case '"': - return FlareJson.TOKEN_STRING; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '-': - return FlareJson.TOKEN_NUMBER; - case ':': - return FlareJson.TOKEN_COLON; - } - index--; - - int remainingLength = json.Length - index; - - // false - if( remainingLength >= 5 ) - { - if( json[index] == 'f' && - json[index + 1] == 'a' && - json[index + 2] == 'l' && - json[index + 3] == 's' && - json[index + 4] == 'e' ) - { - index += 5; - return FlareJson.TOKEN_FALSE; - } - } - - // true - if( remainingLength >= 4 ) - { - if( json[index] == 't' && - json[index + 1] == 'r' && - json[index + 2] == 'u' && - json[index + 3] == 'e' ) - { - index += 4; - return FlareJson.TOKEN_TRUE; - } - } - - // null - if( remainingLength >= 4 ) - { - if( json[index] == 'n' && - json[index + 1] == 'u' && - json[index + 2] == 'l' && - json[index + 3] == 'l' ) - { - index += 4; - return FlareJson.TOKEN_NULL; - } - } - - return FlareJson.TOKEN_NONE; - } - - #endregion - - - #region Serialization - - protected static bool serializeObjectOrArray( object objectOrArray, StringBuilder builder ) - { - if( objectOrArray is Hashtable ) - { - return serializeObject( (Hashtable)objectOrArray, builder ); - } - else if( objectOrArray is ArrayList ) - { - return serializeArray( (ArrayList)objectOrArray, builder ); - } - else - { - return false; - } - } - - - protected static bool serializeObject( Hashtable anObject, StringBuilder builder ) - { - builder.Append( "{" ); - - IDictionaryEnumerator e = anObject.GetEnumerator(); - bool first = true; - while( e.MoveNext() ) - { - string key = e.Key.ToString(); - object value = e.Value; - - if( !first ) - { - builder.Append( ", " ); - } - - serializeString( key, builder ); - builder.Append( ":" ); - if( !serializeValue( value, builder ) ) - { - return false; - } - - first = false; - } - - builder.Append( "}" ); - return true; - } - - - protected static bool serializeDictionary( Dictionary<string,string> dict, StringBuilder builder ) - { - builder.Append( "{" ); - - bool first = true; - foreach( var kv in dict ) - { - if( !first ) - builder.Append( ", " ); - - serializeString( kv.Key, builder ); - builder.Append( ":" ); - serializeString( kv.Value, builder ); - - first = false; - } - - builder.Append( "}" ); - return true; - } - - - protected static bool serializeArray( ArrayList anArray, StringBuilder builder ) - { - builder.Append( "[" ); - - bool first = true; - for( int i = 0; i < anArray.Count; i++ ) - { - object value = anArray[i]; - - if( !first ) - { - builder.Append( ", " ); - } - - if( !serializeValue( value, builder ) ) - { - return false; - } - - first = false; - } - - builder.Append( "]" ); - return true; - } - - - protected static bool serializeValue( object value, StringBuilder builder ) - { - // Type t = value.GetType(); - // Debug.Log("type: " + t.ToString() + " isArray: " + t.IsArray); - - if( value == null ) - { - builder.Append( "null" ); - } - else if( value.GetType().IsArray ) - { - serializeArray( new ArrayList( (ICollection)value ), builder ); - } - else if( value is string ) - { - serializeString( (string)value, builder ); - } - else if( value is Char ) - { - serializeString( Convert.ToString( (char)value ), builder ); - } - else if( value is Hashtable ) - { - serializeObject( (Hashtable)value, builder ); - } - else if( value is Dictionary<string,string> ) - { - serializeDictionary( (Dictionary<string,string>)value, builder ); - } - else if( value is ArrayList ) - { - serializeArray( (ArrayList)value, builder ); - } - else if( ( value is Boolean ) && ( (Boolean)value == true ) ) - { - builder.Append( "true" ); - } - else if( ( value is Boolean ) && ( (Boolean)value == false ) ) - { - builder.Append( "false" ); - } - else if( value.GetType().IsPrimitive ) - { - serializeNumber( Convert.ToDouble( value ), builder ); - } - else - { - return false; - } - - return true; - } - - - protected static void serializeString( string aString, StringBuilder builder ) - { - builder.Append( "\"" ); - - char[] charArray = aString.ToCharArray(); - for( int i = 0; i < charArray.Length; i++ ) - { - char c = charArray[i]; - if( c == '"' ) - { - builder.Append( "\\\"" ); - } - else if( c == '\\' ) - { - builder.Append( "\\\\" ); - } - else if( c == '\b' ) - { - builder.Append( "\\b" ); - } - else if( c == '\f' ) - { - builder.Append( "\\f" ); - } - else if( c == '\n' ) - { - builder.Append( "\\n" ); - } - else if( c == '\r' ) - { - builder.Append( "\\r" ); - } - else if( c == '\t' ) - { - builder.Append( "\\t" ); - } - else - { - int codepoint = Convert.ToInt32( c ); - if( ( codepoint >= 32 ) && ( codepoint <= 126 ) ) - { - builder.Append( c ); - } - else - { - builder.Append( "\\u" + Convert.ToString( codepoint, 16 ).PadLeft( 4, '0' ) ); - } - } - } - - builder.Append( "\"" ); - } - - - protected static void serializeNumber( double number, StringBuilder builder ) - { - builder.Append( Convert.ToString( number ) ); // , CultureInfo.InvariantCulture)); - } - - #endregion - -} diff --git a/Assets/ProFlares/Editor/FlareJson.cs.meta b/Assets/ProFlares/Editor/FlareJson.cs.meta deleted file mode 100644 index 4dc6aab..0000000 --- a/Assets/ProFlares/Editor/FlareJson.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2a4a1342fbdb2a34a8ff038e0c2296c2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ProFlares/Editor/ProFlareAtlasInspector.cs b/Assets/ProFlares/Editor/ProFlareAtlasInspector.cs deleted file mode 100644 index 1daf894..0000000 --- a/Assets/ProFlares/Editor/ProFlareAtlasInspector.cs +++ /dev/null @@ -1,236 +0,0 @@ - -/// ProFlares - v1.08 - Copyright 2014-2015 All rights reserved - ProFlares.com - - -/// <summary> -/// ProFlareAtlasInspector.cs -/// Custom inspector for the ProFlareAtlas -/// </summary> - -using UnityEngine; -using UnityEditor; -using System.Collections; - - -[CustomEditor(typeof(ProFlareAtlas))] -public class ProFlareAtlasInspector : Editor { - - ProFlareAtlas _ProFlareAtlas; - - public string renameString; - - bool listeningForGuiChanges; - - bool guiChanged = false; - - private void CheckUndo() - { -#if UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 - Event e = Event.current; - - if ( e.type == EventType.MouseDown && e.button == 0 || e.type == EventType.KeyUp && ( e.keyCode == KeyCode.Tab ) ) { - //Debug.Log("record1"); - Undo.RecordObject(_ProFlareAtlas,"ProFlareAtlas Undo"); - - listeningForGuiChanges = true; - guiChanged = false; - } - - if ( listeningForGuiChanges && guiChanged ) { - //Debug.Log("record2"); - - Undo.RecordObject(_ProFlareAtlas,"ProFlareAtlas Undo"); - listeningForGuiChanges = false; - - } -#else - Event e = Event.current; - - if ( e.type == EventType.MouseDown && e.button == 0 || e.type == EventType.KeyUp && ( e.keyCode == KeyCode.Tab ) ) { - Undo.SetSnapshotTarget( _ProFlareAtlas, "ProFlareAtlas Undo" ); - Undo.CreateSnapshot(); - Undo.ClearSnapshotTarget(); - listeningForGuiChanges = true; - guiChanged = false; - } - - if ( listeningForGuiChanges && guiChanged ) { - Undo.SetSnapshotTarget( _ProFlareAtlas, "ProFlareAtlas Undo" ); - Undo.RegisterSnapshot(); - Undo.ClearSnapshotTarget(); - listeningForGuiChanges = false; - } -#endif - } - - public override void OnInspectorGUI () { - _ProFlareAtlas = target as ProFlareAtlas; - CheckUndo(); - // base.OnInspectorGUI(); - FlareEditorHelper.DrawGuiDivider(); - GUIStyle title = FlareEditorHelper.TitleStyle(); - GUIStyle thinButton = FlareEditorHelper.ThinButtonStyle(); - GUIStyle enumDropDown = FlareEditorHelper.EnumStyleButton(); - GUIStyle redButton = FlareEditorHelper.ThinButtonRedStyle(); - - - EditorGUILayout.LabelField("ProFlare Atlas Editor",title); - GUILayout.Space(10f); - - _ProFlareAtlas.texture = EditorGUILayout.ObjectField("Flare Atlas Texture", _ProFlareAtlas.texture, typeof(Texture2D), false) as Texture2D; - - if(_ProFlareAtlas.texture == null){ - EditorGUILayout.HelpBox("Assign a texture to the atlas.", MessageType.Warning,true); - return; - } - TextAsset ta = EditorGUILayout.ObjectField("Atlas JSON Import", null, typeof(TextAsset), false) as TextAsset; - - if (ta != null) - { - FlareJson.LoadSpriteData(_ProFlareAtlas, ta); - Updated = true; - } - - FlareEditorHelper.DrawGuiDivider(); - EditorGUILayout.LabelField("Atlas Elements",title); - GUILayout.Space(6f); - - EditorGUILayout.BeginHorizontal(); - - - if(_ProFlareAtlas.elementsList.Count < 1) - - EditorGUILayout.HelpBox("No Elements in flare atlas", MessageType.Warning,true); - else{ - - _ProFlareAtlas.elementNameList = new string[_ProFlareAtlas.elementsList.Count]; - - for(int i = 0; i < _ProFlareAtlas.elementNameList.Length; i++) - _ProFlareAtlas.elementNameList[i] = _ProFlareAtlas.elementsList[i].name; - - - int _ProFlareAtlasElementNumber = EditorGUILayout.Popup(_ProFlareAtlas.elementNumber, _ProFlareAtlas.elementNameList,enumDropDown); - - if(_ProFlareAtlasElementNumber != _ProFlareAtlas.elementNumber){ - _ProFlareAtlas.elementNumber = _ProFlareAtlasElementNumber; - renameString = _ProFlareAtlas.elementsList[_ProFlareAtlas.elementNumber].name; - } - - if(GUILayout.Button("EDIT",thinButton)){Updated = true; - if(_ProFlareAtlas.editElements) - _ProFlareAtlas.editElements = false; - else - _ProFlareAtlas.editElements = true; - } - } - - if(GUILayout.Button("ADD NEW",thinButton)){ - - _ProFlareAtlas.editElements = true; - - ProFlareAtlas.Element element = new ProFlareAtlas.Element(); - - element.name = "New Element " + _ProFlareAtlas.elementsList.Count; - - renameString = element.name; - element.Imported = false; - - _ProFlareAtlas.elementsList.Add(element); - - _ProFlareAtlas.elementNumber = _ProFlareAtlas.elementsList.Count-1; - - - Updated = true; - } - - EditorGUILayout.EndHorizontal(); - - if(_ProFlareAtlas.elementsList.Count < 1) - return; - - EditorGUILayout.BeginVertical("box"); - GUILayout.Space(20f); - - Rect lastRect = GUILayoutUtility.GetLastRect(); - - Rect outerRect2 = new Rect(lastRect.center.x,0+lastRect.yMin,200,200); - - if(_ProFlareAtlas.elementsList.Count > 0){ - GUI.DrawTextureWithTexCoords(outerRect2, _ProFlareAtlas.texture, _ProFlareAtlas.elementsList[_ProFlareAtlas.elementNumber].UV, false); - GUILayout.Space(200f); - } - GUI.enabled = _ProFlareAtlas.editElements; - - - - if(_ProFlareAtlas.editElements){ - int extra = 0; -#if UNITY_4_3 - extra = 10; -#endif - Rect outerRect3 = new Rect(107+extra,lastRect.yMin,0.5f,200); - - Rect rect = new Rect(0,0,1,1); - - GUI.DrawTextureWithTexCoords(outerRect3, EditorGUIUtility.whiteTexture, rect, false); - - Rect outerRect4 = new Rect(7+extra,100+lastRect.yMin,200,0.5f); - - GUI.DrawTextureWithTexCoords(outerRect4, EditorGUIUtility.whiteTexture, rect, true); - } - - GUILayout.BeginHorizontal(); - - if(!_ProFlareAtlas.elementsList[_ProFlareAtlas.elementNumber].Imported){ - renameString = EditorGUILayout.TextField("Name",renameString); - if(GUILayout.Button("RENAME")){ - Updated = true; - _ProFlareAtlas.elementsList[_ProFlareAtlas.elementNumber].name = renameString; - } - }else - EditorGUILayout.LabelField("Name - "+renameString); - - GUILayout.EndHorizontal(); - - EditorGUILayout.Toggle("Imported :", _ProFlareAtlas.elementsList[_ProFlareAtlas.elementNumber].Imported); - - float width = EditorGUILayout.Slider("Width", _ProFlareAtlas.elementsList[_ProFlareAtlas.elementNumber].UV.width,0f,1f); - float height = EditorGUILayout.Slider("Height", _ProFlareAtlas.elementsList[_ProFlareAtlas.elementNumber].UV.height,0f,1f); - - float CenterX = EditorGUILayout.Slider("Center X", _ProFlareAtlas.elementsList[_ProFlareAtlas.elementNumber].UV.center.x,0f,1f); - float CenterY = EditorGUILayout.Slider("Center Y", _ProFlareAtlas.elementsList[_ProFlareAtlas.elementNumber].UV.center.y,0f,1f); - - float xMin = _ProFlareAtlas.elementsList[_ProFlareAtlas.elementNumber].UV.xMin; - float yMin = _ProFlareAtlas.elementsList[_ProFlareAtlas.elementNumber].UV.yMin; - - Rect newRect = new Rect(xMin,yMin,width,height); - - newRect.center = new Vector2(CenterX,CenterY); - - GUILayout.Space(40f); - - _ProFlareAtlas.elementsList[_ProFlareAtlas.elementNumber].UV = newRect; - - if(GUILayout.Button("DELETE ELEMENT",redButton)){ - Updated = true; - _ProFlareAtlas.elementsList.Remove(_ProFlareAtlas.elementsList[_ProFlareAtlas.elementNumber]); - _ProFlareAtlas.elementNumber = 0; - } - - EditorGUILayout.EndVertical(); - - GUI.enabled = true; - - - if (GUI.changed || Updated) - { - Updated = false; - guiChanged = true; - EditorUtility.SetDirty (target); - } - - FlareEditorHelper.DrawGuiDivider(); - } - bool Updated = false; -} - diff --git a/Assets/ProFlares/Editor/ProFlareAtlasInspector.cs.meta b/Assets/ProFlares/Editor/ProFlareAtlasInspector.cs.meta deleted file mode 100644 index 042a8fe..0000000 --- a/Assets/ProFlares/Editor/ProFlareAtlasInspector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 064d3469f306440458124e4ebd9e4038 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ProFlares/Editor/ProFlareBatchInspector.cs b/Assets/ProFlares/Editor/ProFlareBatchInspector.cs deleted file mode 100644 index 30c9b9c..0000000 --- a/Assets/ProFlares/Editor/ProFlareBatchInspector.cs +++ /dev/null @@ -1,300 +0,0 @@ - -/// ProFlares - v1.08 - Copyright 2014-2015 All rights reserved - ProFlares.com - - -/// <summary> -/// ProFlareBatchInspector.cs -/// Custom inspector for the ProFlareBatch -/// </summary> - -using UnityEngine; -using UnityEditor; -using System.Collections; - -[CustomEditor(typeof(ProFlareBatch))] -public class ProFlareBatchInspector : Editor { - - ProFlareBatch _ProFlareBatch; - // Use this for initialization - bool Updated; - string occluded = "Occluded"; - public override void OnInspectorGUI () { - - GUIStyle title = FlareEditorHelper.TitleStyle(); - - FlareEditorHelper.DrawGuiDivider(); - - EditorGUILayout.LabelField("Pro Flare Batch :",title); - - GUILayout.Space(10f); - - _ProFlareBatch = target as ProFlareBatch; - //base.DrawDefaultInspector(); - _ProFlareBatch.debugMessages = EditorGUILayout.Toggle("Debug Messages",_ProFlareBatch.debugMessages); - - EditorGUILayout.BeginHorizontal(); - - EditorGUILayout.LabelField("Mode",GUILayout.MaxWidth(100)); - - ProFlareBatch.Mode _mode = (ProFlareBatch.Mode)EditorGUILayout.EnumPopup(_ProFlareBatch.mode); - - if(_mode != _ProFlareBatch.mode){ - - _ProFlareBatch.mode = _mode; - - switch(_mode){ - case(ProFlareBatch.Mode.Standard):{ - _ProFlareBatch.SingleCamera_Mode = false; - _ProFlareBatch.VR_Mode = false; - }break; - case(ProFlareBatch.Mode.SingleCamera):{ - _ProFlareBatch.SingleCamera_Mode = true; - _ProFlareBatch.VR_Mode = false; - }break; - case(ProFlareBatch.Mode.VR):{ - _ProFlareBatch.SingleCamera_Mode = false; - _ProFlareBatch.VR_Mode = true; - }break; - } - - Updated = true; - - } - - - EditorGUILayout.EndHorizontal(); - - ProFlareAtlas _atlas = EditorGUILayout.ObjectField("Flare Atlas", _ProFlareBatch._atlas, typeof(ProFlareAtlas), false) as ProFlareAtlas; - - if(!_ProFlareBatch._atlas){ - EditorGUILayout.HelpBox("Assign a Flare Atlas.", MessageType.Error,false); - } - - - Camera _camera = EditorGUILayout.ObjectField("Game Camera", _ProFlareBatch.GameCamera, typeof(Camera), true) as Camera; - - if(_camera != _ProFlareBatch.GameCamera){ - - Updated = true; - - _ProFlareBatch.GameCamera = _camera; - - if(_ProFlareBatch.GameCamera) - _ProFlareBatch.GameCameraTrans = _camera.transform; - } - - if(_ProFlareBatch.GameCamera == null) - EditorGUILayout.HelpBox("Assign Game Camera.", MessageType.Warning,false); - - _ProFlareBatch.FlareCamera = EditorGUILayout.ObjectField("Flare Camera", _ProFlareBatch.FlareCamera, typeof(Camera), true) as Camera; - - Texture2D temp2D = null; - - if (_atlas != _ProFlareBatch._atlas) - { - if(_atlas == null) - _ProFlareBatch._atlas = null; - else - if(_atlas.texture != null){ - if(_ProFlareBatch.VR_Mode) - _ProFlareBatch.name = "ProFlareBatch_VR ("+_atlas.gameObject.name+")"; - else - _ProFlareBatch.name = "ProFlareBatch ("+_atlas.gameObject.name+")"; - - _ProFlareBatch._atlas = _atlas; - - _ProFlareBatch.ForceRefresh(); - - Updated = true; - - _ProFlareBatch.mat.mainTexture = _ProFlareBatch._atlas.texture; - - _ProFlareBatch.dirty = true; - - ProFlare[] flares = GameObject.FindObjectsOfType(typeof(ProFlare)) as ProFlare[]; - - foreach(ProFlare flare in flares){ - flare.ReInitialise(); - } - - }else{ - Debug.LogError("ProFlares - Atlas missing texture, Atlas not assigned."); - } - } - - if(_ProFlareBatch.mode == ProFlareBatch.Mode.VR){ - EditorGUILayout.BeginHorizontal(); - - EditorGUILayout.LabelField("VR Flare Depth"); - - _ProFlareBatch.VR_Depth = EditorGUILayout.Slider(_ProFlareBatch.VR_Depth,0f,1f); - - EditorGUILayout.EndHorizontal(); - } - - if (_ProFlareBatch._atlas) - { - if(_ProFlareBatch.mat) - if(Application.isPlaying || (_ProFlareBatch.mat.mainTexture == null)) - if(_atlas.texture != null) - _ProFlareBatch.mat.mainTexture = _atlas.texture; - - - FlareEditorHelper.DrawGuiDivider(); - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.LabelField("Connected Flares :",title); - if(GUILayout.Button("Force Refresh",GUILayout.MaxWidth(120))){ - - _ProFlareBatch.ForceRefresh(); - - ProFlare[] flares = GameObject.FindObjectsOfType(typeof(ProFlare)) as ProFlare[]; - - foreach(ProFlare flare in flares){ - flare.ReInitialise(); - } - - Updated = true; - } - EditorGUILayout.EndHorizontal(); - GUILayout.Space(9f); -// if(_ProFlareBatch.Flares.Count != ProFlareBatch.FlaresList.Count){ - - -// } - - if(_ProFlareBatch.FlaresList.Count < 1) - EditorGUILayout.LabelField("No Connected flares"); - else{ - EditorGUILayout.LabelField(_ProFlareBatch.FlaresList.Count.ToString()+" Flares Connected"); - - if(_ProFlareBatch.FlaresList.Count < 10) - _ProFlareBatch.showAllConnectedFlares = EditorGUILayout.Toggle("Show All Connected Flares",_ProFlareBatch.showAllConnectedFlares); - for(int i = 0; i < _ProFlareBatch.FlaresList.Count; i++){ - - if(_ProFlareBatch.FlaresList[i].flare == null) - continue; - - EditorGUILayout.BeginHorizontal(); - - if(_ProFlareBatch.FlaresList[i].occlusion == null) - continue; - - if(!_ProFlareBatch.FlaresList[i].occlusion.occluded) - - EditorGUILayout.LabelField((i+1).ToString()+" - "+_ProFlareBatch.FlaresList[i].flare.gameObject.name+" - "+_ProFlareBatch.FlaresList[i].occlusion._CullingState.ToString()); - else - EditorGUILayout.LabelField((i+1).ToString()+" - "+_ProFlareBatch.FlaresList[i].flare.gameObject.name+" - "+_ProFlareBatch.FlaresList[i].occlusion._CullingState.ToString()+" - "+occluded); - - if(GUILayout.Button("Select",GUILayout.Width(60))) - { - Selection.activeGameObject = _ProFlareBatch.FlaresList[i].flare.gameObject; - } - - - EditorGUILayout.EndHorizontal(); - if(i > 10){ - - if(!_ProFlareBatch.showAllConnectedFlares) - break; - } - } - } - - FlareEditorHelper.DrawGuiDivider(); - EditorGUILayout.LabelField("Settings :",title); - GUILayout.Space(9f); - _ProFlareBatch.zPos = EditorGUILayout.FloatField("Z Position",_ProFlareBatch.zPos); - FlareEditorHelper.DrawGuiDivider(); - EditorGUILayout.LabelField("Optimizations :",title); - - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.LabelField("Use Flare Culling"); - _ProFlareBatch.useCulling = EditorGUILayout.Toggle(_ProFlareBatch.useCulling); - GUI.enabled = _ProFlareBatch.useCulling; - EditorGUILayout.EndHorizontal(); - - - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.LabelField("Cull Flares After Seconds "); - _ProFlareBatch.cullFlaresAfterTime = EditorGUILayout.IntField(_ProFlareBatch.cullFlaresAfterTime); - EditorGUILayout.EndHorizontal(); - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.LabelField("Cull Flares when can cull # Flares "); - _ProFlareBatch.cullFlaresAfterCount = EditorGUILayout.IntField(_ProFlareBatch.cullFlaresAfterCount); - EditorGUILayout.EndHorizontal(); - - GUI.enabled = true; - GUILayout.Space(8f); - EditorGUILayout.BeginVertical("box"); - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.LabelField("Use Brightness Culling"); - _ProFlareBatch.useBrightnessThreshold = EditorGUILayout.Toggle(_ProFlareBatch.useBrightnessThreshold); - EditorGUILayout.EndHorizontal(); - GUI.enabled = _ProFlareBatch.useBrightnessThreshold; - _ProFlareBatch.BrightnessThreshold = Mathf.Clamp(EditorGUILayout.IntField(" Minimum Brightness",_ProFlareBatch.BrightnessThreshold),0,255); - GUI.enabled = true; - - EditorGUILayout.EndVertical(); - - - if(Application.isPlaying) - GUI.enabled = false; - else - GUI.enabled = true; - - FlareEditorHelper.DrawGuiDivider(); - - EditorGUILayout.LabelField("Debug :",title); - GUILayout.Space(8f); - - EditorGUILayout.BeginVertical("box"); - EditorGUILayout.LabelField("Flare Count : " + _ProFlareBatch.FlaresList.Count); - EditorGUILayout.LabelField("Flare Elements : " + _ProFlareBatch.FlareElements.Count); - //if(_ProFlareBatch.meshFilter){ - // EditorGUILayout.LabelField("Triangle Count : " + (_ProFlareBatch.meshFilter.sharedMesh.triangles.Length/3).ToString()); - // EditorGUILayout.LabelField("Vertex Count : " + _ProFlareBatch.meshFilter.sharedMesh.vertexCount.ToString()); - //} - EditorGUILayout.BeginHorizontal(); - - EditorGUILayout.LabelField("Show Overdraw",GUILayout.MaxWidth(160)); - //_ProFlareBatch.useBrightnessThreshold = EditorGUILayout.Toggle(_ProFlareBatch.useBrightnessThreshold); - bool overdraw = EditorGUILayout.Toggle(_ProFlareBatch.overdrawDebug); - EditorGUILayout.EndHorizontal(); - EditorGUILayout.EndVertical(); - - - - if(overdraw != _ProFlareBatch.overdrawDebug){ - - _ProFlareBatch.overdrawDebug = overdraw; - - if(overdraw){ - - temp2D = new Texture2D(1, 16); - temp2D.name = "[Generated] Debug"; - temp2D.hideFlags = HideFlags.DontSave; - - for (int i = 0; i < 16; ++i) - temp2D.SetPixel(0, i, Color.white); - - _ProFlareBatch.mat.mainTexture = temp2D; - - }else{ - if(_atlas.texture != null) - _ProFlareBatch.mat.mainTexture = _atlas.texture; - - if(temp2D != null) - Destroy(temp2D); - } - - } - FlareEditorHelper.DrawGuiDivider(); - - if (GUI.changed||Updated) - { - Updated = false; - EditorUtility.SetDirty (target); - } - } - } -} diff --git a/Assets/ProFlares/Editor/ProFlareBatchInspector.cs.meta b/Assets/ProFlares/Editor/ProFlareBatchInspector.cs.meta deleted file mode 100644 index 9cbaec4..0000000 --- a/Assets/ProFlares/Editor/ProFlareBatchInspector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5f2ace44baae7294c8398d6a360622a9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ProFlares/Editor/ProFlareExporter.cs b/Assets/ProFlares/Editor/ProFlareExporter.cs deleted file mode 100644 index 9a17eba..0000000 --- a/Assets/ProFlares/Editor/ProFlareExporter.cs +++ /dev/null @@ -1,305 +0,0 @@ -using System; -using System.Collections; -using System.Text; -using System.Collections.Generic; -using UnityEngine; -using System.IO; -using UnityEditor; - -public class ProFlareExporter { - - - public static string animCurveExport(AnimationCurve curve){ - string curveString = "{"; - - int keyCount = 0; - - foreach(Keyframe key in curve.keys){ - - curveString = curveString+"\"key"+keyCount+"\": {\"time\":"+key.time+",\"value\":"+key.value+",\"in\":"+key.inTangent+",\"out\":"+key.outTangent+",\"tangentMode\":"+key.tangentMode+"}"; - - keyCount++; - if(keyCount != curve.keys.Length) - curveString = curveString+","; - - } - curveString = curveString+"}"; - - return curveString; - } - - // Use this for initialization - public static void ExportFlare (ProFlare flare) { - Debug.Log ("Export Flare"); - - string fileName = "Assets/ProFlares/ExportedFlares/"+flare.gameObject.name+".txt"; - - if (File.Exists(fileName)) - { - Debug.Log(fileName+" already exists."); - //return; - } - var sr = File.CreateText(fileName); - sr.WriteLine ("{"); - - sr.WriteLine ("\"meta\": {"); - //sr.WriteLine (" \"frame\": {\"x\":768,\"y\":512,\"w\":256,\"h\":256},"); - - sr.WriteLine (" \"GlobalScale\": {0},",flare.GlobalScale); - - sr.WriteLine (" \"MultiplyScaleByTransformScale\": {0},",boolToString(flare.MultiplyScaleByTransformScale)); - - sr.WriteLine (" \"GlobalBrightness\": {0},",flare.GlobalBrightness); - - sr.WriteLine (" \"GlobalTintColor\": {\"r\":"+flare.GlobalTintColor.r+",\"g\":"+flare.GlobalTintColor.g+",\"b\":"+flare.GlobalTintColor.b+",\"a\":"+flare.GlobalTintColor.a+"},"); - - sr.WriteLine (" \"useMaxDistance\": {0},",boolToString(flare.useMaxDistance)); - - sr.WriteLine (" \"useDistanceScale\": {0},",boolToString(flare.useDistanceScale)); - - sr.WriteLine (" \"useDistanceFade\": {0},",boolToString(flare.useDistanceFade)); - - sr.WriteLine (" \"GlobalMaxDistance\": {0},",flare.GlobalMaxDistance); - -// //Angle Culling Properties - sr.WriteLine (" \"UseAngleLimit\": {0},",boolToString(flare.UseAngleLimit)); - - sr.WriteLine (" \"maxAngle\": {0},",flare.maxAngle); - - sr.WriteLine (" \"UseAngleScale\": {0},",boolToString(flare.UseAngleScale)); - - sr.WriteLine (" \"UseAngleBrightness\": {0},",boolToString(flare.UseAngleBrightness)); - - sr.WriteLine (" \"UseAngleCurve\": {0},",boolToString(flare.UseAngleCurve)); - - sr.WriteLine (" \"AngleCurve\": {0},",ProFlareExporter.animCurveExport(flare.AngleCurve)); - -// //Occlusion Properties -// public LayerMask mask = 1; - -///////////////////////////// sr.WriteLine (" \"mask\": {0},",(int)flare.mask); - - // public bool RaycastPhysics; - sr.WriteLine (" \"RaycastPhysics\": {0},",boolToString(flare.RaycastPhysics)); - - sr.WriteLine (" \"OffScreenFadeDist\": {0},",flare.OffScreenFadeDist); - -// -// //Dynamic Edge Properties - - sr.WriteLine (" \"useDynamicEdgeBoost\": {0},",boolToString(flare.useDynamicEdgeBoost)); - - sr.WriteLine (" \"DynamicEdgeBoost\": {0},",flare.DynamicEdgeBoost); - - sr.WriteLine (" \"DynamicEdgeBrightness\": {0},",flare.DynamicEdgeBrightness); - - sr.WriteLine (" \"DynamicEdgeRange\": {0},",flare.DynamicEdgeRange); - - sr.WriteLine (" \"DynamicEdgeBias\": {0},",flare.DynamicEdgeBias); - - sr.WriteLine (" \"DynamicEdgeCurve\": {0},",ProFlareExporter.animCurveExport(flare.DynamicEdgeCurve)); - -// //Dynamic Center Properties - sr.WriteLine (" \"useDynamicCenterBoost\": {0},",boolToString(flare.useDynamicCenterBoost)); - - sr.WriteLine (" \"DynamicCenterBoost\": {0},",flare.DynamicCenterBoost); - - sr.WriteLine (" \"DynamicCenterBrightness\": {0},",flare.DynamicCenterBrightness); - - sr.WriteLine (" \"DynamicCenterRange\": {0},",flare.DynamicCenterRange); - - sr.WriteLine (" \"DynamicCenterBias\": {0},",flare.DynamicCenterBias); - -// public bool neverCull; - sr.WriteLine (" \"neverCull\": {0},",boolToString(flare.neverCull)); - - sr.WriteLine (" \"Elements\": {"); - int count = 0; - - foreach (ProFlareElement element in flare.Elements) { - sr.WriteLine (" \"Element"+count+"\": {"); - - sr.WriteLine (" \"Editing\": {0},",boolToString(element.Editing)); - - sr.WriteLine (" \"Visible\": {0},",boolToString(element.Visible)); - -// //Element's texture index inside the texture atlas. -// public int elementTextureID; - sr.WriteLine (" \"elementTextureID\": {0},",element.elementTextureID); - -// -// //Elements Sprite name from the texture atlas, this isn't checked at runtime. Its only used to help stop flares breaking when the atlas changes. -// public string SpriteName; - - sr.WriteLine (" \"Brightness\": {0},",element.Brightness); - - sr.WriteLine (" \"Scale\": {0},",element.Scale); - - sr.WriteLine (" \"ScaleRandom\": {0},",element.ScaleRandom); - - sr.WriteLine (" \"ScaleFinal\": {0},",element.ScaleFinal); - - sr.WriteLine (" \"RandomColorAmount\": {\"r\":"+element.RandomColorAmount.x+",\"g\":"+element.RandomColorAmount.y+",\"b\":"+element.RandomColorAmount.z+",\"a\":"+element.RandomColorAmount.w+"},"); - -// //Element OffSet Properties - sr.WriteLine (" \"position\": {0},",element.position); - - sr.WriteLine (" \"useRangeOffset\": {0},",boolToString(element.useRangeOffset)); - - sr.WriteLine (" \"SubElementPositionRange_Min\": {0},",element.SubElementPositionRange_Min); - - sr.WriteLine (" \"SubElementPositionRange_Max\": {0},",element.SubElementPositionRange_Max); - - sr.WriteLine (" \"SubElementAngleRange_Min\": {0},",element.SubElementAngleRange_Min); - - sr.WriteLine (" \"SubElementAngleRange_Max\": {0},",element.SubElementAngleRange_Max); - - sr.WriteLine (" \"OffsetPosition\": {\"r\":"+element.OffsetPosition.x+",\"g\":"+element.OffsetPosition.y+",\"b\":"+element.OffsetPosition.z+"},"); - - sr.WriteLine (" \"Anamorphic\": {\"r\":"+element.Anamorphic.x+",\"g\":"+element.Anamorphic.y+",\"b\":"+element.Anamorphic.z+"},"); - - sr.WriteLine (" \"OffsetPostion\": {\"r\":"+element.OffsetPostion.x+",\"g\":"+element.OffsetPostion.y+",\"b\":"+element.OffsetPostion.z+"},"); - -// //Element Rotation Properties - sr.WriteLine (" \"angle\": {0},",element.angle); - - sr.WriteLine (" \"useRandomAngle\": {0},",boolToString(element.useRandomAngle)); - - sr.WriteLine (" \"useStarRotation\": {0},",boolToString(element.useStarRotation)); - - sr.WriteLine (" \"AngleRandom_Min\": {0},",element.AngleRandom_Min); - - sr.WriteLine (" \"AngleRandom_Max\": {0},",element.AngleRandom_Max); - - sr.WriteLine (" \"OrientToSource\": {0},",boolToString(element.OrientToSource)); - - sr.WriteLine (" \"rotateToFlare\": {0},",boolToString(element.rotateToFlare)); - - sr.WriteLine (" \"rotationSpeed\": {0},",element.rotationSpeed); - - sr.WriteLine (" \"rotationOverTime\": {0},",element.rotationOverTime); - -// //Colour Properties, - sr.WriteLine (" \"useColorRange\": {0},",boolToString(element.useColorRange)); - - sr.WriteLine (" \"ElementFinalColor\": {\"r\":"+element.ElementFinalColor.r+",\"g\":"+element.ElementFinalColor.g+",\"b\":"+element.ElementFinalColor.b+",\"a\":"+element.ElementFinalColor.a+"},"); - - sr.WriteLine (" \"ElementTint\": {\"r\":"+element.ElementTint.r+",\"g\":"+element.ElementTint.g+",\"b\":"+element.ElementTint.b+",\"a\":"+element.ElementTint.a+"},"); - - sr.WriteLine (" \"SubElementColor_Start\": {\"r\":"+element.SubElementColor_Start.r+",\"g\":"+element.SubElementColor_Start.g+",\"b\":"+element.SubElementColor_Start.b+",\"a\":"+element.SubElementColor_Start.a+"},"); - - sr.WriteLine (" \"SubElementColor_End\": {\"r\":"+element.SubElementColor_End.r+",\"g\":"+element.SubElementColor_End.g+",\"b\":"+element.SubElementColor_End.b+",\"a\":"+element.SubElementColor_End.a+"},"); - - sr.WriteLine (" \"useScaleCurve\": {0},",boolToString(element.useScaleCurve)); - - sr.WriteLine (" \"ScaleCurve\": {0},",ProFlareExporter.animCurveExport(element.ScaleCurve)); - -// //Override Properties - sr.WriteLine (" \"OverrideDynamicEdgeBoost\": {0},",boolToString(element.OverrideDynamicEdgeBoost)); - - sr.WriteLine (" \"DynamicEdgeBoostOverride\": {0},",element.DynamicEdgeBoostOverride); - - sr.WriteLine (" \"OverrideDynamicCenterBoost\": {0},",boolToString(element.OverrideDynamicCenterBoost)); - - sr.WriteLine (" \"DynamicCenterBoostOverride\": {0},",element.DynamicCenterBoostOverride); - - sr.WriteLine (" \"OverrideDynamicEdgeBrightness\": {0},",boolToString(element.OverrideDynamicEdgeBrightness)); - - sr.WriteLine (" \"DynamicEdgeBrightnessOverride\": {0},",element.DynamicEdgeBrightnessOverride); - - sr.WriteLine (" \"OverrideDynamicCenterBrightness\": {0},",boolToString(element.OverrideDynamicCenterBrightness)); - - sr.WriteLine (" \"DynamicCenterBrightnessOverride\": {0},",element.DynamicCenterBrightnessOverride); - - if(element.subElements.Count > 0){ - - sr.WriteLine (" \"subElements\": {"); - int count2 = 0; - - foreach (SubElement subElement in element.subElements) { - sr.WriteLine (" \"subElement"+count2+"\": {"); - - sr.WriteLine (" \"color\": {\"r\":"+subElement.color.r+",\"g\":"+subElement.color.g+",\"b\":"+subElement.color.b+",\"a\":"+subElement.color.a+"},"); - - sr.WriteLine (" \"position\": {0},",subElement.position); - - sr.WriteLine (" \"offset\": {\"r\":"+subElement.color.r+",\"g\":"+subElement.color.g+",\"b\":"+subElement.color.b+"},"); - - sr.WriteLine (" \"angle\": {0},",subElement.angle); - - sr.WriteLine (" \"scale\": {0},",subElement.scale); - - sr.WriteLine (" \"random\": {0},",subElement.random); - - sr.WriteLine (" \"random2\": {0},",subElement.random2); - - sr.WriteLine (" \"RandomScaleSeed\": {0},",subElement.RandomScaleSeed); - - sr.WriteLine (" \"RandomColorSeedR\": {0},",subElement.RandomColorSeedR); - - sr.WriteLine (" \"RandomColorSeedG\": {0},",subElement.RandomColorSeedG); - - sr.WriteLine (" \"RandomColorSeedB\": {0},",subElement.RandomColorSeedB); - - sr.WriteLine (" \"RandomColorSeedA\": {0}",subElement.RandomColorSeedA); - - count2++; - if(count2 == element.subElements.Count) - sr.WriteLine (" }"); - else - sr.WriteLine (" },"); - } - - sr.WriteLine (" },"); - } - - sr.WriteLine (" \"EditDynamicTriggering\": {0},",boolToString(element.EditDynamicTriggering)); - - sr.WriteLine (" \"EditOcclusion\": {0},",boolToString(element.EditOcclusion)); - - sr.WriteLine (" \"ElementSetting\": {0},",boolToString(element.ElementSetting)); - - sr.WriteLine (" \"OffsetSetting\": {0},",boolToString(element.OffsetSetting)); - - sr.WriteLine (" \"ColorSetting\": {0},",boolToString(element.ColorSetting)); - - sr.WriteLine (" \"ScaleSetting\": {0},",boolToString(element.ScaleSetting)); - - sr.WriteLine (" \"RotationSetting\": {0},",boolToString(element.RotationSetting)); - - sr.WriteLine (" \"OverrideSetting\": {0},",boolToString(element.OverrideSetting)); - - sr.WriteLine (" \"type\": \"{0}\"",(int)element.type); - - sr.WriteLine (" \"size\": {\"x\":"+element.size.x+",\"y\":"+element.size.y+"},"); - - sr.WriteLine (" \"SpriteName\": \"{0}\"",element.SpriteName); - - count++; - - if(count == flare.Elements.Count) - sr.WriteLine (" }"); - else - sr.WriteLine (" },"); - } - sr.WriteLine (" }"); - - sr.WriteLine ("}"); - - sr.WriteLine ("}"); - - sr.Close(); - - EditorUtility.SetDirty (flare); - - } - - static string boolToString(bool _bool){ - - if (_bool) - return "1"; - else - return "0"; - } - -} diff --git a/Assets/ProFlares/Editor/ProFlareExporter.cs.meta b/Assets/ProFlares/Editor/ProFlareExporter.cs.meta deleted file mode 100644 index 88d9a8b..0000000 --- a/Assets/ProFlares/Editor/ProFlareExporter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d45807196ac7d4b14936e8f01b552b1a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ProFlares/Editor/ProFlareInspector.cs b/Assets/ProFlares/Editor/ProFlareInspector.cs deleted file mode 100644 index 7f5391c..0000000 --- a/Assets/ProFlares/Editor/ProFlareInspector.cs +++ /dev/null @@ -1,1390 +0,0 @@ - -/// ProFlares - v1.08 - Copyright 2014-2015 All rights reserved - ProFlares.com - - -/// <summary> -/// ProFlareInspector.cs -/// Custom inspector for the ProFlare -/// </summary> - -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; - -[CanEditMultipleObjects] -[CustomEditor(typeof(ProFlare))] -public class ProFlareInspector : Editor { - - ProFlare _flare; - - GUIStyle title; - - GUIStyle thinButton; - - GUIStyle thinButtonRed; - - GUIStyle dropDownButton; - - GUIStyle enumStyleButton; - - private static Texture2D visibility_On; - - private static Texture2D visibility_Off; - - bool listeningForGuiChanges; - - bool guiChanged = false; - - int selectionCount = 0; - - private void CheckUndo() - { -#if UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 - - Event e = Event.current; - - if ( e.type == EventType.MouseDown && e.button == 0 || e.type == EventType.KeyUp && ( e.keyCode == KeyCode.Tab ) ) { - //Debug.Log("record1"); - Undo.RecordObject(target,"ProFlare Undo"); - - listeningForGuiChanges = true; - guiChanged = false; - } - - if ( listeningForGuiChanges && guiChanged ) { - //Debug.Log("record2"); - - Undo.RecordObject(target,"ProFlare Undo"); - listeningForGuiChanges = false; - //TODO - Undo Not Refreshing Flare Batches. - //for(int i = 0; i < _flare.FlareBatches.Length; i++){} - } -#else - Event e = Event.current; - - if ( e.type == EventType.MouseDown && e.button == 0 || e.type == EventType.KeyUp && ( e.keyCode == KeyCode.Tab ) ) { - Undo.SetSnapshotTarget( _flare, "ProFlare Undo" ); - Undo.CreateSnapshot(); - Undo.ClearSnapshotTarget(); - listeningForGuiChanges = true; - guiChanged = false; - } - - if ( listeningForGuiChanges && guiChanged ) { - Undo.SetSnapshotTarget( _flare, "ProFlare Undo" ); - Undo.RegisterSnapshot(); - Undo.ClearSnapshotTarget(); - listeningForGuiChanges = false; - //TODO - Undo Not Refreshing Flare Batches. - //for(int i = 0; i < _flare.FlareBatches.Length; i++){} - } -#endif - } - - public List<ProFlare> Flares = new List<ProFlare>(); - - public override void OnInspectorGUI () { - - selectionCount = 0; - - Flares.Clear(); - - foreach(GameObject go in Selection.gameObjects){ - - ProFlare selectedFlare = go.GetComponent<ProFlare>(); - if(selectedFlare){ - Flares.Add(selectedFlare); - selectionCount++; - } - } - - if(selectionCount > 1){ - EditorGUILayout.HelpBox("Multiple Flares selected.", MessageType.Warning,false); - //EditorGUI.showMixedValue = true; - } - - _flare = target as ProFlare; - - CheckUndo(); - -#if UNITY_4_3 - EditorGUI.BeginChangeCheck(); -#endif - - FlareEditorHelper.DrawGuiDivider(); - - bool error = false; - - title = FlareEditorHelper.TitleStyle(); - thinButton = FlareEditorHelper.ThinButtonStyle(); - enumStyleButton = FlareEditorHelper.EnumStyleButton(); - thinButtonRed = FlareEditorHelper.ThinButtonRedStyle(); - - EditorGUILayout.LabelField("Flare Setup :",title); - - GUILayout.Space(10f); - - dropDownButton = FlareEditorHelper.DropDownButtonStyle(); - - - if(selectionCount <= 1) - { - EditorGUILayout.BeginHorizontal(); - if((!_flare.EditingAtlas)&&(_flare._Atlas != null)) - GUI.enabled = false; - - ProFlareAtlas _Atlas = EditorGUILayout.ObjectField("Flare Atlas", _flare._Atlas, typeof(ProFlareAtlas), false) as ProFlareAtlas; - - GUI.enabled = true; - - if(_flare._Atlas) - if(GUILayout.Button("EDIT",GUILayout.Width(60))){ - _flare.EditingAtlas = _flare.EditingAtlas ? false : true; - } - - EditorGUILayout.EndHorizontal(); - - if((_flare.EditingAtlas)&&(_flare._Atlas != null)){ - - EditorGUILayout.HelpBox("Changing atlas can cause data loss if elements do NOT exist in the new atlas.", MessageType.Warning,false); - } - - GUI.enabled = true; - - if(_flare._Atlas != _Atlas){ - - _flare._Atlas = _Atlas; - - - ProFlareBatch[] flareBatchs = GameObject.FindObjectsOfType(typeof(ProFlareBatch)) as ProFlareBatch[]; - - int matchCount = 0; - foreach(ProFlareBatch flareBatch in flareBatchs){ - if(flareBatch._atlas == _Atlas){ - matchCount++; - } - } - _flare.FlareBatches = new ProFlareBatch[matchCount]; - int count = 0; - foreach(ProFlareBatch flareBatch in flareBatchs){ - if(flareBatch._atlas == _Atlas){ - _flare.FlareBatches[count] = flareBatch; - _flare.FlareBatches[count].dirty = true; - count++; - } - } - if(count != 0){ - if(_flare.Elements.Count == 0){ - ProFlareElement element = new ProFlareElement(); - element.flare = _flare; - element.SpriteName = _flare._Atlas.elementsList[0].name; - element.flareAtlas = _flare._Atlas; - element.position = -1; - element.Scale = 1; - _flare.Elements.Add(element); - } - } - } - - - bool missing = false; - for(int i = 0; i < _flare.FlareBatches.Length; i++){ - - if(_flare.FlareBatches[i] == null) - missing = true; - } - if(missing){ - - ProFlareBatch[] flareBatchs = GameObject.FindObjectsOfType(typeof(ProFlareBatch)) as ProFlareBatch[]; - - int matchCount = 0; - foreach(ProFlareBatch flareBatch in flareBatchs){ - if(flareBatch._atlas == _Atlas){ - matchCount++; - } - } - _flare.FlareBatches = new ProFlareBatch[matchCount]; - int count = 0; - foreach(ProFlareBatch flareBatch in flareBatchs){ - if(flareBatch._atlas == _Atlas){ - _flare.FlareBatches[count] = flareBatch; - _flare.FlareBatches[count].dirty = true; - count++; - } - } - } - - EditorGUILayout.LabelField("Rendered by : "); - if(_flare.FlareBatches.Length != 0) - for(int i = 0; i < _flare.FlareBatches.Length; i++){ - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.LabelField(" "+_flare.FlareBatches[i].gameObject.name); - if(GUILayout.Button("Select",GUILayout.Width(60))){ - Selection.activeGameObject = _flare.FlareBatches[i].gameObject; - } - EditorGUILayout.EndHorizontal(); - } - - if(error){ - EditorGUILayout.HelpBox("Fix Errors before continuing.", MessageType.Error); - } - } - FlareEditorHelper.DrawGuiDivider(); - - EditorGUILayout.LabelField("Global Settings :",title); - GUILayout.Space(10f); - - Rect r = EditorGUILayout.BeginVertical("box"); - { - Rect r2 = r; - r2.height = 20; - - if (GUI.Button(r2, GUIContent.none,dropDownButton)) - _flare.EditGlobals = _flare.EditGlobals ? false : true; - - GUILayout.Label("General"); - - if(_flare.EditGlobals){ - - GUILayout.Space(5f); - - //Scale - float _flareGlobalScale = EditorGUILayout.Slider("Scale",_flare.GlobalScale,0f,2000f); - - if(_flareGlobalScale != _flare.GlobalScale){ - - _flare.GlobalScale = _flareGlobalScale; - - foreach(ProFlare flare in Flares){ - flare.GlobalScale = _flare.GlobalScale; - } - } - - _flare.MultiplyScaleByTransformScale = EditorGUILayout.Toggle("Multiply Scale By Transform Scale",_flare.MultiplyScaleByTransformScale); - - float _flareGlobalBrightness = EditorGUILayout.Slider("Brightness",_flare.GlobalBrightness,0f,1f); - - if(_flareGlobalBrightness != _flare.GlobalBrightness){ - _flare.GlobalBrightness = _flareGlobalBrightness; - _flare.GlobalTintColor.a = _flare.GlobalBrightness; - - foreach(ProFlare flare in Flares){ - flare.GlobalBrightness = _flareGlobalBrightness; - flare.GlobalTintColor.a = _flare.GlobalBrightness; - } - } - - Color _flareGlobalTintColor = EditorGUILayout.ColorField("Tint",_flare.GlobalTintColor); - - if(_flareGlobalTintColor != _flare.GlobalTintColor){ - _flare.GlobalTintColor = _flareGlobalTintColor; - _flare.GlobalBrightness = _flare.GlobalTintColor.a; - - foreach(ProFlare flare in Flares){ - flare.GlobalTintColor = _flareGlobalTintColor; - flare.GlobalBrightness = _flare.GlobalTintColor.a; - } - } - - FlareEditorHelper.DrawGuiInBoxDivider(); - - //Angle Falloff Options - if(selectionCount <= 1){ - GUILayout.BeginHorizontal(); - { - _flare.UseAngleLimit = EditorGUILayout.Toggle("Use Angle Falloff",_flare.UseAngleLimit); - GUI.enabled = _flare.UseAngleLimit; - _flare.maxAngle = Mathf.Clamp(EditorGUILayout.FloatField("Max Angle",_flare.maxAngle),0,360); - } - GUILayout.EndHorizontal(); - - _flare.UseAngleScale = EditorGUILayout.Toggle(" Affect Scale",_flare.UseAngleScale); - - _flare.UseAngleBrightness = EditorGUILayout.Toggle(" Affect Brightness",_flare.UseAngleBrightness); - - GUILayout.BeginHorizontal(); - { - _flare.UseAngleCurve = EditorGUILayout.Toggle(" Use Curve",_flare.UseAngleCurve); - GUI.enabled = _flare.UseAngleCurve; - _flare.AngleCurve = EditorGUILayout.CurveField(_flare.AngleCurve); - if(GUILayout.Button("Reset",GUILayout.MaxWidth(50))){ _flare.AngleCurve = new AnimationCurve(new Keyframe(0, 0f), new Keyframe(1, 1.0f));} - GUI.enabled = true; - } - GUILayout.EndHorizontal(); - GUI.enabled = true; - - FlareEditorHelper.DrawGuiInBoxDivider(); - //Max Distance Options - - GUILayout.BeginHorizontal(); - { - _flare.useMaxDistance = EditorGUILayout.Toggle("Use Distance Falloff",_flare.useMaxDistance); - GUI.enabled = _flare.useMaxDistance; - _flare.GlobalMaxDistance = EditorGUILayout.FloatField(" Max Distance",_flare.GlobalMaxDistance); - } - GUILayout.EndHorizontal(); - _flare.useDistanceScale = EditorGUILayout.Toggle(" Affect Scale",_flare.useDistanceScale); - _flare.useDistanceFade = EditorGUILayout.Toggle(" Affect Brightness",_flare.useDistanceFade); - - - GUI.enabled = true; - FlareEditorHelper.DrawGuiInBoxDivider(); - _flare.OffScreenFadeDist = EditorGUILayout.FloatField("Off Screen Fade Distance",_flare.OffScreenFadeDist); - FlareEditorHelper.DrawGuiInBoxDivider(); - - _flare.neverCull = EditorGUILayout.Toggle("Never Cull Flare",_flare.neverCull); - } - } - } - - EditorGUILayout.EndVertical(); - - - if(selectionCount <= 1) - { - r = EditorGUILayout.BeginVertical("box"); - Rect r2 = r; - r2.height = 20; - - - if (GUI.Button(r2, GUIContent.none,dropDownButton)) - _flare.EditDynamicTriggering = _flare.EditDynamicTriggering ? false : true; - - - GUILayout.Label("Dynamics Triggering"); - - if(_flare.EditDynamicTriggering){GUILayout.Space(5f); - - _flare.useDynamicEdgeBoost = EditorGUILayout.Toggle("Use Dynamic Edge Boost",_flare.useDynamicEdgeBoost); - GUI.enabled = _flare.useDynamicEdgeBoost; - _flare.DynamicEdgeBoost = EditorGUILayout.FloatField(" Dynamic Edge Scale",_flare.DynamicEdgeBoost); - _flare.DynamicEdgeBrightness = EditorGUILayout.FloatField(" Dynamic Edge Brightness",_flare.DynamicEdgeBrightness); - _flare.DynamicEdgeRange = EditorGUILayout.FloatField(" Dynamic Edge Range",_flare.DynamicEdgeRange); - _flare.DynamicEdgeBias = EditorGUILayout.FloatField(" Dynamic Edge Bias",_flare.DynamicEdgeBias); - - GUILayout.BeginHorizontal(); - { - _flare.DynamicEdgeCurve = EditorGUILayout.CurveField(" Dynamic Edge Curve", _flare.DynamicEdgeCurve); - if(GUILayout.Button("Reset",GUILayout.MaxWidth(50))) _flare.DynamicEdgeCurve = new AnimationCurve(new Keyframe(0, 0f), new Keyframe(0.5f, 1), new Keyframe(1, 0f)); - } - GUILayout.EndHorizontal(); - GUI.enabled = true; - FlareEditorHelper.DrawGuiInBoxDivider(); - - _flare.useDynamicCenterBoost = EditorGUILayout.Toggle("Use Dynamic Center Boost",_flare.useDynamicCenterBoost); - - GUI.enabled = _flare.useDynamicCenterBoost; - _flare.DynamicCenterRange = EditorGUILayout.FloatField(" Dynamic Center Range",_flare.DynamicCenterRange); - _flare.DynamicCenterBoost = EditorGUILayout.FloatField(" Dynamic Center Scale",_flare.DynamicCenterBoost); - _flare.DynamicCenterBrightness = EditorGUILayout.FloatField(" Dynamic Center Brightness",_flare.DynamicCenterBrightness); - - GUI.enabled = true; - } - - EditorGUILayout.EndVertical(); - } - - - if(selectionCount <= 1) - { - r = EditorGUILayout.BeginVertical("box"); - Rect r2 = r; - r2.height = 20; - - - if (GUI.Button(r2, GUIContent.none,dropDownButton)) - _flare.EditOcclusion = _flare.EditOcclusion ? false : true; - - - GUILayout.Label("Occlusion"); - - if(_flare.EditOcclusion){GUILayout.Space(5f); - _flare.RaycastPhysics = EditorGUILayout.Toggle("Raycast Against Physics",_flare.RaycastPhysics); - GUI.enabled = _flare.RaycastPhysics; - _flare.mask = LayerMaskField(_flare.mask); - - FlareEditorHelper.DrawGuiInBoxDivider(); - EditorGUILayout.LabelField("Debug Info :"); - EditorGUILayout.Toggle(" Flare Occluded",_flare.Occluded); - EditorGUILayout.ObjectField(" Occluding GameObject", _flare.OccludingObject, typeof(GameObject), true); - GUI.enabled = true; - } - EditorGUILayout.EndVertical(); - } - - if(selectionCount <= 1) - { - r = EditorGUILayout.BeginVertical("box"); - Rect r2 = r; - r2.height = 20; - - - if (GUI.Button(r2, GUIContent.none,dropDownButton)) - _flare.IoSetting = _flare.IoSetting ? false : true; - - - GUILayout.Label("Import/Export"); - - if(_flare.IoSetting){GUILayout.Space(5f); - - if(_flare._Atlas != null){ - TextAsset ta = EditorGUILayout.ObjectField("Flare JSON Import, Drag/Drop Here", null, typeof(TextAsset), false) as TextAsset; - - if (ta != null) - { - FlareJson.LoadFlareData(_flare, ta); - Updated = true; - } - - if(GUILayout.Button("Export Flare Json Data")){ - ProFlareExporter.ExportFlare(_flare); - } - }else{ - - GUILayout.Label("Connect Flare Atlast Before Import Or Exporting Flare."); - - - } - } - EditorGUILayout.EndVertical(); - } - - - - FlareEditorHelper.DrawGuiDivider(); - - EditorGUILayout.LabelField("Element Settings :",title); - GUILayout.Space(10f); - - if(selectionCount > 1){ - EditorGUILayout.HelpBox("Editing flare elements is not supported in while multiple flares selected.", MessageType.Warning,false); - }else{ - if(_flare._Atlas != null) - for(int i = 0; i < _flare.Elements.Count;i++) - ElementEditor(_flare.Elements[i],(i+1)); - - - if(_flare._Atlas != null) - if(GUILayout.Button("ADD NEW",thinButton)){ - ProFlareElement element = new ProFlareElement(); - - element.flare = _flare; - element.SpriteName = _flare._Atlas.elementsList[0].name; - element.flareAtlas = _flare._Atlas; - element.position = -1; - element.Scale = 1; - - for(int i = 0; i < _flare.FlareBatches.Length; i++){ - _flare.FlareBatches[i].dirty = true; - } - //_flare._FlareBatch.dirty = true; - _flare.Elements.Add(element); - } - } - FlareEditorHelper.DrawGuiDivider(); - - if (GUI.changed||Updated) - { - //Debug.Log("dirty:"); - Updated = false; - guiChanged = true; - EditorUtility.SetDirty (target); - - if(selectionCount > 1) - foreach(GameObject go in Selection.gameObjects){ - - ProFlare selectedFlare = go.GetComponent<ProFlare>(); - if(selectedFlare) - EditorUtility.SetDirty(selectedFlare); - } - } - } - - public bool Updated = false; - - - void ElementEditor(ProFlareElement element,int count){ - - ProFlareElement.Type elementType; - - EditorGUILayout.BeginHorizontal(); - { - // - if(GUILayout.Button(" ",thinButton,GUILayout.MaxWidth(35))){ - - } - if(GUILayout.Button(" ",thinButton,GUILayout.MaxWidth(32))) - element.Visible = element.Visible ? false : true; - - - Rect rect2 = GUILayoutUtility.GetLastRect(); - - int extra = 0; -#if UNITY_4_3 - extra = 15; -#endif - - Rect outerRect = new Rect(35+extra,rect2.yMin-4,32,32); - Rect final = new Rect(0,0,1,1); - - - if( visibility_On == null) { - visibility_On = Resources.Load("visibility-On") as Texture2D; - } - if( visibility_Off == null) { - visibility_Off = Resources.Load("visibility-Off") as Texture2D; - } - - if(element.Visible) - GUI.DrawTextureWithTexCoords(outerRect,visibility_On, final, true); - else - GUI.DrawTextureWithTexCoords(outerRect,visibility_Off, final, true); - - _flare._Atlas.UpdateElementNameList(); - - int id = EditorGUILayout.Popup(element.elementTextureID, _flare._Atlas.elementNameList,enumStyleButton,GUILayout.MaxWidth(200)); - - - if(element.elementTextureID != id){ - - Debug.Log("Changing Sprite " + element.flareAtlas.elementsList[id].name); - - element.elementTextureID = id; - element.SpriteName = element.flareAtlas.elementsList[id].name; - - for(int f = 0; f < element.flare.FlareBatches.Length; f++){ - element.flare.FlareBatches[f].dirty = true; - } - } - - - elementType = (ProFlareElement.Type)EditorGUILayout.EnumPopup(element.type,enumStyleButton,GUILayout.MaxWidth(100)); - - if(GUILayout.Button("EDIT",thinButton,GUILayout.MaxWidth(80))){ - if(element.Editing) - element.Editing = false; - else{ - - element.ElementSetting = false; - element.OffsetSetting = false; - element.ColorSetting = false; - element.ScaleSetting = false; - element.RotationSetting = false; - element.OverrideSetting = false; - - element.Editing = true; - } - } - - if(GUILayout.Button("CLONE",thinButton)){ - element.Editing = false; - _flare.Elements.Add(CloneElement(element)); - //_flare._FlareBatch.dirty = true; - for(int i = 0; i < _flare.FlareBatches.Length; i++){ - _flare.FlareBatches[i].dirty = true; - } - } - - - if(GUILayout.Button("REMOVE",thinButtonRed)){ - for(int i = 0; i < _flare.FlareBatches.Length; i++){ - _flare.FlareBatches[i].dirty = true; - } -// element.flare._FlareBatch.dirty = true; - element.flare.Elements.Remove(element); - return; - } - } - EditorGUILayout.EndHorizontal(); - //Preview Texture Renderer - { - int extra = 0; - #if UNITY_4_3 - extra = 15; - #endif - - Rect rect2 = GUILayoutUtility.GetLastRect(); - - Rect outerRect = new Rect(10+extra,rect2.yMin+1,22,22); - - if(_flare._Atlas) - if(_flare._Atlas.texture) - if((element.elementTextureID < _flare._Atlas.elementsList.Count)) - GUI.DrawTextureWithTexCoords(outerRect, _flare._Atlas.texture, _flare._Atlas.elementsList[element.elementTextureID].UV, false); - } - - { - if((element.colorTexture == null)||element.colorTextureDirty){ - if(element.useColorRange) - element.colorTexture = CreateGradientTex(element,element.SubElementColor_Start,element.SubElementColor_End); - else - element.colorTexture = CreateGradientTex(element,element.ElementTint,element.ElementTint); - } - - int extra = 0; - #if UNITY_4_3 - extra = 15; - #endif - - Rect rect2 = GUILayoutUtility.GetLastRect(); - Rect outerRect = new Rect(3+extra,rect2.yMin+1,6,22); - Rect UV = new Rect(0,0,1,1); - - GUI.DrawTextureWithTexCoords(outerRect, element.colorTexture, UV, false); - - } - - if(element.type != elementType){ - element.type = elementType; - - - switch(elementType){ - case(ProFlareElement.Type.Single): - break; - case(ProFlareElement.Type.Multi): - - if(element.subElements.Count == 0) - { - for(int i = 0; i < 5; i++){ - SubElement sub = new SubElement(); - sub.random = Random.Range(0f,1f); - sub.random2 = Random.Range(0f,1f); - sub.RandomColorSeedR = Random.Range(-1f,1f); - sub.RandomColorSeedG = Random.Range(-1f,1f); - sub.RandomColorSeedB = Random.Range(-1f,1f); - element.subElements.Add(sub); - } - element.useRangeOffset = true; - element.Editing = true; - } - break; - } - - for(int f = 0; f < element.flare.FlareBatches.Length; f++){ - element.flare.FlareBatches[f].dirty = true; - } - } - - if(element.Editing ){ - QuickEdit(element,count); - - if(element.type == ProFlareElement.Type.Multi) - ElementOptions(element,count); - - OffsetOptions(element,count); - ColorOptions(element,count); - ScaleOptions(element,count); - RotationOptions(element,count); - OverrideOptions(element,count); - } - } - - void QuickEdit(ProFlareElement element,int count){ - - EditorGUILayout.BeginVertical("box"); - - EditorGUILayout.BeginHorizontal(); - { - GUILayout.Label("Quick Edit -",GUILayout.MaxWidth(80)); - - element.Scale = EditorGUILayout.Slider(element.Scale,0f,5f,GUILayout.MaxWidth(180)); - GUILayout.FlexibleSpace(); - if(!element.useColorRange){ - element.ElementTint = EditorGUILayout.ColorField(element.ElementTint,GUILayout.MaxWidth(60)); - - if(GUI.changed) - element.colorTextureDirty = true; - - // byte TintA = (byte)EditorGUILayout.Slider(element.Tint.a,0f,1f,GUILayout.MaxWidth(180)); - - // if(TintA != element.Tint.a){ - // element.Tint.a = TintA; - // } - - float TintA = EditorGUILayout.Slider(element.ElementTint.a,0f,1f,GUILayout.MaxWidth(180)); - - if(TintA != element.ElementTint.a){ - element.ElementTint.a = TintA; - } - - }else{ - element.SubElementColor_Start = EditorGUILayout.ColorField(element.SubElementColor_Start,GUILayout.MaxWidth(60)); - element.SubElementColor_End = EditorGUILayout.ColorField(element.SubElementColor_End,GUILayout.MaxWidth(60)); - - if(GUI.changed) - element.colorTextureDirty = true; - - for(int i = 0; i < element.subElements.Count; i++){ - element.subElements[i].color = Color.Lerp(element.SubElementColor_Start,element.SubElementColor_End,element.subElements[i].random); - } - } - } - - EditorGUILayout.EndHorizontal(); - - EditorGUILayout.EndVertical(); - } - - void ElementOptions(ProFlareElement element,int count){ - - Rect r = EditorGUILayout.BeginVertical("box"); - Rect r2 = r; - - r2.height = 20; - - if (GUI.Button(r2, GUIContent.none,dropDownButton)) - element.ElementSetting = element.ElementSetting ? false : true; - - GUILayout.Label("Multi Element Options"); - - if(!element.ElementSetting){ - EditorGUILayout.EndVertical(); - return; - } - - GUILayout.Space(5f); - - if(element.type == ProFlareElement.Type.Multi){ - - EditorGUILayout.BeginHorizontal(); - { - - EditorGUILayout.LabelField("Sub Elements Count : "+element.subElements.Count); - - if(GUILayout.Button("+")){ - SubElement sub = new SubElement(); - - sub.random = Random.Range(0f,1f); - sub.random2 = Random.Range(0f,1f); - - sub.RandomScaleSeed = Random.Range(-1f,1f); - sub.RandomColorSeedR = Random.Range(-1f,1f); - sub.RandomColorSeedG = Random.Range(-1f,1f); - sub.RandomColorSeedB = Random.Range(-1f,1f); - sub.RandomColorSeedA = Random.Range(-1f,1f); - - element.subElements.Add(sub); - - for(int f = 0; f < element.flare.FlareBatches.Length; f++){ - element.flare.FlareBatches[f].dirty = true; - } - } - if(GUILayout.Button("-")){ - //SubElement sub = new SubElement(); - if(element.subElements.Count > 0){ - element.subElements.Remove(element.subElements[element.subElements.Count-1]); - - - for(int f = 0; f < element.flare.FlareBatches.Length; f++){ - element.flare.FlareBatches[f].dirty = true; - } - } - } - - if(GUILayout.Button("Update Random Seed")){ - for(int i = 0; i < element.subElements.Count; i++){ - Updated = true; - element.subElements[i].random = Random.Range(0f,1f); - element.subElements[i].random2 = Random.Range(0f,1f); - element.subElements[i].RandomScaleSeed = Random.Range(-1f,1f); - element.subElements[i].RandomColorSeedR = Random.Range(-1f,1f); - element.subElements[i].RandomColorSeedG = Random.Range(-1f,1f); - element.subElements[i].RandomColorSeedB = Random.Range(-1f,1f); - element.subElements[i].RandomColorSeedA = Random.Range(-1f,1f); - } - } - } - EditorGUILayout.EndHorizontal(); - } - EditorGUILayout.EndVertical(); - } - - - void ColorOptions(ProFlareElement element,int count){ - - Rect r = EditorGUILayout.BeginVertical("box"); - Rect r2 = r; - r2.height = 20; - - - if (GUI.Button(r2, GUIContent.none,dropDownButton)) - element.ColorSetting = element.ColorSetting ? false : true; - - - GUILayout.Label("Color Options"); - { - - if(element.ColorSetting){ - GUILayout.Space(5f); - if(element.type == ProFlareElement.Type.Single){ - element.ElementTint = EditorGUILayout.ColorField("Tint",element.ElementTint); - - }else{ - - EditorGUILayout.BeginHorizontal(); - { - - element.useColorRange = EditorGUILayout.Toggle("Use Color Tint Range",element.useColorRange); - - if(!element.useColorRange){ - element.ElementTint = EditorGUILayout.ColorField("Tint",element.ElementTint); - }else{ - element.SubElementColor_Start = EditorGUILayout.ColorField(element.SubElementColor_Start); - element.SubElementColor_End = EditorGUILayout.ColorField(element.SubElementColor_End); - } - } - EditorGUILayout.EndHorizontal(); - - EditorGUILayout.LabelField("Color Random"); - element.RandomColorAmount.x = EditorGUILayout.Slider(" R",element.RandomColorAmount.x,0f,1f); - element.RandomColorAmount.y = EditorGUILayout.Slider(" G",element.RandomColorAmount.y,0f,1f); - element.RandomColorAmount.z = EditorGUILayout.Slider(" B",element.RandomColorAmount.z,0f,1f); - element.RandomColorAmount.w = EditorGUILayout.Slider(" Brightness",element.RandomColorAmount.w,0f,1f); - } - } - - if(element.type == ProFlareElement.Type.Single){ - - }else{ - if(!element.useColorRange){ - - for(int i = 0; i < element.subElements.Count; i++){ - Color col = element.ElementTint; - - col.r = Mathf.Clamp01( col.r+(element.RandomColorAmount.x*element.subElements[i].RandomColorSeedR)); - col.g = Mathf.Clamp01( col.g+(element.RandomColorAmount.y*element.subElements[i].RandomColorSeedG)); - col.b = Mathf.Clamp01( col.b+(element.RandomColorAmount.z*element.subElements[i].RandomColorSeedB)); - col.a = Mathf.Clamp01( col.a+(element.RandomColorAmount.w*element.subElements[i].RandomColorSeedA)); - - element.subElements[i].color = col; - } - }else{ - - for(int i = 0; i < element.subElements.Count; i++){ - Color col = Color.Lerp(element.SubElementColor_Start,element.SubElementColor_End,element.subElements[i].random); - - col.r = Mathf.Clamp01(col.r+(element.RandomColorAmount.x*element.subElements[i].RandomColorSeedR)); - col.g = Mathf.Clamp01(col.g+(element.RandomColorAmount.y*element.subElements[i].RandomColorSeedG)); - col.b = Mathf.Clamp01(col.b+(element.RandomColorAmount.z*element.subElements[i].RandomColorSeedB)); - col.a = Mathf.Clamp01(col.a+(element.RandomColorAmount.w*element.subElements[i].RandomColorSeedA)); - - element.subElements[i].color = col; - } - - } - } - } - EditorGUILayout.EndVertical(); - } - - void OffsetOptions(ProFlareElement element,int count){ - - Rect r = EditorGUILayout.BeginVertical("box"); - Rect r2 = r; - r2.height = 20; - - - if (GUI.Button(r2, GUIContent.none,dropDownButton)) - element.OffsetSetting = element.OffsetSetting ? false : true; - - - GUILayout.Label("Offset Options"); - - { - if(element.OffsetSetting){ - GUILayout.Space(5f); - if(element.type == ProFlareElement.Type.Single){ - element.position = EditorGUILayout.Slider("OffSet",element.position,-1.5f,2.5f); - - }else{ - - EditorGUILayout.BeginHorizontal(); - { - - element.useRangeOffset = EditorGUILayout.Toggle("Use offset range",element.useRangeOffset); - - if(element.useRangeOffset){ - - float minTemp = element.SubElementPositionRange_Min; - float maxTemp = element.SubElementPositionRange_Max; - - - EditorGUILayout.MinMaxSlider(ref element.SubElementPositionRange_Min ,ref element.SubElementPositionRange_Max,-4.5f,4.5f); - - if((minTemp != element.SubElementPositionRange_Min)||(maxTemp != element.SubElementPositionRange_Max)||Updated){ - - } - - for(int i = 0; i < element.subElements.Count; i++){ - element.subElements[i].position = Mathf.Lerp(element.SubElementPositionRange_Min,element.SubElementPositionRange_Max,element.subElements[i].random); - element.subElements[i].scale = Mathf.Lerp(-100f,100f,element.subElements[i].random2); - Updated = true; - } - - EditorGUILayout.FloatField(element.SubElementPositionRange_Min,GUILayout.MaxWidth(30)); - - EditorGUILayout.FloatField(element.SubElementPositionRange_Max,GUILayout.MaxWidth(30)); - - }else{ - element.position = EditorGUILayout.Slider(element.position,-1.5f,2.5f); - } - } - EditorGUILayout.EndHorizontal(); - } - - - EditorGUILayout.LabelField("Anamorphic"); - float x = EditorGUILayout.Slider("Vertical ",element.Anamorphic.x,0f,1f); - float y = EditorGUILayout.Slider("Horizontal ",element.Anamorphic.y,0f,1f); - element.Anamorphic = new Vector2(x,y); - - - element.OffsetPostion = EditorGUILayout.Vector2Field("Position Offset", element.OffsetPostion); - - } - - if(element.type == ProFlareElement.Type.Single){ - - } - if(element.type == ProFlareElement.Type.Multi){ - for(int i = 0; i < element.subElements.Count; i++){ - element.subElements[i].position = Mathf.Lerp(element.SubElementPositionRange_Min,element.SubElementPositionRange_Max,element.subElements[i].random); - element.subElements[i].scale = Mathf.Lerp(-100f,100f,element.subElements[i].random2); - } - } - - }EditorGUILayout.EndVertical(); - } - - - void ScaleOptions(ProFlareElement element,int count){ - - Rect r = EditorGUILayout.BeginVertical("box"); - Rect r2 = r; - r2.height = 20; - - - if (GUI.Button(r2, GUIContent.none,dropDownButton)) - element.ScaleSetting = element.ScaleSetting ? false : true; - - - GUILayout.Label("Scale Options"); - - { - if(element.ScaleSetting){ - - GUILayout.Space(5f); - - EditorGUILayout.BeginHorizontal(); - { - EditorGUILayout.LabelField("Scale"); - element.Scale = EditorGUILayout.Slider(element.Scale,0f,5f); - } - EditorGUILayout.EndHorizontal(); - - //EditorGUILayout.BeginHorizontal(); - { - EditorGUILayout.LabelField("Aspect",GUILayout.MinWidth(120)); - element.size.x = Mathf.Max(0f, EditorGUILayout.FloatField(" X", element.size.x)); - element.size.y = Mathf.Max(0f, EditorGUILayout.FloatField(" Y",element.size.y)); - } - //EditorGUILayout.EndHorizontal(); - - - - - if(element.type == ProFlareElement.Type.Multi){ - - element.ScaleRandom = EditorGUILayout.Slider("Random Scale",element.ScaleRandom,0,1f); - - EditorGUILayout.BeginHorizontal(); - { - - element.useScaleCurve = EditorGUILayout.Toggle("Use Scale Range",element.useScaleCurve,GUILayout.MaxWidth(180)); - - GUI.enabled = element.useScaleCurve; - - if(element.useScaleCurve) - Updated = true; - - if(element.type == ProFlareElement.Type.Multi){ - element.ScaleCurve = EditorGUILayout.CurveField(element.ScaleCurve); - } - - if(GUILayout.Button("Reset",GUILayout.MaxWidth(50))){ - element.ScaleCurve = new AnimationCurve(new Keyframe(0, 0.1f), new Keyframe(0.5f, 1.0f), new Keyframe(1.0f, 0.1f)); - } - - GUI.enabled = true; - } - EditorGUILayout.EndHorizontal(); - } - } - } - - if(element.type == ProFlareElement.Type.Multi){ - for(int i = 0; i < element.subElements.Count; i++){ - if(element.useScaleCurve) - element.subElements[i].scale = (1+element.subElements[i].RandomScaleSeed*(element.ScaleRandom))*element.ScaleCurve.Evaluate(element.subElements[i].random); - else - element.subElements[i].scale = (1+element.subElements[i].RandomScaleSeed*(element.ScaleRandom)); - } - } - - EditorGUILayout.EndVertical(); - } - - void RotationOptions(ProFlareElement element,int count){ - - Rect r = EditorGUILayout.BeginVertical("box"); - Rect r2 = r; - r2.height = 20; - - - if (GUI.Button(r2, GUIContent.none,dropDownButton)) - element.RotationSetting = element.RotationSetting ? false : true; - - - GUILayout.Label("Rotation Options"); - { - - if(element.RotationSetting){ - GUILayout.Space(5f); - - element.angle = EditorGUILayout.FloatField("Angle",element.angle); - - if(element.type == ProFlareElement.Type.Multi){ - element.useStarRotation = EditorGUILayout.Toggle("Use Star Rotation",element.useStarRotation); - element.useRandomAngle = EditorGUILayout.Toggle("Use Random Rotation",element.useRandomAngle); - - - if(element.useStarRotation){ - for(int i = 0; i < element.subElements.Count; i++){ - element.subElements[i].angle = (180f/element.subElements.Count)*i; - Updated = true; - } - }else{ - for(int i = 0; i < element.subElements.Count; i++){ - element.subElements[i].angle = 0; - Updated = true; - } - } - - if(element.useRandomAngle){ - - float minTemp = element.SubElementAngleRange_Min; - float maxTemp = element.SubElementAngleRange_Max; - - EditorGUILayout.BeginHorizontal(); - { - - EditorGUILayout.MinMaxSlider(ref element.SubElementAngleRange_Min ,ref element.SubElementAngleRange_Max,-180f,180f); - - EditorGUILayout.FloatField(element.SubElementAngleRange_Min); - - EditorGUILayout.FloatField(element.SubElementAngleRange_Max); - - if((minTemp != element.SubElementAngleRange_Min)||(maxTemp != element.SubElementAngleRange_Max)||Updated){ - for(int i = 0; i < element.subElements.Count; i++){ - - element.subElements[i].angle = element.subElements[i].angle+Mathf.Lerp(-element.SubElementAngleRange_Min,element.SubElementAngleRange_Max,element.subElements[i].random2); - Updated = true; - } - - } - - } - EditorGUILayout.EndHorizontal(); - - } - } - element.rotateToFlare = EditorGUILayout.Toggle("Rotate To Flare",element.rotateToFlare); - element.rotationSpeed = EditorGUILayout.FloatField("Movement Based Rotation",element.rotationSpeed); - element.rotationOverTime = EditorGUILayout.FloatField("Rotation Overtime Speed",element.rotationOverTime); - } - } - EditorGUILayout.EndVertical(); - } - - void OverrideOptions(ProFlareElement element,int count){ - - - Rect r = EditorGUILayout.BeginVertical("box"); - Rect r2 = r; - r2.height = 20; - - - if (GUI.Button(r2, GUIContent.none,dropDownButton)) - element.OverrideSetting = element.OverrideSetting ? false : true; - - - GUILayout.Label("Override Options"); - { - - if(element.OverrideSetting){ - GUILayout.Space(5f); - GUI.enabled = element.flare.useDynamicEdgeBoost; - EditorGUILayout.BeginHorizontal(); - { - element.OverrideDynamicEdgeBoost = EditorGUILayout.Toggle("Dynamic Edge Scale",element.OverrideDynamicEdgeBoost); - GUILayout.FlexibleSpace(); - if(element.OverrideDynamicEdgeBoost) - element.DynamicEdgeBoostOverride = EditorGUILayout.FloatField(" ",element.DynamicEdgeBoostOverride); - } - EditorGUILayout.EndHorizontal(); - - EditorGUILayout.BeginHorizontal();{ - element.OverrideDynamicEdgeBrightness = EditorGUILayout.Toggle("Dynamic Edge Brightness",element.OverrideDynamicEdgeBrightness); - - if(element.OverrideDynamicEdgeBrightness) - element.DynamicEdgeBrightnessOverride = EditorGUILayout.FloatField(" ",element.DynamicEdgeBrightnessOverride); - } - EditorGUILayout.EndHorizontal(); - - GUI.enabled = true; - GUI.enabled = element.flare.useDynamicCenterBoost; - - EditorGUILayout.BeginHorizontal(); - { - element.OverrideDynamicCenterBoost = EditorGUILayout.Toggle("Dynamic Center Scale",element.OverrideDynamicCenterBoost); - - if(element.OverrideDynamicCenterBoost) - element.DynamicCenterBoostOverride = EditorGUILayout.FloatField(" ",element.DynamicCenterBoostOverride); - } - EditorGUILayout.EndHorizontal(); - - - EditorGUILayout.BeginHorizontal(); - { - element.OverrideDynamicCenterBrightness = EditorGUILayout.Toggle("Dynamic Center Brightness",element.OverrideDynamicCenterBrightness); - - if(element.OverrideDynamicCenterBrightness) - element.DynamicCenterBrightnessOverride = EditorGUILayout.FloatField(" ",element.DynamicCenterBrightnessOverride); - } - EditorGUILayout.EndHorizontal(); - - GUI.enabled = true; - } - - } - EditorGUILayout.EndVertical(); - } - - Texture2D CreateGradientTex (ProFlareElement element, Color c0, Color c1) - { - if(element.colorTexture != null){ - DestroyImmediate(element.colorTexture); - element.colorTexture = null; - } - - element.colorTexture = new Texture2D(1, 16); - element.colorTexture.name = "[ProFlare] Gradient Texture"; - element.colorTexture.hideFlags = HideFlags.DontSave; - - - for (int i = 0; i < 16; ++i) - { - float f = i*(1f/16f); - element.colorTexture.SetPixel(0, i, Color.Lerp(c0, c1, f)); - } - - element.colorTexture.Apply(); - element.colorTexture.filterMode = FilterMode.Bilinear; - return element.colorTexture; - } - - - public int LayerMaskField (LayerMask selected) { - - ArrayList layers = new ArrayList (); - - ArrayList layerNumbers = new ArrayList (); - - string name = ""; - - for (int i=0;i<32;i++) { - - string layerName = LayerMask.LayerToName (i); - - if (layerName != "") { - - if (selected == (selected | (1 << i))) { - - layers.Add ("✓ "+layerName); - - name += layerName+", "; - } else { - layers.Add (" "+layerName); - } - layerNumbers.Add (i); - } - } - - bool preChange = GUI.changed; - - GUI.changed = false; - - int[] LayerNumbers = layerNumbers.ToArray (typeof(int)) as int[]; - - int newSelected = EditorGUILayout.Popup ("Layer Mask",-1,layers.ToArray(typeof(string)) as string[],EditorStyles.layerMaskField); - - if (GUI.changed) { - - if (selected == (selected | (1 << LayerNumbers[newSelected]))) { - - selected &= ~(1 << LayerNumbers[newSelected]); - - Debug.Log ("Set Layer "+LayerMask.LayerToName (LayerNumbers[newSelected]) + " To False "+selected.value); - - } else { - - Debug.Log ("Set Layer "+LayerMask.LayerToName (LayerNumbers[newSelected]) + " To True "+selected.value); - - selected = selected | (1 << LayerNumbers[newSelected]); - - } - - } else { - - GUI.changed = preChange; - - } - return selected; - } - - ProFlareElement CloneElement(ProFlareElement element){ - - ProFlareElement _element = new ProFlareElement(); - - _element.Editing = true; - - _element.Visible = element.Visible; - - _element.elementTextureID = element.elementTextureID; - - _element.SpriteName = element.SpriteName; - - _element.flare = element.flare; - - _element.flareAtlas = element.flareAtlas; - - _element.Brightness = element.Brightness; - _element.Scale = element.Scale; - _element.ScaleRandom = element.ScaleRandom; - _element.ScaleFinal = element.ScaleFinal; - - _element.RandomColorAmount = element.RandomColorAmount; - - //Element OffSet Properties - _element.position = element.position; - - _element.useRangeOffset = element.useRangeOffset; - - _element.SubElementPositionRange_Min = element.SubElementPositionRange_Min; - _element.SubElementPositionRange_Max = element.SubElementPositionRange_Max; - - _element.SubElementAngleRange_Min = element.SubElementAngleRange_Min; - _element.SubElementAngleRange_Max = element.SubElementAngleRange_Max; - - - _element.OffsetPosition = element.OffsetPosition; - - _element.Anamorphic = element.Anamorphic; - - _element.OffsetPostion = element.OffsetPostion; - - _element.angle = element.angle; - _element.FinalAngle = element.FinalAngle; - _element.useRandomAngle = element.useRandomAngle; - _element.useStarRotation = element.useStarRotation; - _element.AngleRandom_Min = element.AngleRandom_Min; - _element.AngleRandom_Max = element.AngleRandom_Max; - _element.OrientToSource = element.OrientToSource; - _element.rotateToFlare = element.rotateToFlare; - _element.rotationSpeed = element.rotationSpeed; - _element.rotationOverTime = element.rotationOverTime; - - _element.useColorRange = element.useColorRange; - - _element.ElementFinalColor = element.ElementFinalColor; - - _element.ElementTint = element.ElementTint; - - _element.SubElementColor_Start = element.SubElementColor_Start; - _element.SubElementColor_End = element.SubElementColor_End; - - _element.useScaleCurve = element.useScaleCurve; - _element.ScaleCurve = new AnimationCurve(element.ScaleCurve.keys); - - - _element.OverrideDynamicEdgeBoost = element.OverrideDynamicEdgeBoost; - _element.DynamicEdgeBoostOverride = element.DynamicEdgeBoostOverride; - - _element.OverrideDynamicCenterBoost = element.OverrideDynamicCenterBoost; - _element.DynamicCenterBoostOverride = element.DynamicCenterBoostOverride; - - _element.OverrideDynamicEdgeBrightness = element.OverrideDynamicEdgeBrightness; - _element.DynamicEdgeBrightnessOverride = element.DynamicEdgeBrightnessOverride; - - _element.OverrideDynamicCenterBrightness = element.OverrideDynamicCenterBrightness; - _element.DynamicCenterBrightnessOverride = element.DynamicCenterBrightnessOverride; - - _element.size = element.size; - - for(int i = 0; i < element.subElements.Count; i++){ - - SubElement Sub = new SubElement(); - - Sub.color = element.subElements[i].color; - Sub.position = element.subElements[i].position; - Sub.offset = element.subElements[i].offset; - Sub.angle = element.subElements[i].angle; - Sub.scale = element.subElements[i].scale; - Sub.random = element.subElements[i].random; - Sub.random2= element.subElements[i].random2; - - - Sub.RandomScaleSeed = element.subElements[i].RandomScaleSeed; - Sub.RandomColorSeedR = element.subElements[i].RandomColorSeedR; - Sub.RandomColorSeedG = element.subElements[i].RandomColorSeedG; - Sub.RandomColorSeedB = element.subElements[i].RandomColorSeedB; - Sub.RandomColorSeedA = element.subElements[i].RandomColorSeedA; - - _element.subElements.Add(Sub); - } - - _element.type = element.type; - - return _element; - - } - - void OnSceneGUI () { - _flare = target as ProFlare; - if(!_flare.UseAngleLimit) - return; - - Handles.color = new Color(1f,1f,1f,0.2f); - - Handles.DrawSolidArc(_flare.transform.position, - _flare.transform.up, - _flare.transform.forward, - _flare.maxAngle/2, - 5); - - Handles.DrawSolidArc(_flare.transform.position, - _flare.transform.up, - _flare.transform.forward, - -_flare.maxAngle/2, - 5); - - Handles.color = Color.white; - - //Handles.ScaleValueHandle(_flare.maxAngle, - // _flare.transform.position + _flare.transform.forward*5, - // _flare.transform.rotation, - // 1, - // Handles.ConeCap, - // 2); - } -} diff --git a/Assets/ProFlares/Editor/ProFlareInspector.cs.meta b/Assets/ProFlares/Editor/ProFlareInspector.cs.meta deleted file mode 100644 index 0db9966..0000000 --- a/Assets/ProFlares/Editor/ProFlareInspector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1fd7269d6f0ea374ba2efc6a89068ffb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ProFlares/Editor/Resources.meta b/Assets/ProFlares/Editor/Resources.meta deleted file mode 100644 index 5bc65f8..0000000 --- a/Assets/ProFlares/Editor/Resources.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3d6b2216e2b2d7048b5d6bfe78890d72 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ProFlares/Editor/Resources/visibility-Off.png b/Assets/ProFlares/Editor/Resources/visibility-Off.png Binary files differdeleted file mode 100644 index f42bc78..0000000 --- a/Assets/ProFlares/Editor/Resources/visibility-Off.png +++ /dev/null diff --git a/Assets/ProFlares/Editor/Resources/visibility-Off.png.meta b/Assets/ProFlares/Editor/Resources/visibility-Off.png.meta deleted file mode 100644 index 66bd174..0000000 --- a/Assets/ProFlares/Editor/Resources/visibility-Off.png.meta +++ /dev/null @@ -1,106 +0,0 @@ -fileFormatVersion: 2 -guid: fe1e62a8b79639046bdfd9e02caf8f15 -TextureImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 11 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - sRGBTexture: 1 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - streamingMipmaps: 0 - streamingMipmapsPriority: 0 - vTOnly: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: -1 - maxTextureSize: 1024 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: -1 - mipBias: -100 - wrapU: -1 - wrapV: -1 - wrapW: -1 - nPOTScale: 1 - lightmap: 0 - compressionQuality: 50 - spriteMode: 0 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 - alphaUsage: 1 - alphaIsTransparency: 0 - spriteTessellationDetail: -1 - textureType: 0 - textureShape: 1 - singleChannelComponent: 0 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - ignorePngGamma: 0 - applyGammaDecoding: 1 - platformSettings: - - serializedVersion: 3 - buildTarget: DefaultTexturePlatform - maxTextureSize: 1024 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - - serializedVersion: 3 - buildTarget: iPhone - maxTextureSize: 32 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 0 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 1 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - bones: [] - spriteID: - internalID: 0 - vertices: [] - indices: - edges: [] - weights: [] - secondaryTextures: [] - spritePackingTag: - pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ProFlares/Editor/Resources/visibility-On.png b/Assets/ProFlares/Editor/Resources/visibility-On.png Binary files differdeleted file mode 100644 index 5ed55dc..0000000 --- a/Assets/ProFlares/Editor/Resources/visibility-On.png +++ /dev/null diff --git a/Assets/ProFlares/Editor/Resources/visibility-On.png.meta b/Assets/ProFlares/Editor/Resources/visibility-On.png.meta deleted file mode 100644 index 9ed2589..0000000 --- a/Assets/ProFlares/Editor/Resources/visibility-On.png.meta +++ /dev/null @@ -1,106 +0,0 @@ -fileFormatVersion: 2 -guid: 94ff086058450464b83a46b96da6ca48 -TextureImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 11 - mipmaps: - mipMapMode: 0 - enableMipMap: 0 - sRGBTexture: 1 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - streamingMipmaps: 0 - streamingMipmapsPriority: 0 - vTOnly: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: -1 - maxTextureSize: 1024 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: -1 - mipBias: -100 - wrapU: -1 - wrapV: -1 - wrapW: -1 - nPOTScale: 1 - lightmap: 0 - compressionQuality: 50 - spriteMode: 0 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 - alphaUsage: 1 - alphaIsTransparency: 0 - spriteTessellationDetail: -1 - textureType: 0 - textureShape: 1 - singleChannelComponent: 0 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - ignorePngGamma: 0 - applyGammaDecoding: 1 - platformSettings: - - serializedVersion: 3 - buildTarget: DefaultTexturePlatform - maxTextureSize: 1024 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - - serializedVersion: 3 - buildTarget: iPhone - maxTextureSize: 32 - resizeAlgorithm: 0 - textureFormat: 4 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 1 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - bones: [] - spriteID: - internalID: 0 - vertices: [] - indices: - edges: [] - weights: [] - secondaryTextures: [] - spritePackingTag: - pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 - userData: - assetBundleName: - assetBundleVariant: |