Ejemplo n.º 1
0
    public void InitRuntimeEventList()
    {
        if (eventList.Length == 0)
        {
            return;
        }
        if (runtimeEventList != null && runtimeEventList.Count > 0)
        {
            object[] ges = runtimeEventList.ToArray();
            foreach (object ge in ges)
            {
                GameEvent cge = ge as GameEvent;
                ScriptableObject.Destroy(cge);
            }
            runtimeEventList.Clear();
        }
        else
        {
            runtimeEventList = new ArrayList();
        }

        for (int i = 0; i < eventList.Length; i++)
        {
            GameEvent newge = (GameEvent)(ScriptableObject.Instantiate(eventList [i]));
            newge.setOwner(this);
            runtimeEventList.Add(newge);
        }
    }
Ejemplo n.º 2
0
    public override void draw()
    {
        if (!survive)
        {
            GUIManager.removeGUI(this);
            ScriptableObject.Destroy(this);
            return;
        }

        Vector2 pos = GUIUtility.ScreenToGUIPoint(position);

        Rect    rect    = new Rect(pos.x - radius, pos.y - radius, radius * 2f, radius * 2f);
        GUISkin natural = GUI.skin;

        GUI.skin = Resources.Load <GUISkin>("Skin");
        GUI.Box(rect, "");

        for (int i = 0; i < options.Length; i++)
        {
            Rect buttonRect = new Rect(pos.x + (radius - minDist / 2f) * Mathf.Sin(angle * i) - minDist / 2f, pos.y - (radius - minDist / 2f) * Mathf.Cos(angle * i) - minDist / 2f, minDist, minDist);
            if (Event.current.isMouse && Event.current.type == EventType.MouseUp)
            {
                if (buttonRect.Contains(GUIUtility.ScreenToGUIPoint(Event.current.mousePosition)))
                {
                    returningOption = new Option[] { options[i] };
                }
            }
            GUI.Button(buttonRect, options[i].Name);
        }
        GUI.skin = natural;
    }
Ejemplo n.º 3
0
        public static void SaveSelectedAvatarsTxt()
        {
            for (int i = 0; i < Selection.gameObjects.Length; i++)
            {
                var selectedTransform = Selection.gameObjects[i].transform;
                var avatar            = selectedTransform.GetComponent <UMAAvatarBase>();
                while (avatar == null && selectedTransform.parent != null)
                {
                    selectedTransform = selectedTransform.parent;
                    avatar            = selectedTransform.GetComponent <UMAAvatarBase>();
                }

                if (avatar != null)
                {
                    var path = EditorUtility.SaveFilePanel("Save serialized Avatar", "Assets", avatar.name + ".txt", "txt");
                    if (path.Length != 0)
                    {
                        var asset = ScriptableObject.CreateInstance <UMATextRecipe>();
                        //check if Avatar is DCS
                        if (avatar is UMA.CharacterSystem.DynamicCharacterAvatar)
                        {
                            asset.Save(avatar.umaData.umaRecipe, avatar.context, (avatar as DynamicCharacterAvatar).WardrobeRecipes, true);
                        }
                        else
                        {
                            asset.Save(avatar.umaData.umaRecipe, avatar.context);
                        }
                        System.IO.File.WriteAllText(path, asset.recipeString);
                        ScriptableObject.Destroy(asset);
                    }
                }
            }
        }
Ejemplo n.º 4
0
    public void Update()
    {
        if (0 == m_AudioSources.Count)
        {
            return;
        }

        int i;

        for (i = 0; i < m_AudioSources.Count; i++)
        {
            if (false == m_AudioSources[i].isPlaying)
            {
                AudioSource finishedSource = m_AudioSources[i];
                ScriptableObject.Destroy(finishedSource);

                m_AudioSources.RemoveAt(i);

                --i;
            }
        }

        if (0 == m_AudioSources.Count)
        {
            if (Finished != null)
            {
                Finished(this, new System.EventArgs());
            }
        }
    }
    protected override void ConvertFromUTR(UMATextRecipe sourceUTR, bool andSelect = false)
    {
        var thisUTRPath = AssetDatabase.GetAssetPath(sourceUTR);

        //copy the settings from UMATextRecipe to UMADynamicCharacterAvatarRecipe
        if (CopyFromUTR(sourceUTR))
        {
            Debug.Log("Converted " + sourceUTR.name + " to an UMADynamicCharacterAvatarRecipe");
            //rename old UMATextRecipe recipe to *name*_old
            AssetDatabase.RenameAsset(thisUTRPath, sourceUTR.name + "_old");
            AssetDatabase.CreateAsset(this, thisUTRPath);
            //Delete the old Asset
            AssetDatabase.DeleteAsset(Path.Combine(Path.GetDirectoryName(thisUTRPath), (Path.GetFileNameWithoutExtension(thisUTRPath) + "_old" + Path.GetExtension(thisUTRPath))));
            AssetDatabase.SaveAssets();
            if (andSelect)
            {
                Selection.activeObject = this;
            }
        }
        else
        {
            Debug.Log("Conversion of " + sourceUTR.name + " to an UMADynmicCharacterAvatarRecipe failed. Was the recipeType 'DynamicCharacterAvatar'?");
            ScriptableObject.Destroy(this);
        }
    }
Ejemplo n.º 6
0
    private static void CreateBond(Vector3 start, Vector3 end, Transform parent, float thickness = 0.33f)
    {
        GameObject dispBond   = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
        GameObject bondHolder = new GameObject();
        GameObject tempPos    = new GameObject();

        bondHolder.name             = "Bond";
        bondHolder.transform.parent = parent;
        dispBond.transform.parent   = bondHolder.transform;
        tempPos.transform.parent    = parent;

        dispBond.transform.Rotate(Vector3.right, 90f);
        dispBond.transform.localScale = new Vector3(thickness,  // TODO: Make this a user option
                                                    0.5f,
                                                    thickness);

        dispBond.transform.localPosition = new Vector3(0f, 0f, dispBond.transform.localScale.y);

        bondHolder.transform.localPosition = start;
        tempPos.transform.localPosition    = end;

        bondHolder.transform.localScale = new Vector3(1f, 1f, Vector3.Distance(start, end));

        bondHolder.transform.LookAt(tempPos.transform);
        ScriptableObject.Destroy(tempPos);
    }
Ejemplo n.º 7
0
    static public void RemoveAllResourceSounds()
    {
        List <Sound> sHolder = new List <Sound>();

        for (int i = 0; i < _AllSounds.Length; i++)
        {
            if (!_AllSounds[i].isResourceSound)
            {
                sHolder.Add(_AllSounds[i]);
            }
            else
            {
                ScriptableObject.Destroy(_AllSounds[i]);
            }
        }
        _AllSounds = sHolder.ToArray();
        sHolder.Clear();
        for (int i = 0; i < _AllPlaying.Count; i++)
        {
            if (!_AllPlaying[i].isResourceSound)
            {
                sHolder.Add(_AllPlaying[i]);
            }
            else
            {
                ScriptableObject.Destroy(_AllPlaying[i]);
            }
        }
        _AllPlaying = sHolder;
    }
        public override void Release()
        {
            if (_defaultResources)
            {
                ScriptableObject.Destroy(_defaultResources);
            }

            base.Release();
        }
Ejemplo n.º 9
0
 public void onDeath()
 {
     if (currHP <= 0)
     {
         udo.removeDisplayObject();
         boardSpace.removeUnitAt(xPos, yPos);
         ScriptableObject.Destroy(this);
     }
 }
Ejemplo n.º 10
0
    public static void Init()
    {
        if (_dataSession != null)
        {
            ScriptableObject.Destroy(_dataSession);
        }

//		_dataSession =
    }
Ejemplo n.º 11
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        GUILayout.Label("Avatar Name", EditorStyles.boldLabel);
        avatarName.stringValue = EditorGUILayout.TextArea(avatarName.stringValue);

        GUILayout.Space(20);

#if !StripLitJson
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Save Avatar Txt"))
        {
            UMASaveTool      umaSaveTool      = (UMASaveTool)target;
            GameObject       gameObject       = (GameObject)umaSaveTool.gameObject;
            UMADynamicAvatar umaDynamicAvatar = gameObject.GetComponent("UMADynamicAvatar") as UMADynamicAvatar;

            if (umaDynamicAvatar)
            {
                var path = EditorUtility.SaveFilePanel("Save serialized Avatar", "Assets", avatarName.stringValue + ".txt", "txt");
                if (path.Length != 0)
                {
                    var asset = ScriptableObject.CreateInstance <UMATextRecipe>();
                    asset.Save(umaDynamicAvatar.umaData.umaRecipe, umaDynamicAvatar.context);
                    System.IO.File.WriteAllText(path, asset.recipeString);
                    ScriptableObject.Destroy(asset);
                }
            }
        }

        if (GUILayout.Button("Save Avatar Asset"))
        {
            UMASaveTool      umaSaveTool      = (UMASaveTool)target;
            GameObject       gameObject       = (GameObject)umaSaveTool.gameObject;
            UMADynamicAvatar umaDynamicAvatar = gameObject.GetComponent("UMADynamicAvatar") as UMADynamicAvatar;

            if (umaDynamicAvatar)
            {
                var path = EditorUtility.SaveFilePanelInProject("Save serialized Avatar", avatarName.stringValue + ".asset", "asset", "Message 2");
                if (path.Length != 0)
                {
                    var asset = ScriptableObject.CreateInstance <UMATextRecipe>();
                    asset.Save(umaDynamicAvatar.umaData.umaRecipe, umaDynamicAvatar.context);
                    AssetDatabase.CreateAsset(asset, path);
                    AssetDatabase.SaveAssets();
                }
            }
        }

        GUILayout.EndHorizontal();

        GUILayout.Space(20);
#endif

        serializedObject.ApplyModifiedProperties();
    }
Ejemplo n.º 12
0
        static void DeinitMock()
        {
            var xrManager = XRGeneralSettings.Instance.Manager;

            xrManager.DeinitializeLoader();
            xrManager.loaders.Clear();

            ScriptableObject.Destroy(xrManager);
            ScriptableObject.Destroy(XRGeneralSettings.Instance);
            XRGeneralSettings.Instance = null;
        }
Ejemplo n.º 13
0
    public void SwitchState(State state)
    {
        State lastState = m_states.Pop();

        lastState.OnExit();
        ScriptableObject.Destroy(lastState);
        m_states.Push(state);
        state.SetStateMachine(this);
        m_currentState = state;
        m_currentState.OnEnter();
    }
Ejemplo n.º 14
0
        static void DeinitMock()
        {
            var xrManager = XRGeneralSettings.Instance.Manager;

            xrManager.DeinitializeLoader();
#pragma warning disable CS0618
            xrManager.loaders.Clear();
#pragma warning restore CS0618
            ScriptableObject.Destroy(xrManager);
            ScriptableObject.Destroy(XRGeneralSettings.Instance);
            XRGeneralSettings.Instance = null;
        }
Ejemplo n.º 15
0
 public void removeChild(SecuenceNode child)
 {
     this.childs.Remove(child);
     if (Application.isEditor)
     {
         ScriptableObject.DestroyImmediate(child);
     }
     else
     {
         ScriptableObject.Destroy(child);
     }
 }
Ejemplo n.º 16
0
    public void PopState()
    {
        State lastState = m_states.Pop();

        lastState.OnExit();
        ScriptableObject.Destroy(lastState);
        if (m_states.Count <= 0)
        {
            throw new UnityException("State machine stack empty");
        }
        m_currentState = m_states.Peek();
        m_currentState.OnEnter();
    }
Ejemplo n.º 17
0
 static public void RemoveAllSounds()
 {
     for (int i = 0; i < _AllSounds.Length; i++)
     {
         ScriptableObject.Destroy(_AllSounds[i]);
     }
     for (int i = 0; i < _AllPlaying.Count; i++)
     {
         ScriptableObject.Destroy(_AllPlaying[i]);
     }
     _AllSounds = new Sound[0];
     _AllPlaying.Clear();
 }
Ejemplo n.º 18
0
    public void Remote_CanConnectInputSystemsOverEditorPlayerConnection()
    {
        var connectionToEditor = ScriptableObject.CreateInstance <RemoteInputPlayerConnection>();
        var connectionToPlayer = ScriptableObject.CreateInstance <RemoteInputPlayerConnection>();

        connectionToEditor.name = "ConnectionToEditor";
        connectionToPlayer.name = "ConnectionToPlayer";

        var fakeEditorConnection = new FakePlayerConnection {
            playerId = 0
        };
        var fakePlayerConnection = new FakePlayerConnection {
            playerId = 1
        };

        fakeEditorConnection.otherEnd = fakePlayerConnection;
        fakePlayerConnection.otherEnd = fakeEditorConnection;

        var observer = new RemoteTestObserver();

        // In the Unity API, "PlayerConnection" is the connection to the editor
        // and "EditorConnection" is the connection to the player. Seems counter-intuitive.
        connectionToEditor.Bind(fakePlayerConnection, true);
        connectionToPlayer.Bind(fakeEditorConnection, true);

        // Bind a local remote on the player side.
        var local = new InputRemoting(InputSystem.s_Manager);

        local.Subscribe(connectionToEditor);
        local.StartSending();

        connectionToPlayer.Subscribe(observer);

        var device = InputSystem.AddDevice("Gamepad");

        InputSystem.QueueStateEvent(device, new GamepadState());
        InputSystem.Update();
        InputSystem.RemoveDevice(device);

        ////TODO: make sure that we also get the connection sequence right and send our initial layouts and devices
        Assert.That(observer.messages, Has.Count.EqualTo(4));
        Assert.That(observer.messages[0].type, Is.EqualTo(InputRemoting.MessageType.Connect));
        Assert.That(observer.messages[1].type, Is.EqualTo(InputRemoting.MessageType.NewDevice));
        Assert.That(observer.messages[2].type, Is.EqualTo(InputRemoting.MessageType.NewEvents));
        Assert.That(observer.messages[3].type, Is.EqualTo(InputRemoting.MessageType.RemoveDevice));

        ////TODO: test disconnection

        ScriptableObject.Destroy(connectionToEditor);
        ScriptableObject.Destroy(connectionToPlayer);
    }
Ejemplo n.º 19
0
        /// <summary>
        /// Override addNode to account for custom adding logic
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public override Node AddNode(Type type)
        {
            // TO DO: account for specific node types and add them to custom lists (to avoid pulling nodes every frame)
            Node node = null;

            // If the graph is attached to an IMLComponent...
            if (SceneComponent != null)
            {
                // base logic
                node = base.AddNode(type);
                bool success      = false;
                bool isCustomType = false;

                // Check if the node should be added to our IML Graph
                if (node is ScriptNode)
                {
                    // Add scriptNode.script to all lists
                    success      = SceneComponent.AddScriptNode((ScriptNode)node);
                    isCustomType = true;
                }
                else if (node is GameObjectNode)
                {
                    // Add gameObjectNode to all lists
                    success      = SceneComponent.AddGameObjectNode((GameObjectNode)node);
                    isCustomType = true;
                }

                if (isCustomType)
                {
                    // If we couldn't add the node...
                    if (success == false)
                    {
                        // Remove node from nodes list (it was added in the base logic)
                        nodes.Remove(node);
                        // Destroy node
#if UNITY_EDITOR
                        ScriptableObject.DestroyImmediate(node, true);
#else
                        ScriptableObject.Destroy(node);
#endif
                    }
                }
            }
            // If this graph is not attached to an IML Component...
            else
            {
                Debug.LogError("You can't add nodes to an IMLController that is not attached to an IMLComponent!");
            }
            return(node);
        }
Ejemplo n.º 20
0
    public void TransferToContainer(IContainer container)
    {
        if (container == null)
        {
            return;
        }

        if (itemPrefab != null)
        {
            container.AddItem((GameObject.Instantiate(itemPrefab, Vector3.zero, Quaternion.identity) as GameObject).GetComponent <IItem>());
        }

        ScriptableObject.Destroy(this);
    }
Ejemplo n.º 21
0
    public void TransferToContainer(IContainer container)
    {
        if (ItemPrefab != null)
        {
            IItem item = GameObject.Instantiate(ItemPrefab as Behaviour, Vector3.zero, Quaternion.identity) as IItem;
            if (item is ItemAmmo)
            {
                (item as ItemAmmo).ammoLeft = ammoLeft;
            }

            container.AddItem(item);
        }

        ScriptableObject.Destroy(this);
    }
Ejemplo n.º 22
0
 public void clearChilds()
 {
     foreach (ScriptableObject node in childs)
     {
         if (Application.isEditor)
         {
             ScriptableObject.DestroyImmediate(node);
         }
         else
         {
             ScriptableObject.Destroy(node);
         }
     }
     childs.Clear();
 }
Ejemplo n.º 23
0
 public override void fillControllerEvent(ControllerEventArgs args)
 {
     if (returningOption != null && !sended)
     {
         args.options = returningOption;
         args.send    = true;
         args.cell    = this.args.cell;
         GUIManager.removeGUI(this);
         sended = true;
         ScriptableObject.Destroy(this);
     }
     else
     {
         args.send = false;
     }
 }
Ejemplo n.º 24
0
    public static void DestroyGroup(string id, bool despawnObjects)
    {
        var group = Get(id);

        if (group == null)
        {
            return;
        }

        if (despawnObjects)
        {
            group.DespawnObjects();
        }

        ScriptableObject.Destroy(group);
    }
Ejemplo n.º 25
0
    public void RemoveTeam()
    {
        if (lobby.GetUnteamed().Length > 0 && lobby.TeamUIs.Length > 2)
        {
            for (int i = 0; i <= playersInTeam; i++)
            {
                RemovePlayerFromTeam();
            }
            ScriptableObject.Destroy(team);
            team = null;
            lobby.teamUIs.RemoveAt(lobby.teamUIs.IndexOf(this));
            Destroy(gameObject);

            UpdateLobbyPlayerCount();
        }
    }
Ejemplo n.º 26
0
 public void DestroyContentList()
 {
     if (m_contentList != null)
     {
         for (int i = 0; i < m_contentList.Count; i++)
         {
             var content = m_contentList[i];
             if (content == null)
             {
                 continue;
             }
             ScriptableObject.Destroy(content);
         }
     }
     m_contentList = null;
 }
Ejemplo n.º 27
0
    internal static void Deinitialize()
    {
        FlushInput();

        if (m_Instance != null)
        {
            m_Instance.ReleaseDrivers();
            m_Instance.m_Controllers.Clear();

            ScriptableObject.Destroy(m_Instance);
        }

        m_Instance = null;

        //Debug.Log(GetInstance().GetType().Name + " deinitialized.");
    }
Ejemplo n.º 28
0
    public void removeChild(int i)
    {
        SecuenceNode node = this.childs[i];

        if (node != null)
        {
            this.childs.RemoveAt(i);
            if (Application.isEditor)
            {
                ScriptableObject.DestroyImmediate(node);
            }
            else
            {
                ScriptableObject.Destroy(node);
            };
        }
    }
Ejemplo n.º 29
0
    public bool UseAmmo(int ammoConsumed)
    {
        ammoLeft -= ammoConsumed;

        Debug.Log("Ammo left : " + ammoLeft);

        if (ammoLeft <= 0)
        {
            if (OnOutOfAmmo != null)
            {
                OnOutOfAmmo(this, new System.EventArgs());
            }
            ScriptableObject.Destroy(this);
            return(false);
        }

        return(ammoLeft > 0);
    }
Ejemplo n.º 30
0
        /// <summary>
        /// Deactivate the node contents and remove the node from the active list
        /// </summary>
        /// <param name="rNode">Node to activate</param>
        public void DeactivateNode(Node rNode)
        {
            if (ShowDebug)
            {
                Utilities.Debug.Log.FileWrite(string.Format("Spell[{0}].DeactivateNode() - Node: {1}", Name, rNode.Content.GetType().Name));
            }

            // If we're dealing with a spell action, activate
            SpellAction lAction = rNode.Content as SpellAction;

            if (lAction != null)
            {
                if (lAction.State == EnumSpellActionState.ACTIVE)
                {
                    lAction.Deactivate();
                }
            }

            // Remove the node from the active list
            mActiveNodes.Remove(rNode);

            // Add the action to the shuttind down list. This way it can
            // run and we can remove it when needed
            if (lAction.IsShuttingDown)
            {
                if (ShowDebug)
                {
                    Utilities.Debug.Log.FileWrite(string.Format("Spell[{0}].DeactivateNode() - Added to expiring nodes: {1}", Name, rNode.Content.GetType().Name));
                }

                mExpiringActions.Add(lAction);
            }
            // Since we are instantiating the nodes, we now destroy them
            else // if (!rNode.IsImmediate)
            {
                if (ShowDebug)
                {
                    Utilities.Debug.Log.FileWrite(string.Format("Spell[{0}].DeactivateNode() - Destroyed: {1}", Name, rNode.Content.GetType().Name));
                }

                ScriptableObject.Destroy(rNode.Content);
                ScriptableObject.Destroy(rNode);
            }
        }