Exemplo n.º 1
0
        public static void Initialize(bool createNewIvy)
        {
            Undo.ClearAll();

            EditorApplication.playModeStateChanged += OnPlayModeStateChanged;

            ivyParametersGUI = ScriptableObject.CreateInstance <IvyParametersGUI>();
            controller       = ScriptableObject.CreateInstance <RealIvyProWindowController>();
            controller.Init(instance, ivyParametersGUI);

            windowSkin        = (GUISkin)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("b0545e8c97ca8684182a76c2fb22c7ff"), typeof(GUISkin));
            downArrowTex      = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("8ee6aee77df7d3e4485148aa889f9b6b"), typeof(Texture2D));
            materialTex       = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("eb3b714e29c31744888e1bc4bcfe23d6"), typeof(Texture2D));
            leaveTex          = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("14bbaf6e0a8b00f4ea30434e5eeeaf8c"), typeof(Texture2D));
            dropdownShadowTex = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("9cd9a16c9e229684983f50ff07427219"), typeof(Texture2D));
            presetTex         = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("9dd821bf05e345d4a8a501a8768c7144"), typeof(Texture2D));
            infoTex           = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("d73d5146604f9594996de4e08eec4bdf"), typeof(Texture2D));

            Undo.undoRedoPerformed += MyUndoCallback;

            IvyPreset defaultPresset = GetDefaultPreset();


            if (realIvyProToolsWindow != null)
            {
                realIvyProToolsWindow.QuitWindow();
            }
            CreateTools();

            if (createNewIvy)
            {
                controller.CreateNewIvy(defaultPresset);
                ivyParametersGUI.CopyFrom(controller.infoPool.ivyParameters);
            }
        }
Exemplo n.º 2
0
        public void CastRandomIvy(Vector3 position, Quaternion rotation)
        {
            int       rndIdx         = UnityEngine.Random.Range(0, ivyPresets.Length);
            IvyPreset selectedPreset = ivyPresets[rndIdx];

            CastIvy(selectedPreset, position, rotation);
        }
Exemplo n.º 3
0
 public void Setup(InfoPool infoPool, MeshFilter meshFilter,
                   MeshRenderer meshRenderer, IvyPreset originalPreset)
 {
     this.infoPool       = infoPool;
     this.meshFilter     = meshFilter;
     this.meshRenderer   = meshRenderer;
     this.originalPreset = originalPreset;
 }
Exemplo n.º 4
0
 private static void OnScriptsReloaded()
 {
     if (EditorPrefs.GetBool(KEY_WINDOW_OPENED, false))
     {
         Init();
         IvyPreset preset = GetDefaultPreset();
         controller.OnScriptReloaded(preset);
     }
 }
        public InfoPool CreateNewIvy(IvyPreset selectedPreset)
        {
            this.selectedPreset = selectedPreset;

            IvyParameters parameters = new IvyParameters();

            parameters.CopyFrom(selectedPreset);

            return(CreateNewIvy(parameters));
        }
        public void SaveCurrentParametersAsNewPreset(string filePath)
        {
            IvyPreset newPreset = ScriptableObject.CreateInstance <IvyPreset>();

            newPreset.ivyParameters = new IvyParameters(infoPool.ivyParameters);


            AssetDatabase.CreateAsset(newPreset, filePath);
            //IvyPreset newPreset = AssetDatabase.LoadAssetAtPath(filePath, typeof(IvyPreset)) as IvyPreset;
            AssetDatabase.SaveAssets();

            OnPresetChanged(newPreset);
        }
Exemplo n.º 7
0
        private IvyPreset GetPresetByName(string presetName)
        {
            IvyPreset res = null;

            for (int i = 0; i < ivyPresets.Length; i++)
            {
                if (ivyPresets[i].name == presetName)
                {
                    res = ivyPresets[i];
                    break;
                }
            }

            return(res);
        }
 public void OnScriptReloaded(IvyPreset selectedPreset)
 {
     if (Selection.activeGameObject == null)
     {
         CreateNewIvy(selectedPreset);
     }
     else
     {
         IvyInfo selectedIvyInfo = Selection.activeGameObject.GetComponent <IvyInfo>();
         if (selectedIvyInfo != null)
         {
             ModifyIvy(selectedIvyInfo);
         }
     }
 }
Exemplo n.º 9
0
        private static IvyPreset GetDefaultPreset()
        {
            IvyPreset res = null;
            string    defaultPresetGUID = EditorPrefs.GetString("RealIvyDefaultGUID", GUID_DEFAULT_PRESET);

            res = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(defaultPresetGUID), typeof(IvyPreset)) as IvyPreset;

            if (res == null)
            {
                defaultPresetGUID = GUID_DEFAULT_PRESET;
                res = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(defaultPresetGUID), typeof(IvyPreset)) as IvyPreset;
            }

            return(res);
        }
        public void OnPresetChanged(IvyPreset newPreset)
        {
            if (newPreset)
            {
                this.selectedPreset = newPreset;
                if (currentIvyInfo != null)
                {
                    currentIvyInfo.originalPreset = selectedPreset;
                }

                string presetGUID = UIUtils.GetGUIDByAsset(selectedPreset);
                EditorPrefs.SetString("RealIvyDefaultGUID", presetGUID);

                ivyParametersGUI.CopyFrom(selectedPreset);
                realIvyProWindow.SaveParameters();
                infoPool.meshBuilder.InitLeavesData();
                realIvyProWindow.valueUpdated = true;
            }
        }
        public void ModifyIvy(IvyInfo ivyInfo)
        {
            this.currentIvyInfo = ivyInfo;
            this.selectedPreset = ivyInfo.originalPreset;

            this.infoPool = ivyInfo.infoPool;
            this.infoPool.ivyContainer.ivyGO = ivyInfo.gameObject;

            this.mf    = ivyInfo.meshFilter;
            this.mr    = ivyInfo.meshRenderer;
            this.ivyGO = ivyInfo.gameObject;

            this.infoPool.growth.growing = false;

            this.infoPool.ivyParameters.branchesMaterial = this.mr.sharedMaterials[0];

            ivyParametersGUI.CopyFrom(infoPool.ivyParameters);

            infoPool.meshBuilder.InitLeavesData();
        }
Exemplo n.º 12
0
        public void CastIvy(IvyPreset ivyPreset, Vector3 position, Quaternion rotation)
        {
            IvyController selectedIvy = GetFreeIvy();

            if (selectedIvy == null)
            {
                IvyController ivyControllerInstance = Instantiate <IvyController>(prefabIvyController);
                ivyControllerInstance.transform.parent = transform;

                selectedIvy = ivyControllerInstance;
                ivys.Add(ivyControllerInstance);
            }

            selectedIvy.transform.position = position;
            selectedIvy.transform.rotation = rotation;
            selectedIvy.transform.Rotate(Vector3.right, -90f);

            selectedIvy.ivyParameters = ivyPreset.ivyParameters;

            selectedIvy.gameObject.SetActive(true);
            selectedIvy.StartGrowth();
        }
Exemplo n.º 13
0
 public void SetIvyParameters(IvyPreset ivyPreset)
 {
     this.ivyParameters.CopyFrom(ivyPreset);
 }
Exemplo n.º 14
0
 public void CopyFrom(IvyPreset ivyPreset)
 {
     CopyFrom(ivyPreset.ivyParameters);
 }
Exemplo n.º 15
0
 private void OnPresetChanged(IvyPreset newPreset)
 {
     RealIvyWindow.controller.OnPresetChanged(newPreset);
 }
Exemplo n.º 16
0
        public void CastIvyByPresetName(string presetName, Vector3 position, Quaternion rotation)
        {
            IvyPreset ivyPreset = GetPresetByName(presetName);

            CastIvy(ivyPreset, position, rotation);
        }