Exemple #1
0
 public static void RefreshPartList()
 {
     if (PartList.Static != null)
     {
         InspectorPartList.RefreshPartPackage();
         InspectorPartList.Refresh(PartList.Static);
         EditorUtility.DisplayDialog("Refresh Part", "Parts and Add-Ons refreshed succesfully!", "Ok");
     }
 }
Exemple #2
0
 static void Play()
 {
     if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
     {
         if (PartList.Static != null)
         {
             InspectorPartList.RefreshPartPackage();
             InspectorPartList.Refresh(PartList.Static);
         }
         EditorPrefs.SetString("PlayFromStartPrevScene", EditorSceneManager.GetActiveScene().path);
         EditorSceneManager.OpenScene(startScene);
         EditorPrefs.SetBool("PlayFromStartActive", true);
         EditorApplication.isPlaying = true;
     }
 }
Exemple #3
0
        protected void createPart()
        {
            try
            {
                string filename = "";
                if (_templates[_stemp] is WeaponTemplate)
                {
                    WeaponTemplate twtemplate = (WeaponTemplate)_templates[_stemp];
                    filename = WizardUtils.PartFolder + "/" + _packstring[_spack] + "/Weapon/" + getDirectoryName(twtemplate.weaponCategory) + "/" + _partname + ".asset";
                }
                else
                {
                    filename = WizardUtils.PartFolder + "/" + _packstring[_spack] + "/" + getDirectoryName(_templates[_stemp].category) + "/" + _partname + ".asset";
                }

                string directory = Path.GetDirectoryName(filename);
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                    AssetDatabase.Refresh();
                }

                if (File.Exists(filename))
                {
                    if (!EditorUtility.DisplayDialog("Replace Part", "the part you wish to create is already exist", "Replace", "Cancel"))
                    {
                        return;
                    }
                }

                Part tpart = _templates[_stemp] is WeaponTemplate?EditorUtils.LoadScriptable <Weapon>(filename) :
                                 EditorUtils.LoadScriptable <Part>(filename);

                //..category
                tpart.category = _templates[_stemp].category;
                //category..

                //..package
                tpart.packageName = getPackageName(filename);
                //package..

                //..bodytype
                tpart.supportedBody = new List <BodyType>();
                for (int i = 0; i < _bodyopt.Length; i++)
                {
                    if (_bodyopt[i])
                    {
                        tpart.supportedBody.Add(_bodytype[i]);
                    }
                }
                //bodytype..

                //..textures
                tpart.texture   = _texture;
                tpart.colorMask = _mask;
                //textures..

                //..sprites
                if (_texture != null && _templates[_stemp].category != PartCategory.SkinDetails) //..skin details doesn't need to be sliced
                {
                    string sourcepath = AssetDatabase.GetAssetPath(_templates[_stemp].texture);
                    string targetpath = AssetDatabase.GetAssetPath(_texture);
                    tpart.sprites = SpriteSlicerUtils.SliceSprite(sourcepath, targetpath, getExcludedSprite());
                }
                else
                {
                    tpart.sprites = new List <Sprite>();
                }
                //sprites..

                if (tpart is Weapon)
                {
                    WeaponTemplate twtemplate = (WeaponTemplate)_templates[_stemp];
                    Weapon         tweapon    = (Weapon)tpart;
                    tweapon.weaponCategory = twtemplate.weaponCategory;
                    tweapon.muzzlePosition = _muzzlepos;
                    EditorUtility.SetDirty(tweapon);
                }
                else
                {
                    EditorUtility.SetDirty(tpart);
                }

                if (PartList.Static != null)
                {
                    InspectorPartList.Refresh(PartList.Static);
                }

                Selection.activeObject = tpart;

                string message = "part '" + tpart.name + "' has successfully created";
                EditorUtility.DisplayDialog("Success", message, "OK");
            }
            catch (Exception e)
            {
                EditorUtility.DisplayDialog("Error", "error on creating part: " + e.ToString(), "OK");
            }
        }