コード例 #1
0
 /// <summary> Mutes the target AudioSource </summary>
 public void Mute()
 {
     if (IsMuted) return;
     IsMuted = true;
     AudioSource.mute = true;
     if (DebugComponent) DDebug.Log("Mute '" + name + "' SoundyController", this);
 }
コード例 #2
0
        /// <summary> Resets the database to the default values </summary>
        public bool ResetDatabase()
        {
#if UNITY_EDITOR
            if (!DoozyUtils.DisplayDialog(UILabels.ResetDatabase,
                                          UILabels.AreYouSureYouWantToResetDatabase +
                                          "\n\n" +
                                          UILabels.OperationCannotBeUndone,
                                          UILabels.Yes,
                                          UILabels.No))
            {
                return(false);
            }

            for (int i = Categories.Count - 1; i >= 0; i--)
            {
                ListOfNames category = Categories[i];
                Categories.Remove(category);
                DoozyUtils.MoveAssetToTrash(AssetDatabase.GetAssetPath(category));
            }

            UpdateListOfCategoryNames();
            AddDefaultCategories(true);
            DDebug.Log(UILabels.DatabaseHasBeenReset);
#endif
            return(true);
        }
コード例 #3
0
ファイル: UIPopupManager.cs プロジェクト: Bars1704/Flatout
        /// <summary> Hides the CurrentVisibleQueuePopup (if visible) and clears the PopupQueue </summary>
        /// <param name="instantAction"> Should the CurrentVisibleQueuePopup (if visible) be hidden instantly? (animate in zero seconds) </param>
        public static void ClearQueue(bool instantAction = false)
        {
            if (CurrentVisibleQueuePopup != null)
            {
                CurrentVisibleQueuePopup.Hide(instantAction);
            }
            if (QueueIsEmpty)
            {
                return;
            }
            foreach (UIPopupQueueData data in PopupQueue)
            {
                if (data.Popup == null)
                {
                    continue;
                }
                if (data.Popup == CurrentVisibleQueuePopup)
                {
                    continue;
                }
                data.Popup.Hide(instantAction);
                data.Popup.AddedToQueue = false;
            }

            PopupQueue.Clear();
            if (Instance.DebugComponent)
            {
                DDebug.Log("PopupQueue Cleared", Instance);
            }
        }
コード例 #4
0
        public static void MoveAssetToTrash(string relativePath, string fileName, bool saveAssetDatabase = true,
                                            bool refreshAssetDatabase = true, bool printDebugMessage = true)
        {
            if (string.IsNullOrEmpty(relativePath))
            {
                return;
            }
            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }
            // ReSharper disable once SuspiciousTypeConversion.Global
//            if (!relativePath[relativePath.Length - 1].Equals(@"\")) relativePath += @"\";
            relativePath = CleanPath(relativePath);
            if (!AssetDatabase.MoveAssetToTrash(relativePath + fileName + ".asset"))
            {
                return;
            }
            if (printDebugMessage)
            {
                DDebug.Log("The " + fileName + ".asset file has been moved to trash.");
            }
            if (saveAssetDatabase)
            {
                AssetDatabase.SaveAssets();
            }
            if (refreshAssetDatabase)
            {
                AssetDatabase.Refresh();
            }
        }
コード例 #5
0
ファイル: TouchDetector.cs プロジェクト: Bars1704/Flatout
 public void OnDrag(PointerEventData eventData)
 {
     if (DebugComponent)
     {
         DDebug.Log(gameObject.name + ": " + "OnDrag", this);
     }
 }
コード例 #6
0
        /// <summary>
        /// Play the specified sound at the given position.
        /// Returns a reference to the SoundyController that is playing the sound.
        /// Returns null if no sound is found.
        /// </summary>
        /// <param name="databaseName"> The sound category </param>
        /// <param name="soundName"> Sound Name of the sound </param>
        /// <param name="position"> The position from where this sound will play from </param>
        public static SoundyController Play(string databaseName, string soundName, Vector3 position)
        {
            if (!s_initialized)
            {
                s_instance = Instance;
            }
            if (Database == null)
            {
                return(null);
            }
            if (soundName.Equals(NO_SOUND))
            {
                return(null);
            }
            SoundGroupData soundGroupData = Database.GetAudioData(databaseName, soundName);

            if (soundGroupData == null)
            {
                return(null);
            }
            if (Instance.DebugComponent)
            {
                DDebug.Log("Play '" + databaseName + "' / '" + soundName + "' SoundGroupData at " + position + " position", Instance);
            }
            return(soundGroupData.Play(position, Database.GetSoundDatabase(databaseName).OutputAudioMixerGroup));
        }
コード例 #7
0
        /// <summary>
        /// Play the specified audio clip with the given parameters (and follow a given Transform while playing).
        /// Returns a reference to the SoundyController that is playing the sound.
        /// Returns null if the AudioClip is null.
        /// </summary>
        /// <param name="audioClip"> The AudioClip to play </param>
        /// <param name="outputAudioMixerGroup"> The output audio mixer group that this sound will get routed through </param>
        /// <param name="followTarget"> The target transform that the sound will follow while playing </param>
        /// <param name="volume"> The volume of the audio source (0.0 to 1.0) </param>
        /// <param name="pitch"> The pitch of the audio source </param>
        /// <param name="loop"> Is the audio clip looping? </param>
        /// <param name="spatialBlend">
        ///     Sets how much this AudioSource is affected by 3D space calculations (attenuation,
        ///     doppler etc). 0.0 makes the sound full 2D, 1.0 makes it full 3D
        /// </param>
        public static SoundyController Play(AudioClip audioClip, AudioMixerGroup outputAudioMixerGroup,
                                            Transform followTarget = null, float volume = 1, float pitch = 1, bool loop = false,
                                            float spatialBlend     = 1)
        {
            if (!s_initialized)
            {
                s_instance = Instance;
            }
            if (audioClip == null)
            {
                return(null);
            }
            SoundyController controller = SoundyPooler.GetControllerFromPool();

            controller.SetSourceProperties(audioClip, volume, pitch, loop, spatialBlend);
            controller.SetOutputAudioMixerGroup(outputAudioMixerGroup);
            if (followTarget == null)
            {
                spatialBlend = 0;
                controller.SetFollowTarget(Pooler.transform);
            }
            else
            {
                controller.SetFollowTarget(followTarget);
            }

            controller.gameObject.name = "[AudioClip]-(" + audioClip.name + ")";
            controller.Play();
            if (Instance.DebugComponent)
            {
                DDebug.Log("Play '" + audioClip.name + "' AudioClip", Instance);
            }
            return(controller);
        }
コード例 #8
0
        /// <summary> Resets the current Value to the set reset value. The reset happens instantly if instantUpdate is passed as TRUE </summary>
        /// <param name="resetValue"> Target reset value </param>
        /// <param name="instantUpdate"> If TRUE, the value will not get animated and be changed instantly </param>
        public void ResetValueTo(ResetValue resetValue, bool instantUpdate)
        {
            switch (resetValue)
            {
            case ResetValue.ToMinValue:
                if (DebugComponent)
                {
                    DDebug.Log("[" + name + "] Resetting Value to MinValue: " + MinValue, this);
                }
                SetValue(MinValue, instantUpdate);
                break;

            case ResetValue.ToMaxValue:
                if (DebugComponent)
                {
                    DDebug.Log("[" + name + "] Resetting Value to MaxValue: " + MaxValue, this);
                }
                SetValue(MaxValue, instantUpdate);
                break;

            case ResetValue.ToCustomValue:
                if (DebugComponent)
                {
                    DDebug.Log("[" + name + "] Resetting Value to CustomResetValue: " + CustomResetValue, this);
                }
                SetValue(CustomResetValue, instantUpdate);
                break;
            }

            OnValueUpdated();
        }
コード例 #9
0

        
コード例 #10
0
        private void Awake()
        {
            if (Graph == null)
            {
                DDebug.LogError(UILabels.NoGraphReferenced + ". " + UILabels.ComponentDisabled + ".", gameObject);
                enabled = false;
                return;
            }

            if (Graph.Nodes.Count == 0)
            {
                DDebug.LogError("'" + Graph.name + "' " + UILabels.GraphHasNoNodes + ". " + UILabels.ComponentDisabled + ".", gameObject);
                enabled = false;
                return;
            }

            if (DebugComponent)
            {
                DDebug.Log(UILabels.LoadedGraph + ": " + Graph.name);
            }

            Database.Add(this);
            InitializeGraph();

            if (DontDestroyControllerOnLoad)
            {
                DontDestroyOnLoad(gameObject);
            }
        }
コード例 #11
0
        private void InitializeGraph(bool reset = true)
        {
            if (reset)
            {
                ResetController();
            }
            if (Initialized)
            {
                return;
            }

            if (Graph == null)
            {
                DDebug.LogError("Missing Graph reference...", this);
                return;
            }

            if (Graph.Nodes.Count == 0)
            {
                DDebug.LogError("No nodes have been added to the '" + Graph.name + "' Graph.", this);
                return;
            }

            if (Graph.GetStartOrEnterNode() == null)
            {
                DDebug.LogError("No start node has been set for the '" + Graph.name + "' Graph.", this);
                return;
            }


            StartCoroutine(ActivateStartOrEnterNodeEnumerator());
            //            Graph.ActivateStartOrEnterNode();
            //            Initialized = true;
        }
コード例 #12
0
 /// <summary> Unpause all the controllers that were previously paused </summary>
 public static void UnpauseAll()
 {
     if (DebugComponent) DDebug.Log("Unpause All");
     RemoveNullControllersFromDatabase();
     foreach (SoundyController controller in s_database)
         controller.Unpause();
 }
コード例 #13
0
 /// <summary> Unpause the target AudioSource if it was previously paused </summary>
 public void Unpause()
 {
     if (!IsPaused) return;
     AudioSource.UnPause();
     IsPaused = false;
     if (DebugComponent) DDebug.Log("Unpause '" + name + "' SoundyController", this);
 }
コード例 #14
0
 /// <summary> Unmute the target AudioSource if it was previously muted </summary>
 public void Unmute()
 {
     if (!IsMuted) return;
     IsMuted = false;
     AudioSource.mute = false;
     if (DebugComponent) DDebug.Log("Unmute '" + name + "' SoundyController", this);
 }
コード例 #15
0
ファイル: UIPopupManager.cs プロジェクト: Bars1704/Flatout
        /// <summary> Removes the first UIPopup registered with the given popupName from the PopupQueue (if it exists) </summary>
        /// <param name="popupName"> The popup name to search for </param>
        /// <param name="showNextInQueue"> After removing the corresponding UIPopup from the PopupQueue, should the next popup in queue be shown? </param>
        public static void RemoveFromQueue(string popupName, bool showNextInQueue = true)
        {
            if (!IsInQueue(popupName))
            {
                return;
            }
            UIPopupQueueData data = GetPopupData(popupName);

            if (data == null)
            {
                return;
            }
            PopupQueue.Remove(data);
            if (Instance.DebugComponent)
            {
                DDebug.Log("UIPopup '" + data.PopupName + "' removed from the PopupQueue", Instance);
            }
            if (data.Popup == null)
            {
                return;
            }
            data.Popup.AddedToQueue = false;
            if (CurrentVisibleQueuePopup != data.Popup)
            {
                return;
            }
            CurrentVisibleQueuePopup = null;
            if (showNextInQueue)
            {
                ShowNextInQueue();
            }
        }
コード例 #16
0

        
コード例 #17
0
ファイル: Program.cs プロジェクト: johnkocer/CodecampEFCore2
        static void Main(string[] args)
        {
            EmployeeEfCodeFirstOne2OneDBContext context = new EmployeeEfCodeFirstOne2OneDBContext();
            var employees = context.Employee.ToList();

            DDebug.LogDirConsole("Employee List: ", employees);
        }
コード例 #18
0
ファイル: ThemesDatabase.cs プロジェクト: Rigel2010/C2048
        /// <summary> Reset the database to the default values </summary>
        public bool ResetDatabase()
        {
#if UNITY_EDITOR
            if (!DoozyUtils.DisplayDialog(UILabels.ResetDatabase,
                                          UILabels.AreYouSureYouWantToResetDatabase +
                                          "\n\n" +
                                          UILabels.OperationCannotBeUndone,
                                          UILabels.Yes,
                                          UILabels.No))
            {
                return(false);
            }

            for (int i = Themes.Count - 1; i >= 0; i--)
            {
                ThemeData themeData = Themes[i];
                Themes.Remove(themeData);
                DataUtils.PlayerPrefsDeleteKey(themeData.Id.ToString());
                DoozyUtils.MoveAssetToTrash(AssetDatabase.GetAssetPath(themeData));
            }

            Initialize();
            DDebug.Log(UILabels.DatabaseHasBeenReset);
#endif
            return(true);
        }
コード例 #19
0
        /// <summary>
        /// Play the specified sound and follow a given target Transform while playing.
        /// Returns a reference to the SoundyController that is playing the sound.
        /// Returns null if no sound is found.
        /// </summary>
        /// <param name="databaseName"> The sound category </param>
        /// <param name="soundName"> Sound Name of the sound </param>
        /// <param name="followTarget"> The target transform that the sound will follow while playing </param>
        public static SoundyController Play(string databaseName, string soundName, Transform followTarget)
        {
            if (!s_initialized)
            {
                s_instance = Instance;
            }
            if (Database == null)
            {
                return(null);
            }
            if (soundName.Equals(NO_SOUND))
            {
                return(null);
            }
            SoundGroupData soundGroupData = Database.GetAudioData(databaseName, soundName);

            if (soundGroupData == null)
            {
                return(null);
            }
            if (Instance.DebugComponent)
            {
                DDebug.Log("Play '" + databaseName + "' / '" + soundName + "' SoundGroupData and follow the '" + followTarget.name + "' GameObject", Instance);
            }
            return(soundGroupData.Play(followTarget, Database.GetSoundDatabase(databaseName).OutputAudioMixerGroup));
        }
コード例 #20
0
ファイル: WaitNode.cs プロジェクト: Bars1704/Flatout
 private void OnUIViewMessage(UIViewMessage message)
 {
     if (ActiveGraph != null && !ActiveGraph.Enabled)
     {
         return;
     }
     if (WaitFor != WaitType.UIView)
     {
         return;
     }
     if (DebugMode)
     {
         DDebug.Log("UIViewMessage received: " + message.Type + " " + message.View.ViewCategory + " / " + message.View.ViewName + " // Listening for: " + ViewCategory + " / " + ViewName, this);
     }
     if (message.Type == UIViewBehaviorType.Unknown)
     {
         return;
     }
     if (message.Type != UIViewTriggerAction)
     {
         return;
     }
     if (AnyValue ||
         message.View.ViewCategory.Equals(ViewCategory) &&
         message.View.ViewName.Equals(ViewName))
     {
         ContinueToNextNode();
     }
 }
コード例 #21
0
        /// <summary>
        /// Play a sound according to the settings in the SoundyData reference.
        /// Returns a reference to the SoundyController that is playing the sound if data.SoundSource is set to either Soundy or AudioClip.
        /// If data is null or data.SoundSource is set to MasterAudio, it will always return null because MasterAudio is the one playing the sound and not a SoundyController </summary>
        /// <param name="data"> Sound settings </param>
        public static SoundyController Play(SoundyData data)
        {
            if (data == null)
            {
                return(null);
            }
            if (!s_initialized)
            {
                s_instance = Instance;
            }
            switch (data.SoundSource)
            {
            case SoundSource.Soundy:
                return(Play(data.DatabaseName, data.SoundName));

            case SoundSource.AudioClip:
                return(Play(data.AudioClip, data.OutputAudioMixerGroup));

            case SoundSource.MasterAudio:
                if (Instance.DebugComponent)
                {
                    DDebug.Log("Play '" + data.SoundName + "' with MasterAudio", Instance);
                }
#if dUI_MasterAudio
                DarkTonic.MasterAudio.MasterAudio.PlaySound(data.SoundName);
                //DDebug.Log("MasterAudio - Play Sound: " + data.SoundName);
#endif
                break;
            }

            return(null);
        }
コード例 #22
0
            /// <summary> Creates Script from Template's path </summary>
            public static Object CreateScript(string pathName, string templatePath)
            {
                if (pathName != null)
                {
                    string className = Path.GetFileNameWithoutExtension(pathName).Replace(" ", string.Empty);

                    var encoding = new UTF8Encoding(true, false);

                    if (File.Exists(templatePath))
                    {
                        // Read procedures.
                        var    reader       = new StreamReader(templatePath);
                        string templateText = reader.ReadToEnd();
                        reader.Close();

                        templateText = templateText.Replace("#SCRIPTNAME#", className);
                        templateText = templateText.Replace("#NOTRIM#", string.Empty);
                        // You can replace as many tags you make on your templates, just repeat Replace function
                        // e.g.:
                        // templateText = templateText.Replace("#NEWTAG#", "MyText");

                        // Write procedures.
                        var writer = new StreamWriter(Path.GetFullPath(pathName), false, encoding);
                        writer.Write(templateText);
                        writer.Close();

                        AssetDatabase.ImportAsset(pathName);
                        return(AssetDatabase.LoadAssetAtPath(pathName, typeof(Object)));
                    }
                }

                DDebug.LogError(string.Format("The template file was not found: {0}", templatePath));
                return(null);
            }
コード例 #23
0
        /// <summary> Create a new UICanvas with the given canvasName and return a reference to it </summary>
        /// <param name="canvasName"> Name of the canvas </param>
        public static UICanvas CreateUICanvas(string canvasName)
        {
            UnityEventSystem.transform.SetParent(null);
            canvasName = canvasName.Trim();
            if (string.IsNullOrEmpty(canvasName))
            {
                DDebug.Log("You cannot create a new UICanvas without entering a 'canvasName'. The 'canvasName' you passed was an empty string. No UICanvas was created and returned null.");
                return(null);
            }

            if (DatabaseContains(canvasName))
            {
                DDebug.Log("Cannot create a new UICanvas with the '" + canvasName + "' canvasName because another UICanvas with the same name already exists in the UICanvas.Database. Returned the existing UICanvas instead.");
                return(GetUICanvas(canvasName));
            }

            var go = new GameObject(canvasName, typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler), typeof(GraphicRaycaster));

            go.GetComponent <Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;
            var canvas = go.AddComponent <UICanvas>();

            canvas.CanvasName       = canvasName;
            canvas.CustomCanvasName = !canvasName.Equals(MasterCanvasName);
            return(canvas);
        }
コード例 #24
0
ファイル: UIPopupManager.cs プロジェクト: Bars1704/Flatout
        /// <summary>
        ///     Looks in the UIPopupManager PopupsDatabase for an UIPopup prefab linked to the given popup name.
        ///     If found, it instantiates a clone of it and returns a reference to it. Otherwise it returns null
        /// </summary>
        /// <param name="popupName"> Popup name to search for </param>
        public static UIPopup GetPopup(string popupName)
        {
            if (PopupDatabase.IsEmpty)
            {
                DDebug.Log("No Popups have been defined in the Popups Database. Open the Control Panel at the Popups section and add some there.");
                return(null);
            }

            if (!PopupDatabase.Contains(popupName))
            {
                DDebug.Log("No Popup with the name '" + popupName + "' has been defined in the Popups Database. Open the Control Panel at the Popups section and add it there.");
                return(null);
            }

            GameObject prefab = PopupDatabase.GetPrefab(popupName);

            if (prefab == null)
            {
                DDebug.Log("No Popup prefab with the '" + popupName + "' PopupName has been defined in the Popups Database. Open the Control Panel at the Popups section and add it there.");
                return(null);
            }

            UICanvas   canvas = prefab.GetComponent <UIPopup>().GetTargetCanvas();
            GameObject clone  = Instantiate(prefab, canvas.transform);
            var        popup  = clone.GetComponent <UIPopup>();

            popup.SetPopupName(popupName);
            return(popup);
        }
コード例 #25
0
ファイル: UIButton.cs プロジェクト: Ave-nue/Jianghu
 private void PrintBehaviorDebugMessage(UIButtonBehavior behavior, string action, bool debug = false)
 {
     if (DebugComponent || debug)
     {
         DDebug.Log("(" + ButtonName + ") UIButton - " + behavior.BehaviorType + " - " + action + ".", this);
     }
 }
コード例 #26
0
 /// <summary> Destroys all GameObjects associated with the given Scene and removes the Scene from the SceneManager </summary>
 /// <param name="sceneName"> Name or path of the Scene to unload. </param>
 public static AsyncOperation UnloadSceneAsync(string sceneName)
 {
     if (Instance.DebugComponent)
     {
         DDebug.Log("UnloadSceneAsync - sceneName: " + sceneName, Instance);
     }
     return(SceneManager.UnloadSceneAsync(sceneName));
 }
コード例 #27
0
 /// <summary> Destroys all GameObjects associated with the given Scene and removes the Scene from the SceneManager </summary>
 /// <param name="sceneBuildIndex"> Index of the Scene in BuildSettings </param>
 public static AsyncOperation UnloadSceneAsync(int sceneBuildIndex)
 {
     if (Instance.DebugComponent)
     {
         DDebug.Log("UnloadSceneAsync - sceneBuildIndex: " + sceneBuildIndex, Instance);
     }
     return(SceneManager.UnloadSceneAsync(sceneBuildIndex));
 }
コード例 #28
0
 private void RegisterListener()
 {
     Message.AddListener <GameEventMessage>(OnMessage);
     if (DebugComponent)
     {
         DDebug.Log("[" + name + "] Started listening for GameEvents", this);
     }
 }
コード例 #29
0
 private void UnregisterListener()
 {
     Message.RemoveListener <GameEventMessage>(OnMessage);
     if (DebugComponent)
     {
         DDebug.Log("[" + name + "] Stopped listening for GameEvents", this);
     }
 }
コード例 #30
0
ファイル: SoundyController.cs プロジェクト: Bars1704/Flatout
 /// <summary> Unpause all the controllers that were previously paused </summary>
 public static void UnpauseAll()
 {
     if (DebugComponent)
     {
         DDebug.Log("Unpause All");
     }
     PauseAllControllers = false;
 }