コード例 #1
0
        /// <summary>Called when this audio is expected to start. Note that context may be null.</summary>
        public virtual void Start(Dom.Node context)
        {
            // Play the clip in the context's doc:
            WorldUI wUI = (context.document as HtmlDocument).worldUI;

            GameObject root;

            if (wUI == null)
            {
                root = UI.GUINode;
            }
            else
            {
                root = wUI.gameObject;
            }

            GameObject host = new GameObject();

            host.transform.parent = root.transform;
            Source = host.AddComponent <AudioSource>();

            // 3D space if worldUI; 2D space if main UI:
            Source.spatialBlend = (wUI == null) ? 0f : 1f;

            Source.clip = Clip;
            Source.Play();
        }
コード例 #2
0
ファイル: IsHovered.cs プロジェクト: HippoAR/DemoPowerUI
        public override bool TryMatch(Dom.Node node)
        {
            if (node == null)
            {
                return(false);
            }

            // The element must be one of the active pointed ones or one of their parents:
            for (int i = 0; i < InputPointer.PointerCount; i++)
            {
                InputPointer pointer = InputPointer.AllRaw[i];

                if (pointer.ActiveOver == node)
                {
                    // Great, got it!
                    return(true);
                }
                else if (pointer.ActiveOver != null)
                {
                    // Is our node one of its parents?
                    if (node.isParentOf(pointer.ActiveOver))
                    {
                        return(true);
                    }
                }
            }

            // Nope!
            return(false);
        }
コード例 #3
0
 /// <summary>Called when this audio should now begin.</summary>
 public void Start(Dom.Node context)
 {
     if (Contents != null)
     {
         Contents.Start(context);
     }
 }
コード例 #4
0
        public static void RunOption(PowerUI.MouseEvent e)
        {
            Dom.Node targetNode = (e.target as Dom.Node);

            // Get the unique ID:
            int uniqueId;

            if (!int.TryParse(targetNode.getAttribute("unique-id"), out uniqueId))
            {
                Dom.Log.Add("A dialogue option did not have an unique-id attribute.");
                return;
            }

            // Get the widget:
            DialogueWidget dw = e.targetWidget as DialogueWidget;

            if (dw == null)
            {
                Dom.Log.Add("A dialogue option tried to run but it's not inside a DialogueWidget.");
                return;
            }

            // Great ok - we can now grab the active options entry.
            // Select the active slide with that unique ID:
            PowerSlide.DialogueSlide slide = dw.getSlide(uniqueId) as PowerSlide.DialogueSlide;

            if (slide == null)
            {
                Dom.Log.Add("Unable to resolve a DialogueSlide from a unique-id.");
                return;
            }

            // Get the GOTO:
            string gotoUrl = slide.slidesToGoTo;

            if (string.IsNullOrEmpty(gotoUrl))
            {
                // Acts just like a continue does.
                // Just cue it:
                dw.timeline.cue();
                return;
            }

            // Load it now (into the existing timeline):
            PowerSlide.Timeline.open(gotoUrl, PowerSlide.Dialogue.basePath, dw.timeline).then(delegate(object o){
                // Successfully opened it! Should already be running, but just incase:
                PowerSlide.Timeline timeline = o as PowerSlide.Timeline;

                // Start:
                timeline.start();
            }, delegate(object failure){
                // Failed!
                Dom.Log.Add("Failed to load a timeline from an option URI: " + failure);
            });

            // dw.timeline.document.startDialogue(gotoUrl,dw.Timeline.template);

            // Kill the event:
            e.stopPropagation();
        }
コード例 #5
0
ファイル: IsScope.cs プロジェクト: HippoAR/DemoPowerUI
        public override bool TryMatch(Dom.Node node)
        {
            if (node == null)
            {
                return(false);
            }

            return(node.parentNode_ == Scope);
        }
コード例 #6
0
        public override bool TryMatch(Dom.Node node)
        {
            if (node == null)
            {
                return(false);
            }

            // Get parent:
            Node parent = node.parentNode;

            if (parent == null || parent.childNodes_ == null)
            {
                return(true);
            }

            // Get the list of siblings:
            NodeList kids = parent.childNodes_;

            // Get the elements tag:
            string type = (node as Element).Tag;

            // Compare to each sibling:
            for (int i = 0; i < kids.length; i++)
            {
                Element kid = kids[i] as Element;

                if (kid == node || kid == null)
                {
                    continue;
                }

                if (kid.Tag == type)
                {
                    return(false);
                }
            }

            return(true);
        }