Exemple #1
0
        static void Init()
        {
            bool reset = _i == null;

            if (reset)
            {
                _i = CreateInstance <SmartTypeCreator>();
                _i.titleContent = new GUIContent("Generate Smart Types");
            }

            _i.ShowUtility();
            SetHeight();

            if (reset)
            {
                Rect pos = _i.position;
                pos.width   = WIDTH;
                _i.position = pos;

                _helpIcon = EditorGUIUtility.Load("icons/_Help.png") as Texture2D;

                _i._isParsingAssemblies = false;
                _i.ParseAssemblies();
            }

            PopulateTemplates();

            string path        = "Assets";
            int    assetLength = path.Length;

            foreach (UnityEngine.Object obj in Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.Assets))
            {
                int dpLen = Application.dataPath.Length - assetLength;
                path = Application.dataPath.Substring(0, dpLen) + AssetDatabase.GetAssetPath(obj);
                bool success = true;
                if (!Directory.Exists(path))
                {
                    path    = Path.GetDirectoryName(path);
                    success = (Directory.Exists(path));
                }
                if (success)
                {
                    _i._path = path.Substring(dpLen, path.Length - dpLen);
                    break;
                }
            }

            _i._settingsSerialized      = new SerializedObject(SmartTypeCreatorSettings.DEFAULT);
            _i._settingsCustomTemplates = _i._settingsSerialized.FindProperty("_customTemplates");
            _i._settingsExclude         = _i._settingsSerialized.FindProperty("_typeHelperExcludePatterns");
            _i._settingsFrameTime       = _i._settingsSerialized.FindProperty("_asyncTypeLoadFrameTime");
        }
Exemple #2
0
 void ClosePopup()
 {
     Close();
     Object.DestroyImmediate(_i);
     _i = null;
 }